#define max(p,q)((p)>(q)?(p):(q)) #define ll long long ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;} #define M 1000000007 #define N 10000000 int pp[N+10]; main(){ //med解法 int n; scanf("%d",&n); while(n--){ int p,k,m=1; scanf("%d%d",&p,&k); while(k--)m*=p; int a=1,b=1,cnt=1; while(a!=0||b!=1){ int t=a+b; a=b;b=t%m;cnt++; } for(int i=2;i*i<=cnt;i++)if(cnt%i==0){ int cc=0; while(cnt%i==0){ cnt/=i; cc++; } pp[i]=max(pp[i],cc); } if(cnt!=1)pp[cnt]=max(pp[cnt],1); } int ans=1; for(int i=2;i