[Problem] To provide an excellent therapeutic or prophylactic agent for autoimmune diseases, allergic diseases, graft rejection in an organ, the bone marrow or a tissue, systemic lupus erythematosus or the like, which relies on a cathepsin-S-inhibiting activity. [Solution] It is confirmed that a nitrogenated bicyclic heterocyclic compound represented by formula (I) has a good cathepsin-S-inhibiting activity, and this confirmation leads to the accomplishment of the present invention. The compound according to the present invention has a cathepsin-S-inhibiting activity and therefore can be used as a therapeutic or prophylactic agent for autoimmune diseases, allergic diseases, graft rejection in an organ, the bone marrow or a tissue, systemic lupus erythematosus or the like.