A compound which is of formula wherein Z 1 is N and Z 2 is CH, or Z 1 is CH and Z 2 is N, or Z 1 and Z 2 is N; Z is CH or N; A is a phenyl ring or a 5 -12 membered heterocyclic ring; R 1 is H, C 1-7 alkyl, C 3-7 cycloalkyl, C 3-7 cycloalkyl C 1-7 alkyl, C 1-7 alkoxy, C 1-7 alkyl carbonyl, amino, hydroxy, hydroxy C 1-7 alkyl, halo C 1-7 alkyl, C 1-7 alkylamino C 1-7 alkyl, -R 16 -C -R 17 or -E-R 6; R 2 is H, halogen or C 1-7 alkyl; B is a 5-12 membered carbocyclic ring and R 3 is halogen, C 1-7 alkyl, C 1-7 alkoxy, halo C 1-7 alkyl or halo C 1-7 alkoxy; or B is a 5-12 membered heterocyclic ring and R 3 is H, halogen, C 1-7 alkyl, C 1-7 alkoxy, halo C 1-7 alkyl or halo C 1-7 alkoxy; R 4 is H, halogen, C 1-7 alkyl or oxo; R 5 is H, -C R 7, -SO 2 R 8 or an optionally substituted 5-6 membered heterocyclic ring; R 6 is an optionally substituted 5-6 membered heterocyclic ring; R 7 is C 1-7 alkyl, C 2-7 alkenyl, C 1-7 alkoxy, C 1-7 alkoxy C 1-7 alkyl, carboxy C 1-7 alkyl, C 1-7 alkoxy carbonyl C 1-7 alkyl, C 1-7 alkylamino C 1-7 alkyl, -NH-R 10 or -NH-X 1 -R 11; R 8 is C 1-7 alkyl, C 2-7 alkenyl, C 3-7 cycloalkyl, hydroxy C 1-7 alkyl, -NR 13 R 14, -NH-X 2 -R 15, phenyl or an optionally substituted 5-6 membered heterocyclic ring; R 10 is C 1-7 alkyl or C 3-7 cycloalkyl; R 11 is phenyl or an optionally substituted 5-6 membered heterocyclic ring; R 13 and R 14 are, independently, H, C 1-7 alkyl or C 3-7 cycloalkyl; R 15 is phenyl or an optionally substituted 5-6 membered heterocyclic ring; R 16 is a bond or a C 1-7 alkyl; R 17 is C 1-7 alkyl, C 1-7 alkoxy, C 1-7 alkylamino, amino or hydroxy; E is a bond or a C 1-7 alkyl; X 1 and X 2 are, independently, a bond or C 1-7 alkyl; or is a pharmaceutically acceptable salt thereof. Z 1 is N and Z 2 is CH, or Z 1 is CH and Z 2 is N, or Z 1 and Z 2 is N; Z is CH or N; A is a phenyl ring or a 5 -12 membered heterocyclic ring; R 1 is H, C 1-7 alkyl, C 3-7 cycloalkyl, C 3-7 cycloalkyl C 1-7 alkyl, C 1-7 alkoxy, C 1-7 alkyl carbonyl, amino, hydroxy, hydroxy C 1-7 alkyl, halo C 1-7 alkyl, C 1-7 alkylamino C 1-7 alkyl, -R 16 -C -R 17 or -E-R 6; R 2 is H, halogen or C 1-7 alkyl; B is a 5-12 membered carbocyclic ring and R 3 is halogen, C 1-7 alkyl, C 1-7 alkoxy, halo C 1-7 alkyl or halo C 1-7 alkoxy; or B is a 5-12 membered heterocyclic ring and R 3 is H, halogen, C 1-7 alkyl, C 1-7 alkoxy, halo C 1-7 alkyl or halo C 1-7 alkoxy; R 4 is H, halogen, C 1-7 alkyl or oxo; R 5 is H, -C R 7, -SO 2 R 8 or an optionally substituted 5-6 membered heterocyclic ring; R 6 is an optionally substituted 5-6 membered heterocyclic ring; R 7 is C 1-7 alkyl, C 2-7 alkenyl, C 1-7 alkoxy, C 1-7 alkoxy C 1-7 alkyl, carboxy C 1-7 alkyl, C 1-7 alkoxy carbonyl C 1-7 alkyl, C 1-7 alkylamino C 1-7 alkyl, -NH-R 10 or -NH-X 1 -R 11; R 8 is C 1-7 alkyl, C 2-7 alkenyl, C 3-7 cycloalkyl, hydroxy C 1-7 alkyl, -NR 13 R 14, -NH-X 2 -R 15, phenyl or an optionally substituted 5-6 membered heterocyclic ring; R 10 is C 1-7 alkyl or C 3-7 cycloalkyl; R 11 is phenyl or an optionally substituted 5-6 membered heterocyclic ring; R 13 and R 14 are, independently, H, C 1-7 alkyl or C 3-7 cycloalkyl; R 15 is phenyl or an optionally substituted 5-6 membered heterocyclic ring; R 16 is a bond or a C 1-7 alkyl; R 17 is C 1-7 alkyl, C 1-7 alkoxy, C 1-7 alkylamino, amino or hydroxy; E is a bond or a C 1-7 alkyl; X 1 and X 2 are, independently, a bond or C 1-7 alkyl; or is a pharmaceutically acceptable salt thereof.