Synthesis of lactams and other nitrogen heterocycles by intramolecular cyclizations of carbamates and acyl derivatives of aminosulfones