Compounds represented by the formulas (I) (II) wherein each symbol is as defined in the specification, and a prodrug thereof have a superior renin inhibitory activity, and are useful as agents for the prophylaxis or treatment of hypertension, various organ damages attributable to hypertension and the like.