Provided is a heterocyclic compound having an ROR³t inhibitory activity. A compound represented by the formula (I): wherein ring A is an optionally substituted cyclic group, Q is a bond, optionally substituted C 1-10 alkylene, optionally substituted C 2-10 alkenylene, or optionally substituted C 2-10 alkynylene, R 1 is a substituent, ring B is a thiazole ring, an isothiazole ring or a dihydrothiazole ring, each of which is optionally further substituted by a substituent in addition to R 2 , and R 2 is an optionally substituted cyclyl-carbonyl-C 1-6 alkyl group, an optionally substituted aminocarbonyl-C 1-6 alkyl group, an optionally substituted cyclyl-C 1-6 alkyl group, an optionally substituted cyclyl-C 1-6 alkylamino-carbonyl group, an optionally substituted aminocarbonyl-C 2-6 alkenyl group, an optionally substituted C 1-6 alkylcarbonylamino-C 1-6 alkyl group, an optionally substituted cyclyl-aminocarbonyl group, an optionally substituted cyclyl-carbonyl group or an optionally substituted non-aromatic heterocyclic group, or a salt thereof.