A compound of formula (Ia) wherein Q 1 represents Nor C(R 4); A is a 5- or 6-membered ring, which may be aromatic or non-aromatic, and optionally containing 1 or 2 heteroatoms selected from nitrogen and sulfur; B is a 5-membered aromatic ring containing 1 or 2 nitrogen heteroatoms; R 1 represents one or more optional substituents independently selected from halo, -R 6a, -O-R 6b, -C(=O)-R 6c, -C(=O)-N(R 7)(R 8), -CN and -N(R 7a)R 7b; or any two R 1 groups may be taken together (when attached to adjacent atoms of the A ring) to form a 5- or 6-membered ring optionally containing one or two heteroatoms, and which ring is optionally substituted by one or two C 1-3 alkyl substituents; R 2 is -C 1-4 alkyl optionally substituted by one or more substituents selected from halo and -OC 1-3 alkyl; any two of R 3, R 3a, R 4 and R 4a represent H, and the other two independently represent a substituent selected from H, F, -C 1-3 alkyl and -O-C 1-3 alkyl; R 5 is H, -R 9a, -C(=O)-R 9b, -SO 2 -R 10 or Het 1; either one of X and Y represents -CR 11a and the other represents N or -CR 11b; R 6a and R 6b independently represent hydrogen or -C 1-4 alkyl optionally substituted by one or more substituents selected from halo, -O-CH 3 and phenyl; R 6c is -C 1-3 alkyl; R 7 and R 8 are independently selected from Hand -C 1-3 alkyl; R 7a and R 7b independently represent H, C 1-6 alkyl or R 7a and R 7b are linked together to form a 3- to 6-membered ring; R 9a represents -C 1-4 alkyl, optionally substituted by one or more substituents selected from halo, -OC 1-3 alkyl and Het 2; R 9b is hydrogen or -C 1-3 alkyl (optionally substituted by one or more fluoro atoms); R 10 is -C 1-4 alkyl optionally substituted by one or more substituents selected from halo and -O-CH 3; R 11a and R 11b independently represent H, C 1-4 alkyl (itself optionally substituted by one or more substituent(s) selected from fluoro, -CN, -R 12a, -OR 12b, -N(R 12c)R 12d and/or -C N(R 12e)R 12f) or -O-C 1-4 alkyl (itself optionally substituted by one or more substituent(s) selected from fluoro, -R 12g, -OR 12h and/or -N(R 12i)R 12j); R 12a, R 12b, R 12c, R 12d, R 12e, R 12f, R 12g, R 12h, R 12i and R 12j independently represent hydrogen or C 1-3 alkyl (optionally substituted by one or more fluoro atoms); Het 1 and Het 2 independently represent a 5- or 6-membered aromatic ring containing one or two heteroatoms, preferably selected from nitrogen and sulfur, optionally substituted by one or more substitutents selected from halo and C 1-3 alkyl (itself optionally substituted by one or more fluoro atoms), or a pharmaceutically-acceptable salt thereof, Q 1 represents Nor C(R 4); A is a 5- or 6-membered ring, which may be aromatic or non-aromatic, and optionally containing 1 or 2 heteroatoms selected from nitrogen and sulfur; B is a 5-membered aromatic ring containing 1 or 2 nitrogen heteroatoms; R 1 represents one or more optional substituents independently selected from halo, -R 6a, -O-R 6b, -C(=O)-R 6c, -C(=O)-N(R 7)(R 8), -CN and -N(R 7a)R 7b; or any two R 1 groups may be taken together (when attached to adjacent atoms of the A ring) to form a 5- or 6-membered ring optionally containing one or two heteroatoms, and which ring is optionally substituted by one or two C 1-3 alkyl substituents; R 2 is -C 1-4 alkyl optionally substituted by one or more substituents selected from halo and -OC 1-3 alkyl; any two of R 3, R 3a, R 4 and R 4a represent H, and the other two independently represent a substituent selected from H, F, -C 1-3 alkyl and -O-C 1-3 alkyl; R 5 is H, -R 9a, -C(=O)-R 9b, -SO 2 -R 10 or Het 1; either one of X and Y represents -CR 11a and the other represents N or -CR 11b; R 6a and R 6b independently represent hydrogen or -C 1-4 alkyl optionally substituted by one or more substituents selected from halo, -O-CH 3 and phenyl; R 6c is -C 1-3 alkyl; R 7 and R 8 are independently selected from Hand -C 1-3 alkyl; R 7a and R 7b independently represent H, C 1-6 alkyl or R 7a and R 7b are linked together to form a 3- to 6-membered ring; R 9a represents -C 1-4 alkyl, optionally substituted by one or more substituents selected from halo, -OC 1-3 alkyl and Het 2; R 9b is hydrogen or -C 1-3 alkyl (optionally substituted by one or more fluoro atoms); R 10 is -C 1-4 alkyl optionally substituted by one or more substituents selected from halo and -O-CH 3; R 11a and R 11b independently represent H, C 1-4 alkyl (itself optionally substituted by one or more substituent(s) selected from fluoro, -CN, -R 12a, -OR 12b, -N(R 12c)R 12d and/or -C N(R 12e)R 12f) or -O-C 1-4 alkyl (itself optionally substituted by one or more substituent(s) selected from fluoro, -R 12g, -OR 12h and/or -N(R 12i)R 12j); R 12a, R 12b, R 12c, R 12d, R 12e, R 12f, R 12g, R 12h, R 12i and R 12j independently represent hydrogen or C 1-3 alkyl (optionally substituted by one or more fluoro atoms); Het 1 and Het 2 independently represent a 5- or 6-membered aromatic ring containing one or two heteroatoms, preferably selected from nitrogen and sulfur, optionally substituted by one or more substitutents selected from halo and C 1-3 alkyl (itself optionally substituted by one or more fluoro atoms),