Magnetizer and demagnetizer