An object of the present invention is to provide a novel and excellent agent for treating or preventing dementia, schizophrenia and the like, based on the 5-HT 5A receptor modulating action. It was confirmed that a compound characterized by a structure that a tricyclic hetero ring having a pyrrole ring at the center and guanidine are bonded via a carbonyl group has a potent 5-HT 5A receptor modulating action and an excellent pharmacological action based thereon, and thus, it was found that the compound can be an excellent agent for treating or preventing dementia, schizophrenia, bipolar disorder, or attention deficit hyperactivity disorder, particularly for memory-related functional disorders such as cognitive impairments including dementia and schizophrenia, thereby completing the present invention.