The present invention provides a compound having a cholinergic muscarinic M1 receptor positive allosteric modulator activity, which may be useful as medicaments such as a prophylactic or therapeutic drug for Alzheimer's disease, schizophrenia, pain, sleep disorder, Parkinson's disease dementia, dementia with Lewy bodies and the like, and the like. The present invention relates to a compound represented by the formula (I) wherein ring A is an optionally substituted 5- or 6-membered ring; R is a C 1-6 alkyl group substituted by 1 to 5 halogen atoms; and X is -CH= or -N=, or a salt thereof.