Provided is a compound which has an MAGL inhibitory effect and is expected to be useful as a prophylactic or therapeutic agent for neurodegenerative diseases (e.g., Alzheimer's disease, Parkinson's disease, Hutchinson's disease, amyotrophic lateral sclerosis, traumatic brain injury, glaucoma, multiple sclerosis, etc.), anxiety disorders, pains (e.g., inflammatory pain, cancer pain, neuropathic pain, etc.), epilepsy, depression and the like. The present invention pertains to a compound represented by formula (I): [wherein each symbol is as described in the description] or a salt thereof.