A compound of formula wherein: A 1 is N and A 2 is CR 6, R 1 is a group of the formula, R 2 is halogen; cycloalkyl; or C 1-6 alkyl or -O- C 1-6 alkyl, which may be substituted with a substituent selected from -OH, -O-C 1-6 alkyl, -NH 2, -NH-C 1-6 alkyl, -N(C 1-6 alkyl) 2, and a monocyclic nitrogen-containing hetero ring which may be substituted with C 1-6 alkyl, R 3 is C 1-6 alkyl, cycloalkyl, cycloalkenyl, aryl, heteroaryl or a saturated hetero ring, each of which may be substituted with halogen, C 1-6 alkyl, cycloalkyl, -OH, oxo, -O-C 1-6 alkyl, -COOH, -CO-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-aryl, -CO-O-C 1-6 alkylene-O-aryl, -CO-NH 2, -CO-NH-C 1-6 alkyl, -CO-N(C 1-6 alkyl) 2, -CO-N(C 1-6 alkyl)-aryl, -CO-N(C 1-6 alkyl)-(C 1-6 alkylene-aryl), -CO-NH-C 1-6 alkylene-OH, -CO-NH-C 1-6 alkylene-CO 2 H or a monocyclic sulfur-containing saturated hetero ring, R 4 and R 5 are the same or different, and each is hydrogen or C 1-6 alkyl, R 6 is hydrogen or C 1-6 alkyl, and R 8 and R b are combined with the adjacent nitrogen atom to form a polycyclic nitrogen-containing hetero ring which may be substituted with: halogen; -OH; oxo; -O-C 1-6 alkyl; cyano; nitro; halogeno-C 1-6 alkyl; cycloalkyl; aryl which may be substituted with a group selected from a group G 1; a hetero ring which may be substituted with a group selected from a group G 2; C 1-6 alkylene-(aryl which may be substituted with a group selected from a group G 1); C 1-6 alkylene-SO 2 -NR 7 R 8; C 1-6 alkylene-hetero ring; C 1-6 alkyl which may further be substituted with -OH, -O-C 1-6 alkyl, cyano, or cycloalkyl; -COOH; -CO-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-aryl, -CO-O-C 1-6 alkylene-O-aryl, -CO-NH 2, -CO-NH- C 1-6 alkyl, -CO-N(C 1-6 alkyl)2, -CO-N(C 1-6 alkyl)-aryl, -CO-N(C 1-6 alkyl)-(C 1-6 alkylene-aryl), -CO-NH-C 1-6 alkylene-OH, -CO-NH-C 1-6 alkylene-CO 2 H; -NH-SO 2 -R 9; -SO 2 -NR 7 R 8; or a monocyclic nitrogen-containing hetero ring; wherein R 7 and R 8 are the same or different, and each is hydrogen or C 1-6 alkyl; R 9 is C 1-6 alkyl, or aryl which may be substituted with C 1-6 alkyl; group G 1 is halogen, C 1-6 alkyl, halogeno-C 1-6 alkyl, -OH, -O-C 1-6 alkyl, -O-C 1-6 alkylene-aryl, -O-C 1-6 alkylene-hetero ring, -O-halogeno-C 1-6 alkyl, aryl or a hetero ring; and group G 2 is halogen, -C 1-6 alkyl, halogeno-C 1-6 alkyl, -OH, -O-C 1-6 alkyl, -O-C 1-6 alkylene-aryl, -O-C 1-6 alkylene-hetero ring, -O-halogeno-C 1-6 alkyl, aryl or hetero ring, or a pharmaceutically acceptable salt thereof. A 1 is N and A 2 is CR 6, R 1 is a group of the formula, R 2 is halogen; cycloalkyl; or C 1-6 alkyl or -O- C 1-6 alkyl, which may be substituted with a substituent selected from -OH, -O-C 1-6 alkyl, -NH 2, -NH-C 1-6 alkyl, -N(C 1-6 alkyl) 2, and a monocyclic nitrogen-containing hetero ring which may be substituted with C 1-6 alkyl, R 3 is C 1-6 alkyl, cycloalkyl, cycloalkenyl, aryl, heteroaryl or a saturated hetero ring, each of which may be substituted with halogen, C 1-6 alkyl, cycloalkyl, -OH, oxo, -O-C 1-6 alkyl, -COOH, -CO-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-aryl, -CO-O-C 1-6 alkylene-O-aryl, -CO-NH 2, -CO-NH-C 1-6 alkyl, -CO-N(C 1-6 alkyl) 2, -CO-N(C 1-6 alkyl)-aryl, -CO-N(C 1-6 alkyl)-(C 1-6 alkylene-aryl), -CO-NH-C 1-6 alkylene-OH, -CO-NH-C 1-6 alkylene-CO 2 H or a monocyclic sulfur-containing saturated hetero ring, R 4 and R 5 are the same or different, and each is hydrogen or C 1-6 alkyl, R 6 is hydrogen or C 1-6 alkyl, and R 8 and R b are combined with the adjacent nitrogen atom to form a polycyclic nitrogen-containing hetero ring which may be substituted with: halogen; -OH; oxo; -O-C 1-6 alkyl; cyano; nitro; halogeno-C 1-6 alkyl; cycloalkyl; aryl which may be substituted with a group selected from a group G 1; a hetero ring which may be substituted with a group selected from a group G 2; C 1-6 alkylene-(aryl which may be substituted with a group selected from a group G 1); C 1-6 alkylene-SO 2 -NR 7 R 8; C 1-6 alkylene-hetero ring; C 1-6 alkyl which may further be substituted with -OH, -O-C 1-6 alkyl, cyano, or cycloalkyl; -COOH; -CO-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-O-C 1-6 alkyl, -CO-O-C 1-6 alkylene-aryl, -CO-O-C 1-6 alkylene-O-aryl, -CO-NH 2, -CO-NH- C 1-6 alkyl, -CO-N(C 1-6 alkyl)2, -CO-N(C 1-6 alkyl)-aryl, -CO-N(C 1-6 alkyl)-(C 1-6 alkylene-aryl), -CO-NH-C 1-6 alkylene-OH, -CO-NH-C 1-6 alkylene-CO 2 H; -NH-SO 2 -R 9; -SO 2 -NR 7 R 8; or a monocyclic nitrogen-containing hetero ring; wherein R 7 and R 8 are the same or different, and each is hydrogen or C 1-6 alkyl; R 9 is C 1-6 alkyl, or aryl which may be substituted with C 1-6 alkyl; group G 1 is halogen, C 1-6 alkyl, halogeno-C 1-6 alkyl, -OH, -O-C 1-6 alkyl, -O-C 1-6 alkylene-aryl, -O-C 1-6 alkylene-hetero ring, -O-halogeno-C 1-6 alkyl, aryl or a hetero ring; and group G 2 is halogen, -C 1-6 alkyl, halogeno-C 1-6 alkyl, -OH, -O-C 1-6 alkyl, -O-C 1-6 alkylene-aryl, -O-C 1-6 alkylene-hetero ring, -O-halogeno-C 1-6 alkyl, aryl or hetero ring,