A compound of formula: or a pharmaceutically acceptable salt thereof wherein R 1 is optionally-substituted C 1-6 alkoxy, optionally-substituted C 3-7 cycloalkoxy, optionally-substituted 4- to 10-membered saturated heterocyclyloxy, optionally-substituted C 1-6 alkyl, optionally-substituted C 3-7 cycloalkyl, optionally-substituted C 1-6 alkylthio, optionally-substituted 4- to 10-membered saturated heterocyclyl, optionally-substituted amino, halogen atom, or hydroxy; R 2 is optionally-substituted C 1-6 alkyl, optionally-substituted C 3-7 cycloalkyl, or optionally-substituted amino; W 1 is single bond, or optionally-substituted C 1-4 alkylene; Ring Q 1 is pyridyl which may be substituted with 1 - 5 the same or different substituents selected from the group consisting of (a) halogen atom, (b) cyano, (c) C 1-6 alkyl which may be substituted with 1 - 3 the same or different halogen atoms, and (d) C 1-6 alkoxy which may be substituted with 1 - 3 the same or different halogen atoms, or pyrimidinyl which may be substituted with 1 - 3 the same or different substituents selected from the group consisting of (a) - (d) in the above; Ring Q 2 is C 6-10 aromatic carbocyclyl, or 5- to 10-membered aromatic heterocyclyl; n is 1, 2, 3, or 4; R 3 is, independently if there are plural R 3, hydrogen atom, halogen atom, cyano, hydroxy, optionally-substituted C 1-6 alkyl, optionally-substituted C 1-6 alkoxy, optionally-substituted C 3-7 cycloalkyl, optionally-substituted C 3-7 cycloalkoxy, or optionally-substituted amino; Q 2 -X 1 - is Q 2 - (single bond)-, Q 2 -(CH 2) m -O-, Q 2 -(CH 2) m -S-, Q 2 -(CH 2) m -S 2 -, Q 2 -(CH 2) m -NR a S 2 -, Q 2 -(CH 2) m -S 2 NR a -, Q 2 -(CH 2) m -C -, Q 2 - (CH 2) m -NR a -, Q 2 - (CH 2) m-NR a C -, or Q 2 -(CH 2) m -C NR a -, wherein R a is hydrogen atom or C 1-6 alkyl; m is 0, 1, or 2; W 2 is single bond, or optionally-substituted C 1-8 alkylene; and R 4 is hydrogen atom, -OR b (wherein R b is hydrogen atom, optionally-substituted C 1-6 alkyl, optionally-substituted C 1-6 alkylcarbonyl, optionally-substituted aminocarbonyl, or optionally-substituted C 1-6 alkylsulfonyl), -NR c R d (wherein R c is hydrogen atom or optionally-substituted C 1-6 alkyl; and R d is hydrogen atom, optionally-substituted C 1-6 alkyl, optionally-substituted C 1-6 alkylcarbonyl, optionally-substituted C 1-6 alkoxycarbonyl, or optionally-substituted C 1-6 alkylsulfonyl), optionally-substituted 4- to 10-membered saturated heterocyclyl, or optionally-substituted 5- to 10-membered heteroaryl. R 1 is optionally-substituted C 1-6 alkoxy, optionally-substituted C 3-7 cycloalkoxy, optionally-substituted 4- to 10-membered saturated heterocyclyloxy, optionally-substituted C 1-6 alkyl, optionally-substituted C 3-7 cycloalkyl, optionally-substituted C 1-6 alkylthio, optionally-substituted 4- to 10-membered saturated heterocyclyl, optionally-substituted amino, halogen atom, or hydroxy; R 2 is optionally-substituted C 1-6 alkyl, optionally-substituted C 3-7 cycloalkyl, or optionally-substituted amino; W 1 is single bond, or optionally-substituted C 1-4 alkylene; Ring Q 1 is pyridyl which may be substituted with 1 - 5 the same or different substituents selected from the group consisting of (a) halogen atom, (b) cyano, (c) C 1-6 alkyl which may be substituted with 1 - 3 the same or different halogen atoms, and (d) C 1-6 alkoxy which may be substituted with 1 - 3 the same or different halogen atoms, or pyrimidinyl which may be substituted with 1 - 3 the same or different substituents selected from the group consisting of (a) - (d) in the above; pyridyl which may be substituted with 1 - 5 the same or different substituents selected from the group consisting of (a) halogen atom, (b) cyano, (c) C 1-6 alkyl which may be substituted with 1 - 3 the same or different halogen atoms, and (d) C 1-6 alkoxy which may be substituted with 1 - 3 the same or different halogen atoms, or (a) halogen atom, (b) cyano, (c) C 1-6 alkyl which may be substituted with 1 - 3 the same or different halogen atoms, and (d) C 1-6 alkoxy which may be substituted with 1 - 3 the same or different halogen atoms, or pyrimidinyl which may be substituted with 1 - 3 the same or different substituents selected from the group consisting of (a) - (d) in the above; Ring Q 2 is C 6-10 aromatic carbocyclyl, or 5- to 10-membered aromatic heterocyclyl; n is 1, 2, 3, or 4; R 3 is, independently if there are plural R 3, hydrogen atom, halogen atom, cyano, hydroxy, optionally-substituted C 1-6 alkyl, optionally-substituted C 1-6 alkoxy, optionally-substituted C 3-7 cycloalkyl, optionally-substituted C 3-7 cycloalkoxy, or optionally-substituted amino; Q 2 -X 1 - is Q 2 - (single bond)-, Q 2 -(CH 2) m -O-, Q 2 -(CH 2) m -S-, Q 2 -(CH 2) m -S 2 -, Q 2 -(CH 2) m -NR a S 2 -, Q 2 -(CH 2) m -S 2 NR a -, Q 2 -(CH 2) m -C -, Q 2 - (CH 2) m -NR a -, Q 2 - (CH 2) m-NR a C -, or Q 2 -(CH 2) m -C NR a -, wherein R a is hydrogen atom or C 1-6 alkyl; m is 0, 1, or 2; W 2 is single bond, or optionally-substituted C 1-8 alkylene; and R 4 is hydrogen atom, -OR b (wherein R b is hydrogen atom, optionally-substituted C 1-6 alkyl, optionally-substituted C 1-6 alkylcarbonyl, optionally-substituted aminocarbonyl, or optionally-substituted C 1-6 alkylsulfonyl), -NR c R d (wherein R c is hydrogen atom or optionally-substituted C 1-6 alkyl; and R d is hydrogen atom, optionally-substituted C 1-6 alkyl, optionally-substituted C 1-6 alkylcarbonyl, optionally-substituted C 1-6 alkoxycarbonyl, or optionally-substituted C 1-6 alkylsulfonyl), optionally-substituted 4- to 10-membered saturated heterocyclyl, or optionally-substituted 5- to 10-membered heteroaryl.