The compound represented by formulae (I) and (II), the salt thereof, the N-oxide thereof or the solvate thereof, or the prodrug thereof and the pharmaceutical composition comprising thereof have a CXCR4-regulating effect, and they are effective in treatment and prevention of various inflammatory disease, various allergic disease, acquired immunodeficiency syndrome infection with human immunodeficiency virus, or agents for regeneration therapy.(wherein ring A represents a nitrogen-containing heterocyclic group which may have a substituent(s); ring B represents a homocyclic group which may have a substituent(s) or a heterocyclic group which may have a substituent(s); and Y represents a hydrocarbon group which may have a substituent(s), a heterocyclic group which may have a substituent(s), an amino group which may be protected, a hydroxyl group which may be protected or a mercapto group which may be protected; T represents ring A or an amino group which may be protected.)