Exciton and Shallow Impurity States of Semiconductors in an Arbitrary Magnetic Field