int a,b,r[9];{rd(a,a);Permutation p(101);p=1;REP(a)rd(a,b),swap(p[a],p[b]);wt(lcm(r(p.cycle_len(r))));}