a[999],x,y,c,i;g(a,b){return b?g(b,a%b):a;}main(s){for(;~scanf("%d%d",&x,&y);a[y]=a[x]?a[x]:x*c,a[x]=i*c,c=1)i=a[y]?a[y]:y;for(i=101;y=--i;s*=c/g(s,c))for(c=1;(y=a[y])&&y-i;c++);c=!printf("%d",s);}