[Problem] On the basis of a cathepsin S inhibitory effect, an excellent agent for treating or preventing autoimmune disease, allergic disease, graft rejection of an organ, bone marrow or tissue, systemic lupus erythematosus, or the like is provided. [Means for Solution] It was found that a nitrogen-containing bicyclic heterocyclic compound has the excellent cathepsin S inhibitory effect, thereby completing the invention. The compound of the present invention has the cathepsin S inhibitory effect, and can be used as an agent for preventing and/or treating autoimmune disease, allergic disease, graft rejection of an organ, bone marrow or tissue, systemic lupus erythematosus, or the like.