#include #define ff first #define ss second #define pb push_back typedef long long ll; using namespace std; typedef pair pii; const int mod=1e9+7; inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;} inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;} inline int mul(int x,int y){return ((ll)x*y)%mod;} inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;} inline int invv(int x){return step(x,mod-2);} inline char gc() { // like getchar() static char buf[1 << 16]; static size_t bc, be; if (bc >= be) { buf[0] = 0, bc = 0; be = fread(buf, 1, sizeof(buf), stdin); } return buf[bc++]; // returns 0 on EOF } int readInt() { int a, c; while ((a = gc()) < 40); if (a == '-') return -readInt(); while ((c = gc()) >= 48) a = a * 10 + c - 480; return a - 48; } const int maxn=1e6+10; const int mb=20; const int mxb=(1<>ops; int n,a[maxn],b[maxn],c[maxn],d[maxn]; void do_op(int op,int ind,int val){ ops.pb({op,{ind,val} }); } void ispis_ops(){ printf("%d\n",ops.size()); for(int i=0;iget_op(int bt){ int pos[2][2]; memset(pos,0,sizeof(pos)); for(int i=1;i<=n;i++){ pos[c[i]][d[i]]=i; } if(calc())return {-1,{-1,-1}}; if(pos[0][1]){ int id=pos[0][1]; c[id]=1; if(calc())return {2,{id,bt}}; c[id]=0; d[id]=0; if(calc())return {1,{id,mxb-bt}}; d[id]=1; c[id]^=1; d[id]^=1; if(calc())return {3,{id,bt}}; c[id]^=1; d[id]^=1; } if(pos[1][0]){ int id=pos[1][0]; c[id]=0; if(calc())return {1,{id,mxb-bt}}; c[id]=1; d[id]=1; if(calc())return {2,{id,bt}}; d[id]=0; c[id]^=1; d[id]^=1; if(calc())return {3,{id,bt}}; c[id]^=1; d[id]^=1; } if(pos[1][1]){ int id=pos[1][1]; c[id]=0; d[id]=0; if(calc())return {1,{id,mxb-bt}}; c[id]=1; d[id]=1; c[id]^=1; d[id]^=1; if(calc())return {3,{id,bt}}; c[id]^=1; d[id]^=1; } if(pos[0][0]){ int id=pos[0][0]; d[id]=1; c[id]=1; if(calc())return {2,{id,bt}}; d[id]=0; c[id]=0; c[id]^=1; d[id]^=1; if(calc())return {3,{id,bt}}; c[id]^=1; d[id]^=1; } assert(1==0); } void solvebig(){ for(int i=0;i0); d[j]=((b[j]&(1<0); } pairpom=get_op(1<