#include <bits/stdc++.h>
using namespace std;
#define fastIo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,n) for(int i=1;i<=n;i++)
#define f3(i,l,r) for(int i=l;i<=r;i++)
#define pb push_back
#define int long long
#define ff first
#define ALL(v) v.begin(),v.end()
#define pii pair<int,int>
#define ss second
#define tree preihjpoueheaopuhjew
const int N=1e5+100;
int n;
pii query[N];
int limit;
int max(int a,int b) {
return a>b?a:b;
}
vector<int>comp;
struct tree {
int cnt,g;
tree(int _g=0,int _cnt=0) {
g=_g;
cnt=_cnt;
}
void merge(tree left,tree right){
g=__gcd(left.g,right.g);
}
};
tree stGcd[4*N];
int __gcd(int a,int b) {
return b==0?a:__gcd(b,a%b);
}
int compress() {
for (int i = 1; i <= n; i++) {
comp.pb(query[i].ss);
}
sort(ALL(comp));
comp.resize(unique(ALL(comp)) - comp.begin());
for (int i = 1; i <= n; i++) {
query[i].ss = lower_bound(ALL(comp), query[i].ss) - comp.begin() + 1;
}
return comp.size();
}
void updateGcdTree(int ix,int v,int i=1,int l=1,int r=limit) {
if(!(l<=ix&&ix<=r))return;
if(l==r&&l==ix){
stGcd[i].cnt+=v;
if(stGcd[i].cnt>=1)stGcd[i].g=comp[l-1];
else stGcd[i].g=0;
return;
}
int m=(l+r)>>1,cl=2*i,cr=2*i+1;
updateGcdTree(ix,v,cl,l,m);
updateGcdTree(ix,v,cr,m+1,r);
stGcd[i].merge(stGcd[cl],stGcd[cr]);
}
tree queriesGcdTree(int u,int v,int i=1,int l=1,int r=limit) {
if(l>v||r<u)return tree();
if(u<=l&&v>=r)return stGcd[i];
int m=(l+r)>>1,cl=2*i,cr=2*i+1;
tree ans;
ans.merge(queriesGcdTree(u,v,cl,l,m),queriesGcdTree(u,v,cr,m+1,r));
return ans;
}
signed main() {
fastIo;
cin>>n;
int cnt=0;
f(i,n)cin>>query[i].ff>>query[i].ss;
limit=compress();
f(i,n) {
int x=query[i].ss;
// cout<<"E:"<<x<<"\n";
if(query[i].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