#include #include using namespace std; typedef long long ll; ll a[100010],b[100010],d[100010],p = 223577; ll pw(ll a,ll x){ ll ret = 1; while(x){ if(x&1) (ret *= a) %= p; (a *= a) %= p; x /= 2; } return ret; } vector> ans; void solve(int i,int j){ ans.push_back({i,j}); (a[i] += a[j]) %= p; } void fin(){ for(int i=0;i> n; for(i=0;i> a[i]; for(i=0;i> b[i]; bool f1 = false,f2 = false; for(i=0;i z1,z2; int j = -1,k = 0; for(i=0;i1) j = z1[1]; else k = z2[1]; } ll inv = pw(a[j],p - 2); for(i=0;ib[k]) a[k] -= p; ll dif = b[k] - a[k]; while(dif){ if(dif&1) solve(k,j); solve(j,j); dif /= 2; } ll inv2 = pw(a[k],p - 2); for(i=0;i