The present invention provides a compound having a CaMKII inhibitory action, which is expected to be useful as an agent for the prophylaxis or treatment of cardiac diseases (particularly catecholaminergic polymorphic ventricular tachycardia, postoperative atrial fibrillation, heart failure, fatal arrhythmia) and the like.The present invention relates to a compound represented by the formula (I):wherein each symbol is as defined in the specification,or a salt thereof.