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