The present invention provides a heterocyclic compound having an IRAK-4 inhibitory action, which is useful for the prophylaxis or treatment of inflammatory disease, autoimmune disease, osteoarticular degenerative disease, neoplastic disease and the like, and a medicament containing thereof. 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.