import java.util.*; class point{ int op=-1,num,key; String name; int time = 0; int mark = 0; point sdom, label, ancestor, parent, dom; ArrayList in=new ArrayList(); ArrayList out=new ArrayList(); ArrayList bucket=new ArrayList(); point() { this.sdom = this.label = this; this.ancestor = this.dom = this.parent = null; this.in = new ArrayList(); this.out = new ArrayList(); this.bucket = new ArrayList(); } point(String name, int op, int num, int key){ this.name = name; this.op = op; this.num = num; this.key = key; } point(String name, int num, int key){ this.name = name; this.num = num; this.key = key; } } public class Factorial { public static void main(String[] args){ HashMap Map = new HashMap(); Scanner sc = new Scanner(System.in); int i,j,n,ans,k=0,p=0,t=1; char[]bufff = new char[20]; String buff=new String(); String buff1=new String(); String buff2=new String(); buff1=""; int buf; buff=sc.nextLine(); n=Integer.valueOf(buff); point [] graph=new point[n]; point [] forms=new point[n]; for(i=0;i G=new ArrayList(); for(i=0;i { return p1.time - p2.time; }); } public static void dfs(point p,int time) { time+=1; p.mark=1; p.time=time; int i; for(i = 0; i < p.out.size(); i++){ if(p.out.get(i).mark != 1){ p.out.get(i).parent=p; dfs(p.out.get(i),time); } } } }