QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#798302#8647. JOI TourMath4Life202086 2505ms805788kbC++1412.3kb2024-12-04 11:28:142024-12-04 11:28:14

Judging History

你现在查看的是最新测评结果

  • [2024-12-04 11:28:14]
  • 评测
  • 测评结果:86
  • 用时:2505ms
  • 内存:805788kb
  • [2024-12-04 11:28:14]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include "joitour.h"
#include <bits/stdc++.h>
using namespace std;
using ll = int; using pii = pair<ll,ll>;
const ll Nm = 2e5+5;

ll N;
long long ans = 0;
vector<int> F,U,V;
vector<pii> locs[Nm]; //{index of subtree, index in subtree}
ll rlbl[Nm];
//vector<ll> hld;

const ll Sm = 4194304; const ll E = 22;

//long long sts0[2*Sm]; //already pushed sum s0
int na0[2*Sm];  //number active in 0
int pd0[2*Sm]; //number to push down
//long long sts2[2*Sm];
int na2[2*Sm];
int pd2[2*Sm];
ll allc = 0; //allocator for memory

ll v2(ll x) {
    return __builtin_ctz(x);
}

inline void pdn0(ll p) { //push down at position p
    //return;
    //sts0[p]+=stna0[p]*pd0[p];
    pd0[2*p]+=pd0[p];
    pd0[2*p+1]+=pd0[p];
    pd0[p]=0;
}

inline void pdn2(ll p) { //push down at position p
    //return;
    //sts2[p]+=stna2[p]*pd2[p];
    pd2[2*p]+=pd2[p];
    pd2[2*p+1]+=pd2[p];
    pd2[p]=0;
}

ll wrt0(ll x, ll v) { //v is the DELTA
    //return 0;
    for (ll e=16;e>0;e--) {
        pdn0((x>>e)+(1LL<<(E-e)));
    }
    //sts0[x+Sm] += v*pd0[x+Sm];
    na0[x+Sm] += v;
    for (ll e=1;e<=16;e++) {
        ll p = ((x>>e)+(1LL<<(E-e)));
        //sts0[p] += v*pd0[x+Sm];
        na0[p] += v;
    }
    return v*pd0[x+Sm];
}

ll wrt2(ll x, ll v) {
    //return 0;
    for (ll e=16;e>0;e--) {
        pdn2((x>>e)+(1LL<<(E-e)));
    }
   // sts2[x+Sm] += v*pd2[x+Sm];
    na2[x+Sm] += v;
    for (ll e=1;e<=16;e++) {
        ll p = ((x>>e)+(1<<(E-e)));
        //sts2[p] += v*pd2[x+Sm];
        na2[p] += v;
    }
    return v*pd2[x+Sm];
}

pii wrtI(ll x, ll y, ll v) { //return {n21, n01} updates
    //cout << "write 1 to range "<<x<<","<<y<<"\n";
    //return {0,0};
    if (x>y) {
        return {0,0};
    }
    ll vx = v2(x); ll vy = v2(y+1);
    if (vx<vy) {
        ll p = (x>>vx)+(1<<(E-vx));
        pii p1 = {v*na0[p],v*na2[p]};
        pd0[p]+=v; pd2[p]+=v;
        pii p2 = wrtI(x+(1<<vx),y,v);
        return {p1.first+p2.first,p1.second+p2.second};
    } else {
        ll p = (y>>vy)+(1<<(E-vy));
        pii p1 = {v*na0[p],v*na2[p]};
        pd0[p]+=v; pd2[p]+=v;
        pii p2 = wrtI(x,y-(1<<vy),v);
        return {p1.first+p2.first,p1.second+p2.second};
    }
}

struct cst { //cdt subtree
    ll M;
    long long n0,n2,n21,n01;
    vector<ll> Fn;
    ll r;
    vector<vector<ll>> fadj;
    vector<ll> radj;
    vector<int> tsz; //subtree size
    vector<int> sti; //segtree index
   // vector<long long> v0,v2,v21,v01;
    /*void lft(ll x) {
        v0[x]=(Fn[x]==0);
        v2[x]=(Fn[x]==2);
        v21[x]=0;
        v01[x]=0;
        for (ll y: fadj[x]) {
            lft(y);
            v0[x]+=v0[y];
            v2[x]+=v2[y];
            v01[x]+=v01[y];
            v21[x]+=v21[y];
        }
        if (Fn[x]==1) {
            v01[x]+=v0[x];
            v21[x]+=v2[x];
        }
    }
    void calc() {
        vector<long long> emp(M,0);
        v0=emp; v2=emp; v21=emp; v01=emp;
        lft(r);
        n0=v0[r]; n2=v2[r]; n21=v21[r]; n01=v01[r];
        v0.clear(); v2.clear(); v21.clear(); v01.clear();
    }*/
    cst(ll r0, ll M0, vector<vector<ll>> adj,vector<ll> f0) {
        n0=0; n2=0; n21=0; n01=0;
        r=r0; M=M0;
        Fn=f0;
        vector<bool> found;
        for (ll m=0;m<M;m++) {
            tsz.push_back(0);
            sti.push_back(0);
            radj.push_back(-1);
            found.push_back(0);
            fadj.push_back((vector<ll>){});
        }
        // queue<ll> q;
        // q.push(r);
        // while (!q.empty()) {
        //     ll x = q.front(); q.pop();
        //     found[x]=1;
        //     for (ll y: adj[x]) {
        //         if (!found[y]) {
        //             radj[y]=x;
        //             q.push(y);
        //             fadj[x].push_back(y);
        //         }
        //     }
        // }
        stack<pii> q0;
        q0.push({r,0});
        while (!q0.empty()) {
            pii p0 = q0.top(); q0.pop();
            ll x = p0.first; ll t = p0.second;
            if (t==0) {
                found[x]=1;
                q0.push({x,1});
                for (ll y: adj[x]) {
                    if (!found[y]) {
                        radj[y]=x;
                        q0.push({y,0});
                        fadj[x].push_back(y);
                    }
                }
            } else {
                tsz[x]=1;
               // cout << "x="<<x<<", Fn[x]="<<Fn[x]<<"\n";
                for (ll y: adj[x]) {
                   // cout << "y in fadj="<<y<<"\n";
                    if (radj[y]==x) {
                        //cout << "f1\n";
                        tsz[x]+=tsz[y];
                    }
                }
                //cout << "tsz[x]="<<tsz[x]<<"\n";
                sti[x]=allc;
                if (f0[x]==0) {
                    n0++;
                    n01 += wrt0(allc,1); //v is the DELTA
                } else if (f0[x]==2) {
                    n2++;
                    n21 += wrt2(allc,1);
                } else {
                    pii p1mod = wrtI(allc-tsz[x]+1,allc,1);
                    n01 = p1mod.first+n01;
                    n21 = p1mod.second+n21;
                }
                allc++;
            }
        }
        //cout << "n0,n2,n01,n21="<<n0<<","<<n2<<","<<n01<<","<<n21<<"\n";
        //calc();
    }
    /*void upd(ll x, ll v) {
        Fn[x]=v;
        calc();
    }*/
    void upd(ll x, ll v) {
        if (Fn[x]==0) {
            n0--;
            n01 += wrt0(sti[x],-1);
        } else if (Fn[x]==2) {
            n2--;
            n21 += wrt2(sti[x],-1);
        } else {
            pii p1mod = wrtI(sti[x]-tsz[x]+1,sti[x],-1);
            n01 = p1mod.first+n01;
            n21 = p1mod.second+n21;
        }
        Fn[x]=v;
        if (Fn[x]==0) {
            n0++;
            n01 += wrt0(sti[x],1);
        } else if (Fn[x]==2) {
            n2++;
            n21 += wrt2(sti[x],1);
        } else {
            pii p1mod = wrtI(sti[x]-tsz[x]+1,sti[x],1);
            n01 = p1mod.first+n01;
            n21 = p1mod.second+n21;
        }
       // cout << "n0,n2,n01,n21="<<n0<<","<<n2<<","<<n01<<","<<n21<<"\n";
    }
}; 

struct cdt { //centroid decomp tree
    ll M; //size
    vector<vector<ll>> fadj;
    vector<ll> Fn; //new F
    vector<pii> strl; //subtree locations: {index of st, index in st}
    vector<cst*> v1;
    long long s21=0, s01=0, s0=0, s2=0, s210=0, s012=0, s02=0;
    cdt(ll M1, vector<vector<ll>> fadj1, vector<ll> Fn1) { //fadj is really just adj oops
        M=M1; fadj=fadj1; Fn=Fn1;
        for (ll m=0;m<M;m++) {
            strl.push_back((pii){0,0});
        }
        ll rcnt = 0;
        for (ll x: fadj[0]) {
            //unordered_map<ll,ll> rlbl; //relabel
            vector<vector<ll>> nadj;
            vector<ll> fnew;
            ll Mn = 0;
            queue<pii> q0;
            q0.push({x,-1});
            //cout << "x="<<x<<"\n";
            while (!q0.empty()) {
                pii p0 = q0.front(); q0.pop();
                ll z = p0.first; ll pz = p0.second;
                if (z==0) {
                    continue;
                }
                //if (rlbl.find(z)==rlbl.end()) {
                    rlbl[z]=Mn++;
                    //cout << "defining z="<<z<<" as "<<rlbl[z]<<"\n";
                    nadj.push_back((vector<ll>){});
                    fnew.push_back(Fn[z]);
                    strl[z]={rcnt,rlbl[z]};
                    //cout << "relabel: z="<<z<<"->"<<rlbl[z]<<"\n";
                    //locs[z].push_back({dind,rlbl[z]});
               // }
                if (pz != -1) {
                    //cout << "z,pz="<<z<<","<<pz<<"\n";
                    nadj[rlbl[z]].push_back(rlbl[pz]);
                    nadj[rlbl[pz]].push_back(rlbl[z]);
                }
                for (ll nz: fadj[z]) {
                    if (nz != pz && nz != 0) {
                        q0.push({nz,z});
                    }
                }
            }
            v1.push_back(new cst(0LL,Mn,nadj,fnew));
            rcnt++;
        }
        for (ll r=0;r<rcnt;r++) {
            s21 += (v1[r]->n21);
            s01 += (v1[r]->n01);
            s0 += (v1[r]->n0);
            s2 += v1[r]->n2;
            s210 += (v1[r]->n21)*(v1[r]->n0);
            s012 += (v1[r]->n01)*(v1[r]->n2);
            s02 += (v1[r]->n0)*(v1[r]->n2);
        }
        ans += (s21*s0-s210+s01*s2-s012);
        if (Fn[0]==0) {
            ans += s21;
        } else if (Fn[0]==1) {
            ans += (s0*s2-s02);
        } else {
            ans += s01;
        }
    }
    void upd(ll x, ll vf) {
        if (x==0) {
            ll v0 = Fn[0];
            if (v0==0) {
                ans -= s21;
            } else if (v0==1) {
                ans -= (s0*s2-s02);
            } else {
                assert(v0==2);
                ans -= s01;
            }
            if (vf==0) {
                ans += s21;
            } else if (vf==1) {
                ans += (s0*s2-s02);
            } else {
                assert(vf==2);
                ans += s01;
            }
        } else {
            ll v0 = Fn[0];
            if (v0==0) {
                ans -= s21;
            } else if (v0==1) {
                ans -= (s0*s2-s02);
            } else {
                assert(v0==2);
                ans -= s01;
            }
            ans -= (s21*s0-s210+s01*s2-s012);

            ll i = strl[x].first;
            s21 -= (v1[i]->n21);
            s01 -= (v1[i]->n01);
            s2 -= (v1[i]->n2);
            s0 -= (v1[i]->n0);
            s210 -= (v1[i]->n21)*(v1[i]->n0);
            s012 -= (v1[i]->n01)*(v1[i]->n2);
            s02 -= (v1[i]->n0)*(v1[i]->n2);

            (*v1[i]).upd(strl[x].second,vf);

            i = strl[x].first;
            s21 += (v1[i]->n21);
            s01 += (v1[i]->n01);
            s2 += (v1[i]->n2);
            s0 += (v1[i]->n0);
            s210 += (v1[i]->n21)*(v1[i]->n0);
            s012 += (v1[i]->n01)*(v1[i]->n2);
            s02 += (v1[i]->n0)*(v1[i]->n2);

            v0 = Fn[0];
            if (v0==0) {
                ans += s21;
            } else if (v0==1) {
                ans += (s0*s2-s02);
            } else {
                assert(v0==2);
                ans += s01;
            }
            ans += (s21*s0-s210+s01*s2-s012);
        }
        Fn[x]=vf;
    }
};

vector<ll> adj[Nm];
bool found[Nm];
ll sz[Nm]; 
ll rev[Nm];
vector<cdt*> cdtr;

ll getsz(ll x, ll pr = -1) {
    sz[x]=1;
    for (ll y: adj[x]) {
        if (y != pr && !found[y]) {
            sz[x]+=getsz(y,x);
        }
    }
    return sz[x];
}

ll getctr(ll x, ll sz0, ll pr=-1) {
    for (ll y: adj[x]) {
        if (y != pr && !found[y]) {
            if (2*sz[y]>=sz0) {
                return getctr(y,sz0,x);
            }
        }
    }
    return x;
}

ll dind = 0; //index in cdtr

void bldDcmp(ll x=0) { //start, previous
    ll sz0 = getsz(x);
    ll y = getctr(x,sz0);
    vector<vector<ll>> nadj; //new adjacency
    vector<ll> fnew;
    ll M = 0;
    queue<pii> q0;
    q0.push({y,-1});
    while (!q0.empty()) {
        pii p0 = q0.front(); q0.pop();
        ll z = p0.first; ll pz = p0.second;
        rlbl[z]=M++;
        nadj.push_back((vector<ll>){});
        fnew.push_back(F[z]);
        locs[z].push_back({dind,rlbl[z]});
        if (pz != -1) {
            nadj[rlbl[z]].push_back(rlbl[pz]);
            nadj[rlbl[pz]].push_back(rlbl[z]);
        }
        for (ll zn: adj[z]) {
            if (!found[zn] && zn != pz) {
                q0.push({zn,z});
            }
        }
    }
    cdtr.push_back(new cdt(M,nadj,fnew));
    found[y]=1;
    dind++;
    for (ll z: adj[y]) {
        if (!found[z]) {
            bldDcmp(z);
        }
    }
}

void init(int N1, vector<int> F1, vector<int> U1, vector<int> V1, int Q) {
    N=N1;
    F=F1;
    U=U1;
    V=V1;
    for (ll i=0;i<(N-1);i++) {
        adj[U[i]].push_back(V[i]);
        adj[V[i]].push_back(U[i]);
    }
    bldDcmp(); //build centroid decomposition
}

void change(int x, int y) {
    for (pii p0: locs[x]) {
        (*cdtr[p0.first]).upd(p0.second,y);
    }
}

long long num_tours() {
    return ans;
}

詳細信息

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 50496kb

input:

400
1 1 0 2 2 0 2 1 1 1 1 0 1 2 2 2 2 0 0 2 0 2 0 2 1 1 2 2 1 2 1 0 1 2 2 2 0 0 0 2 1 2 2 0 0 0 1 2 1 1 0 1 1 2 1 2 2 2 1 1 0 1 1 1 2 2 1 1 0 0 1 1 0 0 1 1 1 2 2 2 1 1 2 1 1 1 0 2 0 2 1 0 1 1 2 0 0 2 1 0 2 2 1 0 0 0 0 1 1 1 0 1 2 1 1 1 2 0 2 2 0 2 0 1 0 1 1 1 1 0 1 1 0 0 0 2 2 0 2 2 2 1 1 0 1 2 0 1 ...

output:

597892
604453
604236
600488
598028
594449
593671
586072
582432
581797
586919
588018
591441
592178
589303
587825
591777
595845
591906
591733
593937
592286
587593
583280
582383
580941
576582
577908
579779
578590
578141
577238
577854
584168
591759
594698
591476
590496
583825
582797
581264
586076
587779...

result:

ok 

Test #2:

score: 6
Accepted
time: 3ms
memory: 54564kb

input:

3
1 2 2
0 2
0 1
100
1 0
2 0
0 2
0 0
0 1
2 1
0 2
0 1
0 2
0 1
0 2
1 2
2 2
0 1
2 0
1 0
1 2
1 0
1 1
0 2
1 2
1 0
2 2
2 0
1 1
0 1
1 2
2 1
2 2
2 0
2 2
2 0
2 1
2 0
2 1
1 1
1 0
1 1
0 0
2 0
0 1
1 0
1 2
0 0
0 1
1 1
0 0
2 2
0 1
2 0
0 2
2 2
2 1
1 2
0 1
1 1
1 2
1 0
0 2
2 0
2 1
0 0
0 1
1 2
1 1
2 2
1 2
0 2
1 1
0 1
...

output:

0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #3:

score: 6
Accepted
time: 0ms
memory: 54128kb

input:

4
2 2 0 2
1 2
1 3
0 3
100
2 2
2 0
0 0
1 1
0 2
2 2
1 2
3 1
0 0
2 1
3 2
0 1
3 0
1 1
3 2
0 0
0 2
2 0
0 0
3 1
2 2
2 1
2 0
3 2
1 0
0 1
3 1
2 1
3 0
3 2
3 1
3 2
2 0
3 0
0 2
0 0
3 2
0 2
3 1
0 0
1 1
2 2
2 1
2 0
0 2
3 2
3 1
1 0
0 0
0 2
3 0
2 2
0 0
3 2
3 0
3 2
2 0
1 2
0 1
1 0
3 1
1 2
1 0
1 1
3 0
0 2
1 0
0 0
1 ...

output:

0
0
0
0
1
2
0
0
0
2
1
0
0
0
0
0
0
0
2
1
0
2
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
2
0
0
2
2
2
2
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
2
0
0
0
2
0
0
0
0
0
0
0
2
1
1
1
0
1
0
1
2
0
0
0
0
0
0
0
0
0

result:

ok 

Test #4:

score: 6
Accepted
time: 0ms
memory: 51260kb

input:

5
2 0 1 2 1
0 3
3 4
2 3
1 3
100
0 0
1 2
3 0
0 1
3 1
3 2
1 1
1 0
0 0
0 1
0 2
2 0
0 0
0 1
3 0
0 2
3 1
3 0
4 0
1 1
4 2
0 1
3 1
2 1
0 2
3 0
3 1
1 2
1 1
4 0
1 2
2 0
4 2
4 1
4 2
3 0
3 2
2 1
0 0
0 2
1 1
4 0
2 0
2 1
2 2
1 2
3 1
2 0
0 1
3 2
2 2
0 2
0 1
4 2
3 0
2 0
2 2
3 2
0 0
0 2
2 1
3 1
2 2
4 0
4 1
4 2
1 1
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
1
0
0
0
0
0
0
1
2
4
3
2
3
0
0
0
0
0
0
0
0
0
0
0
3
4
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #5:

score: 6
Accepted
time: 3ms
memory: 54084kb

input:

6
0 0 0 0 0 2
2 4
4 5
0 4
2 3
1 5
100
5 1
3 1
4 1
0 2
2 2
2 0
5 2
4 0
2 2
1 2
4 2
0 1
3 0
4 0
0 2
3 1
4 1
4 0
4 1
0 0
3 2
2 1
2 2
3 1
3 0
1 0
4 2
0 1
5 0
3 1
2 0
2 1
0 2
5 2
1 2
5 1
1 0
2 0
3 0
4 0
1 2
3 2
2 1
5 0
0 1
4 2
4 1
0 0
2 0
3 0
3 2
3 0
5 2
3 2
0 1
0 0
5 0
1 1
4 2
5 1
3 1
2 2
0 2
2 1
1 0
1 ...

output:

0
0
0
0
3
4
3
3
0
0
0
0
0
0
0
0
0
0
0
0
3
4
4
4
3
5
4
0
0
0
0
0
0
0
0
0
0
2
2
2
1
3
2
2
2
2
1
2
5
4
3
4
3
6
5
2
5
4
2
0
0
0
0
0
0
2
0
1
2
2
1
2
4
2
1
2
4
2
1
2
2
3
5
2
4
0
2
2
0
0
0
1
2
1
0
0
0
0
0
3
2

result:

ok 

Test #6:

score: 6
Accepted
time: 0ms
memory: 52372kb

input:

400
1 1 1 0 0 0 1 1 2 1 1 1 1 1 1 0 2 2 1 0 1 0 2 0 1 2 2 1 1 2 2 1 2 0 2 0 2 0 0 0 0 2 1 2 1 0 2 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 1 1 1 2 1 2 0 0 2 1 1 1 2 2 0 0 0 2 2 1 1 1 2 1 1 0 1 0 0 2 1 2 1 2 0 0 2 0 2 1 2 1 1 0 2 2 2 1 1 0 2 0 0 0 1 2 2 1 2 1 0 2 0 0 1 0 0 0 1 2 0 2 1 0 0 0 0 1 1 2 1 1 0 1 0 ...

output:

89736
92089
97184
97881
97958
97957
98575
98780
98194
98636
98571
98118
98137
96880
97697
97751
97126
95885
95846
95881
95780
96554
97541
97088
97147
97124
97229
97271
97761
98723
98751
99213
99575
99558
99541
100018
99689
100639
100160
101057
98928
99588
98995
99010
98196
103072
103702
103678
10365...

result:

ok 

Test #7:

score: 6
Accepted
time: 0ms
memory: 51484kb

input:

400
1 1 0 2 2 0 2 1 1 1 1 0 1 2 2 2 2 0 0 2 0 2 0 2 1 1 2 2 1 2 1 0 1 2 2 2 0 0 0 2 1 2 2 0 0 0 1 2 1 1 0 1 1 2 1 2 2 2 1 1 0 1 1 1 2 2 1 1 0 0 1 1 0 0 1 1 1 2 2 2 1 1 2 1 1 1 0 2 0 2 1 0 1 1 2 0 0 2 1 0 2 2 1 0 0 0 0 1 1 1 0 1 2 1 1 1 2 0 2 2 0 2 0 1 0 1 1 1 1 0 1 1 0 0 0 2 2 0 2 2 2 1 1 0 1 2 0 1 ...

output:

17280
17415
17280
17408
17272
17145
17272
17136
17000
16988
17112
16988
16851
16974
17097
17080
17202
17324
17202
17324
17466
17324
17182
17061
16940
16920
16800
16660
16541
16520
16380
16356
16497
16638
16779
16660
16520
16497
16356
16497
16638
16520
16541
16560
16577
16714
16592
16605
16728
16740
...

result:

ok 

Subtask #2:

score: 8
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 8
Accepted
time: 34ms
memory: 59088kb

input:

4000
2 0 2 1 2 1 0 2 0 2 2 1 0 2 2 2 2 1 1 2 2 1 1 0 2 0 0 2 1 0 0 1 1 1 0 2 0 2 2 1 0 2 2 1 0 2 2 1 2 2 0 2 0 1 1 2 2 0 2 0 0 1 0 0 0 1 2 1 0 2 2 1 0 0 0 0 1 2 0 0 1 2 1 0 0 1 2 2 1 2 0 2 0 2 1 2 1 0 0 1 1 2 2 2 1 2 2 0 2 0 1 2 0 1 2 1 2 2 1 1 1 2 0 0 0 0 1 2 2 2 0 1 1 2 2 2 0 1 0 0 2 1 1 0 2 0 1 0...

output:

620474975
620091276
620213053
620215716
620182492
619967950
620433875
620378867
619791163
620294584
620042350
620254670
619599499
619635328
619632073
619845490
620198042
620214770
620452856
620637250
620099913
620537344
620561024
620602104
620531392
620536225
620559149
621081398
621137321
621348648
...

result:

ok 

Test #9:

score: 8
Accepted
time: 22ms
memory: 52872kb

input:

4000
0 1 1 2 1 2 1 2 2 2 0 0 2 1 2 1 1 0 0 2 0 0 2 0 2 1 2 1 0 2 2 1 2 0 2 1 0 1 2 1 1 0 0 0 0 1 2 0 1 2 0 1 2 2 1 2 1 2 1 1 0 0 0 0 1 0 0 0 2 2 1 2 2 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 0 0 0 2 0 0 0 2 1 1 2 0 0 0 0 0 0 0 2 0 1 1 1 2 2 2 1 2 0 1 0 2 0 0 1 2 0 2 1 0 0 1 0 2 2 0 0 0 1 0 1 0 0 2 2 1 2 0 0 0...

output:

42768942
42797072
42797223
42840318
42832995
42797246
42797380
42817147
42816920
42815937
42778805
42753526
42752585
42787135
42764416
42796136
42796797
42766303
42765309
42764279
42740223
42739766
42767580
43539681
43587532
43564273
43590474
43562674
43561503
43524119
43524798
43524001
43525085
435...

result:

ok 

Test #10:

score: 8
Accepted
time: 8ms
memory: 55800kb

input:

4000
2 0 2 1 2 1 0 2 0 2 2 1 0 2 2 2 2 1 1 2 2 1 1 0 2 0 0 2 1 0 0 1 1 1 0 2 0 2 2 1 0 2 2 1 0 2 2 1 2 2 0 2 0 1 1 2 2 0 2 0 0 1 0 0 0 1 2 1 0 2 2 1 0 0 0 0 1 2 0 0 1 2 1 0 0 1 2 2 1 2 0 2 0 2 1 2 1 0 0 1 1 2 2 2 1 2 2 0 2 0 1 2 0 1 2 1 2 2 1 1 1 2 0 0 0 0 1 2 2 2 0 1 1 2 2 2 0 1 0 0 2 1 1 0 2 0 1 0...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 

Subtask #3:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 2279ms
memory: 781104kb

input:

200000
0 2 2 0 2 2 0 1 1 0 2 2 0 1 2 2 0 1 0 2 1 1 0 1 0 2 0 2 0 0 0 1 0 0 2 0 2 1 0 0 1 1 1 0 0 2 1 2 2 1 0 2 2 2 0 2 2 1 2 0 1 0 0 1 2 0 0 2 1 1 1 0 1 1 1 2 1 0 1 1 0 1 2 2 2 0 1 0 1 1 0 2 0 1 0 2 0 0 2 2 2 2 2 0 0 2 1 2 2 1 2 0 1 1 1 1 1 0 2 0 2 0 1 1 1 0 1 0 2 1 2 0 1 1 0 2 1 2 2 2 0 0 2 2 2 0 1...

output:

77241161705660

result:

ok 

Test #12:

score: 6
Accepted
time: 2261ms
memory: 770244kb

input:

200000
2 1 2 0 2 1 2 1 2 1 1 1 2 1 2 1 2 1 1 1 1 2 0 1 2 1 1 2 1 2 2 2 1 2 2 2 1 2 2 1 1 1 2 2 1 1 2 2 1 2 1 1 2 2 1 2 2 2 1 2 2 2 1 2 1 1 2 2 2 1 1 2 2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 1 2 2 2 2 1 1 1 2 1 1 2 1 1 2 1 2 2 2 2 1 1 2 1 2 2 1 1 1 2 1 1 1 2 0 2 1 2 2 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 2 1 1 1 1 2...

output:

14535453821146

result:

ok 

Test #13:

score: 6
Accepted
time: 2125ms
memory: 777616kb

input:

200000
2 2 0 2 2 0 0 0 0 0 2 2 2 2 0 2 2 2 2 1 0 2 0 2 2 0 0 2 2 0 0 2 2 1 0 2 0 2 0 0 2 1 0 0 0 2 0 0 0 2 2 0 2 0 2 2 0 0 0 0 2 0 0 2 0 2 0 2 0 2 2 2 2 2 0 2 2 2 2 0 0 0 0 0 2 0 2 2 0 2 0 0 2 0 0 2 2 2 0 2 0 2 2 0 2 2 2 0 0 2 0 1 0 2 0 2 2 0 2 2 2 0 2 2 0 2 0 2 0 2 0 0 0 0 2 0 0 2 0 0 0 2 0 0 0 2 0...

output:

15024455356747

result:

ok 

Test #14:

score: 6
Accepted
time: 2322ms
memory: 768380kb

input:

200000
1 0 0 1 2 0 0 0 1 1 0 1 1 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 1 1 1 0 0 1 1 1 2 0 0 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 0 1 2 1 0 1 1 1 1 0 1 2 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 0 1 0 1 0 1 0 1 2 1 0 0 1...

output:

14979709993295

result:

ok 

Test #15:

score: 6
Accepted
time: 1510ms
memory: 693036kb

input:

200000
0 1 2 1 2 1 0 1 0 0 2 0 0 1 0 0 2 0 0 0 2 1 0 1 0 0 2 2 2 1 0 2 1 1 2 1 2 1 2 0 2 1 0 2 0 2 2 2 2 0 2 1 2 1 1 1 0 1 2 2 1 1 0 0 0 1 1 1 0 0 1 1 1 2 0 2 2 0 2 2 2 2 0 2 2 0 1 0 1 0 1 0 2 1 1 2 0 0 2 1 1 0 0 2 2 1 2 2 2 1 1 0 1 2 0 0 1 1 1 1 1 1 0 0 2 1 1 0 0 0 0 0 2 1 1 2 2 1 1 0 2 0 1 1 1 2 2...

output:

457084700208

result:

ok 

Test #16:

score: 6
Accepted
time: 1487ms
memory: 692504kb

input:

200000
0 0 1 0 1 1 1 1 0 2 2 1 2 1 2 0 0 0 2 0 0 1 0 1 1 0 1 0 2 0 0 1 1 1 1 2 1 1 1 0 2 0 0 2 2 2 0 2 1 0 0 2 0 0 2 1 0 2 1 2 0 2 2 1 0 1 0 0 2 1 2 2 2 0 1 2 2 2 2 0 1 0 2 2 1 0 0 1 2 1 0 2 1 2 0 0 2 0 2 2 2 2 1 0 0 2 0 2 0 2 2 2 1 1 1 1 1 0 1 1 0 0 2 2 1 0 2 0 2 1 2 2 2 2 2 0 0 1 0 1 0 1 2 1 0 0 2...

output:

490004211265

result:

ok 

Test #17:

score: 6
Accepted
time: 2058ms
memory: 701580kb

input:

200000
1 1 1 1 0 2 1 0 1 0 2 0 2 0 2 2 2 0 2 1 1 2 0 0 0 0 0 2 2 2 0 2 1 2 0 1 0 2 2 1 2 1 0 0 2 1 0 2 1 1 0 1 2 2 0 0 2 0 2 2 1 2 1 2 0 0 1 1 0 1 2 1 2 0 2 2 0 2 0 2 1 0 2 2 2 0 1 0 0 0 2 2 2 2 0 0 0 0 1 2 2 1 1 2 2 1 2 1 2 0 0 1 2 1 0 1 0 0 0 2 1 1 1 0 0 1 2 1 1 1 0 1 1 0 2 1 1 0 1 1 2 2 1 2 1 1 0...

output:

149609988117

result:

ok 

Test #18:

score: 6
Accepted
time: 2001ms
memory: 697240kb

input:

200000
0 1 2 1 2 2 2 2 0 1 1 2 0 0 0 0 1 1 0 2 0 2 1 1 1 2 2 0 2 2 0 1 1 1 2 0 0 1 2 1 2 1 0 1 2 1 1 2 0 1 1 0 0 1 0 1 0 1 0 0 1 2 2 2 2 1 2 0 0 2 1 2 1 2 1 0 2 2 0 2 1 1 1 1 2 2 1 0 2 2 2 2 1 0 2 2 0 0 1 0 1 2 1 1 2 0 2 1 1 2 2 2 1 0 2 2 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 0 1 1 2 0 0 2 1 1 0 2 2 1 1 0 1...

output:

490004211265

result:

ok 

Test #19:

score: 6
Accepted
time: 1876ms
memory: 661320kb

input:

200000
2 1 1 1 2 0 0 1 2 0 1 1 1 2 0 0 2 1 2 0 0 0 2 1 0 1 1 1 2 2 2 2 2 1 0 2 2 2 1 2 0 1 2 0 0 2 2 0 0 0 0 1 2 0 1 0 0 1 1 2 2 0 0 1 2 2 1 0 1 2 2 2 0 0 0 1 2 1 1 2 2 1 2 1 0 0 0 2 1 1 2 2 2 1 0 1 2 2 1 1 1 1 2 1 1 2 2 1 2 1 2 1 0 2 2 2 2 0 0 1 2 2 2 0 1 0 2 2 0 0 0 2 2 0 2 0 0 1 0 0 2 0 1 0 1 1 2...

output:

1812572240374

result:

ok 

Test #20:

score: 6
Accepted
time: 1844ms
memory: 629428kb

input:

200000
1 0 0 2 0 2 0 0 2 1 2 1 0 0 0 1 1 2 1 2 0 2 0 0 2 0 2 0 2 1 1 1 2 2 0 0 2 2 2 1 1 2 2 0 2 0 0 0 0 0 1 1 0 0 0 1 2 0 1 2 1 2 0 1 2 0 0 0 2 2 2 1 2 2 0 1 2 1 1 0 0 1 1 2 0 1 0 0 2 0 2 2 0 2 2 2 0 1 0 1 0 0 2 0 1 2 1 1 1 0 1 1 1 0 0 2 2 1 0 2 0 1 2 2 1 1 1 1 1 1 0 0 1 0 2 1 2 0 0 1 2 0 2 2 2 0 0...

output:

7322589985203

result:

ok 

Test #21:

score: 6
Accepted
time: 2242ms
memory: 708416kb

input:

200000
2 2 2 1 1 0 1 0 0 1 1 0 0 1 0 0 0 2 0 0 2 0 0 1 1 2 1 0 2 1 1 1 2 2 1 0 0 2 2 0 0 1 2 0 0 1 2 2 0 1 1 1 1 1 0 2 2 2 1 0 2 1 0 1 0 2 1 0 0 0 1 0 2 1 2 0 0 0 0 2 2 2 2 0 0 1 0 1 1 0 1 2 2 2 2 2 2 2 1 0 0 2 1 0 2 0 2 2 0 0 2 1 2 0 2 2 0 2 0 0 1 0 2 1 1 2 2 1 1 2 1 2 0 0 2 2 0 0 0 2 0 0 1 2 1 0 1...

output:

33075374608087

result:

ok 

Test #22:

score: 6
Accepted
time: 2245ms
memory: 700080kb

input:

200000
2 1 1 2 2 2 2 1 2 1 2 0 1 2 1 1 2 2 1 2 2 2 2 2 1 2 1 1 1 1 2 1 2 1 1 2 2 1 2 1 2 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 0 1 1 2 1 1 2 2 1 1 1 1 1 1 2 2 0 1 1 2 1 2 1 2 2 2 1 1 2 1 0 1 2 2 2 1 2 1 1 1 1 0 1 1 2 1 0 2 2 1 1 2 2 2 0 1 2 1 2 2 2 1 1 2 1 2 2 2 1 2 2 2 1 1 1 2 2 1 2 2 2 2 2 2 1 2 2 1 1 1...

output:

6216545751865

result:

ok 

Test #23:

score: 6
Accepted
time: 2337ms
memory: 715924kb

input:

200000
2 0 2 0 0 2 0 2 0 2 2 2 0 2 2 2 0 2 2 0 2 2 2 2 0 2 0 0 0 2 2 2 2 0 2 2 0 0 0 2 2 0 0 0 2 0 2 0 0 2 2 0 2 2 0 0 0 2 2 0 0 2 0 0 0 0 2 2 0 2 0 0 2 2 2 0 0 0 0 0 0 0 2 2 2 2 2 1 0 0 2 1 2 0 2 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 0 2 2 2 2 0 2 0 0 0 2 2 0 2 2 0 0 0 2 2 0 0 2 2 2 2 2 2...

output:

6090130973914

result:

ok 

Test #24:

score: 6
Accepted
time: 2290ms
memory: 703300kb

input:

200000
1 1 0 0 1 2 0 2 0 0 0 1 0 0 0 1 1 0 1 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 0 1 0 2 0 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 2 0 1 2 1 0 0 0 2 0 0 0 2 0 0 1 1 1 2 1 1 1 0 1 0 1 1 2 1...

output:

6392103279027

result:

ok 

Test #25:

score: 6
Accepted
time: 2315ms
memory: 802220kb

input:

200000
0 0 0 2 1 1 1 0 0 1 1 2 0 2 1 2 2 0 0 2 0 2 2 1 0 2 1 2 2 2 2 0 1 1 1 1 1 1 1 1 1 2 2 1 0 2 0 1 0 1 2 0 0 2 0 2 0 0 1 0 2 2 0 0 1 0 2 1 1 0 1 0 2 0 2 0 1 2 2 1 1 0 1 2 0 1 2 1 2 0 0 0 1 0 1 2 2 0 1 1 0 0 0 1 1 2 0 0 2 2 0 0 2 2 2 2 1 0 0 1 1 1 2 2 2 2 0 0 0 1 1 1 0 1 1 2 1 1 1 0 0 2 1 0 2 0 1...

output:

98889219873489

result:

ok 

Test #26:

score: 6
Accepted
time: 0ms
memory: 35024kb

input:

3
0 0 1
1 2
0 2
0

output:

0

result:

ok 

Test #27:

score: 6
Accepted
time: 0ms
memory: 36852kb

input:

4
0 0 1 1
0 2
1 2
2 3
0

output:

0

result:

ok 

Test #28:

score: 6
Accepted
time: 3ms
memory: 54292kb

input:

5
2 0 2 2 0
0 2
0 1
0 3
2 4
0

output:

0

result:

ok 

Test #29:

score: 6
Accepted
time: 0ms
memory: 51016kb

input:

6
1 0 2 2 0 1
1 3
4 5
0 4
0 1
2 5
0

output:

4

result:

ok 

Test #30:

score: 6
Accepted
time: 1696ms
memory: 605032kb

input:

200000
0 0 0 2 0 0 1 0 2 2 2 1 2 0 1 0 0 0 0 1 0 2 0 2 1 0 2 2 2 2 2 0 0 2 2 0 1 1 0 1 1 0 1 2 2 2 0 1 2 1 2 2 1 0 2 2 2 1 2 2 2 0 1 2 2 2 2 2 1 1 0 0 1 0 2 0 2 1 1 2 2 0 2 1 2 0 2 2 1 2 2 2 0 2 2 2 0 2 0 1 1 1 2 0 1 2 2 1 2 0 2 0 0 2 1 1 2 2 0 2 0 2 0 1 0 0 0 0 2 0 1 2 0 1 2 2 2 0 1 0 0 2 2 2 1 0 0...

output:

827878641518

result:

ok 

Test #31:

score: 6
Accepted
time: 1719ms
memory: 587960kb

input:

200000
1 1 2 2 1 1 2 2 2 2 2 1 2 2 2 2 2 1 2 1 2 2 1 2 1 2 2 2 2 2 1 2 1 1 1 2 2 2 1 0 1 2 2 2 2 1 2 2 1 2 1 1 2 2 1 2 1 2 1 1 2 1 2 2 2 1 2 1 1 1 2 2 2 1 1 2 1 2 1 1 2 1 1 1 0 2 1 1 1 2 1 2 2 2 1 2 1 1 1 2 1 1 2 2 1 2 1 2 1 1 1 2 0 2 1 1 2 2 2 1 2 2 2 2 2 1 2 1 1 2 2 1 1 1 2 1 2 1 2 2 1 1 1 1 1 1 1...

output:

148910253102

result:

ok 

Test #32:

score: 6
Accepted
time: 1813ms
memory: 604140kb

input:

200000
2 0 2 2 0 2 0 0 0 2 2 0 2 0 0 0 0 2 0 2 0 0 0 2 0 0 0 0 2 0 0 2 0 2 1 0 0 0 2 2 0 2 2 0 0 2 2 0 1 2 2 2 1 0 0 2 0 2 2 0 2 2 0 0 2 2 0 2 0 2 2 0 2 2 0 2 2 0 2 0 0 0 0 2 2 2 0 0 0 2 2 2 2 0 0 0 2 2 0 2 0 2 1 2 2 0 0 2 2 0 2 0 1 2 2 0 2 0 0 2 2 0 0 0 1 0 0 0 0 0 2 0 0 2 0 0 0 0 2 2 0 2 2 0 2 2 2...

output:

181252557212

result:

ok 

Test #33:

score: 6
Accepted
time: 1758ms
memory: 596132kb

input:

200000
1 0 2 1 2 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 2 0 0 1 0 0 1 0 1 0 0 0 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 2 1 1 0 0 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1 1 0 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0...

output:

155843324547

result:

ok 

Test #34:

score: 6
Accepted
time: 293ms
memory: 223820kb

input:

200000
0 2 2 0 2 2 0 1 1 0 2 2 0 1 2 2 0 1 0 2 1 1 0 1 0 2 0 2 0 0 0 1 0 0 2 0 2 1 0 0 1 1 1 0 0 2 1 2 2 1 0 2 2 2 0 2 2 1 2 0 1 0 0 1 2 0 0 2 1 1 1 0 1 1 1 2 1 0 1 1 0 1 2 2 2 0 1 0 1 1 0 2 0 1 0 2 0 0 2 2 2 2 2 0 0 2 1 2 2 1 2 0 1 1 1 1 1 0 2 0 2 0 1 1 1 0 1 0 2 1 2 0 1 1 0 2 1 2 2 2 0 0 2 2 2 0 1...

output:

0

result:

ok 

Test #35:

score: 6
Accepted
time: 263ms
memory: 221488kb

input:

200000
2 1 2 0 2 1 2 1 2 1 1 1 2 1 2 1 2 1 1 1 1 2 0 1 2 1 1 2 1 2 2 2 1 2 2 2 1 2 2 1 1 1 2 2 1 1 2 2 1 2 1 1 2 2 1 2 2 2 1 2 2 2 1 2 1 1 2 2 2 1 1 2 2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 1 2 2 2 2 1 1 1 2 1 1 2 1 1 2 1 2 2 2 2 1 1 2 1 2 2 1 1 1 2 1 1 1 2 0 2 1 2 2 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 2 1 1 1 1 2...

output:

0

result:

ok 

Test #36:

score: 6
Accepted
time: 302ms
memory: 223424kb

input:

200000
2 2 0 2 2 0 0 0 0 0 2 2 2 2 0 2 2 2 2 1 0 2 0 2 2 0 0 2 2 0 0 2 2 1 0 2 0 2 0 0 2 1 0 0 0 2 0 0 0 2 2 0 2 0 2 2 0 0 0 0 2 0 0 2 0 2 0 2 0 2 2 2 2 2 0 2 2 2 2 0 0 0 0 0 2 0 2 2 0 2 0 0 2 0 0 2 2 2 0 2 0 2 2 0 2 2 2 0 0 2 0 1 0 2 0 2 2 0 2 2 2 0 2 2 0 2 0 2 0 2 0 0 0 0 2 0 0 2 0 0 0 2 0 0 0 2 0...

output:

0

result:

ok 

Test #37:

score: 6
Accepted
time: 295ms
memory: 220280kb

input:

200000
1 0 0 1 2 0 0 0 1 1 0 1 1 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 1 1 1 0 0 1 1 1 2 0 0 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 0 1 2 1 0 1 1 1 1 0 1 2 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 0 1 0 1 0 1 0 1 2 1 0 0 1...

output:

598441952

result:

ok 

Subtask #4:

score: 16
Accepted

Test #38:

score: 16
Accepted
time: 3ms
memory: 49044kb

input:

3
1 1 1
0 1
1 2
100
2 0
0 0
0 2
2 1
0 1
0 0
0 1
0 0
1 0
2 2
0 1
0 0
0 1
1 1
0 0
2 0
2 1
2 2
0 2
2 1
2 2
2 0
0 1
2 1
0 2
0 1
2 0
2 1
0 0
2 0
2 1
2 2
0 2
2 0
0 0
2 1
2 0
2 2
1 2
0 1
1 1
2 1
0 0
0 2
0 1
0 0
1 2
1 0
1 2
1 0
0 1
2 2
2 1
2 2
0 2
1 2
2 1
0 0
0 2
0 1
1 1
2 0
0 0
1 2
0 2
0 0
1 0
0 1
0 2
2 1
...

output:

0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0

result:

ok 

Test #39:

score: 16
Accepted
time: 3ms
memory: 53396kb

input:

4
2 2 2 0
0 1
1 2
2 3
100
0 0
3 2
1 1
3 1
0 2
2 0
1 0
3 0
0 1
1 2
0 0
3 2
3 1
1 0
3 2
3 0
3 1
1 2
3 2
0 1
2 2
2 1
1 0
1 1
1 0
3 0
0 2
1 2
0 0
3 1
1 0
2 0
3 0
2 2
3 2
0 2
0 1
3 1
2 1
3 0
1 2
2 2
3 2
2 1
1 1
3 1
1 2
2 0
0 2
1 1
0 1
3 0
2 2
0 2
0 0
1 0
3 1
2 1
0 2
2 2
0 0
0 1
3 0
2 1
1 2
3 1
3 2
1 1
2 ...

output:

0
0
0
2
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
2
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #40:

score: 16
Accepted
time: 4ms
memory: 50244kb

input:

5
0 1 0 2 1
0 1
1 2
2 3
3 4
100
1 0
4 2
3 1
2 2
2 0
4 1
1 2
3 0
3 2
3 1
1 0
1 2
2 2
4 2
1 1
4 0
2 0
0 2
2 1
0 1
3 2
1 0
4 1
3 0
4 0
3 2
2 0
0 0
2 1
0 2
0 1
4 1
3 0
0 2
4 2
2 0
2 1
4 0
1 2
4 1
1 0
3 2
0 0
2 0
2 2
4 2
3 1
3 0
0 2
1 2
0 0
2 1
3 2
2 0
2 2
0 1
2 0
3 1
0 0
4 0
2 2
1 0
2 1
3 2
4 2
1 1
4 1
...

output:

1
0
0
3
2
3
0
0
0
0
0
0
0
0
1
3
2
0
3
3
0
0
1
1
0
0
1
0
0
2
2
1
1
0
1
2
0
2
2
4
2
1
1
2
0
0
0
2
0
0
0
0
2
2
0
0
0
0
1
2
1
2
1
0
2
4
4
2
1
2
4
2
0
2
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
2
1
0
1
0
0
0
3
0
0
2

result:

ok 

Test #41:

score: 16
Accepted
time: 0ms
memory: 52508kb

input:

6
0 1 2 0 1 2
0 1
1 2
2 3
3 4
4 5
100
2 1
5 1
5 2
1 2
2 2
3 2
2 1
0 2
3 1
3 0
0 1
0 0
3 2
5 1
4 2
1 0
0 1
5 0
1 2
5 1
5 2
4 0
0 0
0 2
2 2
0 0
1 0
2 0
0 1
1 2
2 2
2 0
2 1
1 1
4 1
3 0
1 0
3 1
0 0
5 0
1 1
2 0
2 1
2 0
4 2
3 0
1 2
4 0
2 1
3 1
3 2
2 2
3 0
4 1
5 1
5 0
4 2
3 2
2 1
4 0
5 1
2 0
1 1
1 0
4 1
3 ...

output:

4
4
0
4
4
2
1
3
0
0
3
2
4
3
1
2
4
2
2
1
0
0
1
3
2
0
0
0
0
0
0
0
0
1
0
0
1
3
3
6
0
0
0
0
0
3
1
0
0
3
4
3
0
0
2
0
2
0
0
3
3
2
0
1
0
0
0
0
4
4
3
4
4
4
3
2
2
2
3
0
0
2
0
0
0
0
0
0
2
4
3
2
1
0
1
0
0
1
2
3
6

result:

ok 

Test #42:

score: 16
Accepted
time: 6ms
memory: 55268kb

input:

400
0 2 2 1 0 2 2 1 2 0 1 2 0 0 2 1 2 0 1 0 2 2 0 2 1 1 1 1 0 1 0 1 0 1 1 1 0 1 0 2 1 2 2 1 0 1 1 2 0 1 2 0 2 1 2 1 1 2 1 1 0 1 0 2 2 2 2 1 0 1 0 0 0 2 2 0 2 1 1 0 0 0 1 1 1 0 0 2 0 0 2 0 1 2 1 1 0 1 2 1 0 1 0 1 1 0 1 2 0 1 0 2 2 1 0 0 1 0 2 1 2 0 1 1 1 0 1 1 0 1 0 2 0 1 1 2 0 2 2 2 2 2 0 1 0 0 2 2 ...

output:

748492
751280
745592
746546
748685
749066
748286
746439
742602
741927
739801
738044
740003
732801
732137
732791
741037
740750
744502
744511
744015
746300
749460
745730
745106
751192
750538
754769
756253
757792
760457
756172
757024
761186
760814
761345
762058
764833
769148
767330
764502
764339
767930...

result:

ok 

Test #43:

score: 16
Accepted
time: 28ms
memory: 56052kb

input:

4000
1 1 1 2 0 2 2 1 1 2 0 1 0 1 2 0 1 1 1 1 1 0 0 0 2 2 1 2 2 0 1 2 0 0 2 0 1 0 2 1 2 0 0 0 0 2 0 2 2 1 0 2 2 2 2 1 0 2 1 0 1 1 2 1 0 0 0 2 1 1 0 1 0 1 2 2 2 1 0 1 2 0 2 2 1 2 1 0 1 1 0 1 0 0 2 0 2 2 1 0 1 2 0 2 1 1 0 2 1 2 2 0 0 0 1 2 0 2 1 2 0 0 2 1 1 2 1 1 0 2 1 0 2 0 1 1 0 0 0 0 2 0 2 1 2 0 0 2...

output:

791220194
791202818
791448703
790793734
790538710
790399232
790680228
790274544
789587326
789569532
789589951
789568904
789520169
789458372
789475557
788952064
788936826
788957112
788606079
788625706
788314564
788853784
788476658
788033878
787760817
787604725
787949498
787930696
787950912
787946164
...

result:

ok 

Test #44:

score: 16
Accepted
time: 1531ms
memory: 796484kb

input:

200000
1 2 0 2 1 2 1 1 0 1 1 1 0 1 2 0 2 1 2 1 1 0 0 0 0 2 2 2 0 0 1 1 1 2 1 0 0 2 2 0 2 1 0 2 0 0 1 1 2 2 0 2 0 0 1 1 2 2 0 2 1 1 1 1 0 2 0 1 1 0 2 0 0 2 1 0 2 2 2 0 0 2 0 2 0 2 2 1 2 1 1 2 0 1 0 0 2 0 2 2 1 0 0 2 1 0 2 0 2 1 0 2 1 0 2 0 0 0 0 0 2 0 0 2 2 1 0 2 0 2 1 2 1 2 2 2 0 2 0 0 0 0 2 1 0 0 1...

output:

98878415111108

result:

ok 

Test #45:

score: 16
Accepted
time: 1586ms
memory: 797816kb

input:

200000
1 2 2 1 2 2 2 2 1 2 1 1 2 2 1 2 1 1 2 2 1 2 1 2 2 2 1 2 1 1 2 2 1 1 2 1 1 1 1 2 2 2 2 1 2 2 1 2 2 1 2 2 2 2 1 1 2 2 1 2 1 2 2 1 1 2 2 1 1 1 2 1 2 2 1 2 2 1 2 2 2 2 2 2 1 0 1 1 1 2 2 1 0 2 1 2 2 2 1 1 1 2 1 2 2 2 2 2 2 2 1 2 2 1 1 1 1 0 1 1 1 2 1 2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 1 1 1 1 1 2 2 2...

output:

18725807625786

result:

ok 

Test #46:

score: 16
Accepted
time: 1495ms
memory: 805788kb

input:

200000
0 2 2 2 0 2 0 2 0 2 0 0 0 0 2 0 2 2 0 2 0 0 2 2 2 2 2 2 0 2 2 0 0 0 0 0 0 0 2 0 0 1 2 0 2 2 2 0 2 0 0 0 2 0 0 2 2 0 2 0 0 0 0 0 2 2 2 0 0 0 2 2 0 0 0 0 2 0 2 0 1 2 2 0 0 2 0 2 0 2 2 0 2 0 2 0 0 2 0 0 0 2 0 0 0 2 0 2 0 0 2 0 0 2 0 2 0 2 2 2 0 0 2 0 2 2 2 2 1 0 0 0 2 2 0 2 0 2 0 2 2 2 0 0 0 0 0...

output:

19001142419904

result:

ok 

Test #47:

score: 16
Accepted
time: 1586ms
memory: 798180kb

input:

200000
0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 1 0 0 0 1 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 1 0 1 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 0 1 1 1 0 1 0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 1 0 1 1 0 0 0 1 2 2 1 0 0 1 0 2 1 2 1 2...

output:

19038058071323

result:

ok 

Test #48:

score: 16
Accepted
time: 819ms
memory: 417252kb

input:

100000
0 2 1 1 0 2 0 0 2 2 2 2 0 0 1 1 0 2 2 2 0 2 1 2 1 0 2 0 0 2 0 1 0 1 2 0 0 2 2 1 0 2 2 1 0 2 1 0 2 1 2 0 2 0 1 2 1 0 2 0 1 0 1 0 0 0 0 2 1 2 0 1 1 0 1 0 0 2 2 0 2 1 0 2 2 1 2 0 1 0 2 1 2 0 2 0 0 0 0 2 1 1 0 1 1 2 2 1 2 0 1 1 1 1 0 0 2 2 2 2 2 2 0 2 2 1 0 1 0 0 1 0 0 1 1 2 1 1 2 1 1 0 1 1 2 0 0...

output:

12305851592762
12305852134900
12306133507778
12305866995960
12305585087263
12305866995960
12305585642746
12305866995960
12305585642746
12305866995960
12305585642746
12305583154618
12305582570257
12305583154618
12305864493268
12305582570257
12305583154618
12305864493268
12305863525808
12305581608077
...

result:

ok 

Test #49:

score: 16
Accepted
time: 786ms
memory: 405932kb

input:

100000
1 2 0 2 2 1 2 0 2 1 1 0 0 1 1 2 2 1 2 1 1 1 0 0 0 2 1 2 1 2 1 1 0 0 1 2 1 0 1 1 1 0 0 2 2 2 0 1 2 2 1 0 1 0 1 2 0 0 0 2 0 1 0 2 0 2 2 0 0 0 1 2 1 1 1 0 1 2 2 1 2 0 1 0 0 2 0 0 2 2 1 2 1 1 2 2 2 2 2 0 2 2 0 0 0 0 2 0 2 2 1 0 1 2 1 1 0 2 2 1 0 1 2 1 1 2 2 2 0 1 2 2 1 2 1 2 2 0 0 1 1 1 0 2 2 1 2...

output:

12301813256756
12302373157130
12301813256756
12302373157130
12302924262596
12302925522835
12302374383909
12302373157130
12301813256756
12302373157130
12302374383909
12301813256756
12302367485243
12302364362222
12302924262596
12302364362222
12302367485243
12301813256756
12302364362222
12302925522835
...

result:

ok 

Test #50:

score: 16
Accepted
time: 1144ms
memory: 391264kb

input:

100000
2 2 2 2 1 0 2 1 2 1 1 2 0 1 1 2 1 1 0 2 1 0 1 1 1 1 1 1 0 0 0 0 1 2 1 2 0 1 0 2 0 2 0 1 0 1 2 1 0 1 1 1 2 0 1 0 0 2 0 0 1 2 1 0 1 2 1 1 2 2 2 1 1 0 1 2 1 0 0 0 0 0 0 0 0 2 1 1 2 0 0 0 0 0 1 1 1 2 0 2 1 2 1 1 1 0 2 1 0 1 0 0 2 2 2 2 2 2 1 0 2 2 0 2 2 0 0 1 2 2 0 2 1 2 1 1 2 1 2 1 1 2 2 1 2 1 0...

output:

12418513167989
12418318171086
12418165193041
12418160409001
12418126763330
12418040055626
12418267377528
12418272506223
12417820448436
12417972199669
12417773522932
12417576059620
12417757013704
12417825430253
12418053743032
12418508820771
12418503688442
12418439828326
12418689699116
12418838558201
...

result:

ok 

Test #51:

score: 16
Accepted
time: 1079ms
memory: 389328kb

input:

100000
2 1 2 1 2 2 1 1 1 1 2 1 2 1 1 2 2 1 2 1 2 2 1 1 2 2 2 2 2 1 2 2 2 1 1 2 1 2 2 2 2 1 1 2 2 1 2 1 2 1 2 1 2 1 1 1 1 2 2 2 2 2 1 2 1 2 2 1 2 1 2 2 1 1 1 1 0 2 1 2 1 2 2 1 1 2 2 2 1 1 0 1 2 1 1 1 1 2 1 1 1 1 2 2 1 1 1 2 0 1 2 2 2 1 2 1 2 1 1 1 1 1 2 1 1 1 0 1 1 1 1 1 1 2 2 2 2 2 1 1 2 2 1 2 1 2 1...

output:

2346723587578
2346797006215
2346772375460
2346809727919
2347690734887
2347721226196
2347677034956
2347711403087
2347703419765
2347769503612
2347741902138
2348263987234
2348275750601
2348310490766
2348282698683
2348245269554
2348276304355
2348288123222
2348310435745
2348929711544
2348877359493
234885...

result:

ok 

Test #52:

score: 16
Accepted
time: 1052ms
memory: 418024kb

input:

100000
2 0 2 2 2 2 2 2 2 2 0 0 2 0 2 0 2 2 0 2 0 0 0 0 0 1 2 0 1 0 2 2 0 2 0 2 0 2 2 0 0 0 2 0 2 2 2 0 2 0 0 2 2 0 0 2 2 2 2 0 0 0 0 0 2 0 0 2 0 2 0 0 2 2 0 2 2 0 2 0 0 0 2 0 2 2 0 2 0 2 1 2 0 0 0 0 0 0 0 1 2 0 0 0 0 2 0 0 0 2 2 0 0 0 0 0 0 0 2 2 2 2 2 0 2 0 2 0 2 0 1 2 2 2 0 0 2 0 2 2 0 2 2 0 2 2 2...

output:

2400462386571
2400462158148
2400461544795
2400461889958
2400461185189
2400461548434
2400461920357
2400461234560
2400460695567
2400460511380
2400459879735
2400460424304
2400460567413
2400460041056
2400459736037
2400459512574
2400459660195
2400459345806
2400575350120
2400575946924
2400575378804
240057...

result:

ok 

Test #53:

score: 16
Accepted
time: 1075ms
memory: 410496kb

input:

100000
0 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 0 2 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 1 1 0 0 0 1 0 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 0 0 1 0 1 0...

output:

2323745275743
2323777633776
2323806469161
2323833154157
2323840493310
2323808770580
2324765240403
2324758452482
2323776601856
2323753628594
2323785579860
2323750302594
2323802364215
2323774143294
2323758276966
2323764116183
2323699833384
2324252351662
2324767071839
2324755050915
2324753777905
232472...

result:

ok 

Test #54:

score: 16
Accepted
time: 1962ms
memory: 797676kb

input:

200000
1 1 0 2 1 2 1 2 2 0 1 0 2 1 1 1 2 2 2 1 0 2 2 1 2 1 0 0 1 2 1 0 1 1 2 2 0 1 1 0 1 2 2 1 2 2 0 1 2 0 2 0 2 1 0 0 1 2 2 1 1 0 1 2 0 1 1 2 1 0 2 1 0 2 2 2 0 1 0 2 2 0 0 0 2 1 2 1 0 0 1 2 1 1 0 0 1 2 0 2 1 2 1 0 2 1 2 2 1 0 0 1 0 2 2 2 1 0 1 1 0 2 2 1 1 0 2 2 2 0 0 0 1 0 2 0 1 2 1 1 1 0 0 0 2 1 0...

output:

98436910774628
98435790492478
98436353021634
98437473264408
98435641752233
98434521544912
98435641752233
98435650540959
98434527058080
98432660574726
98432663853112
98432964316426
98432961059499
98432964316426
98432961059499
98432964316426
98434084562142
98432964316426
98434084562142
98432873827394
...

result:

ok 

Test #55:

score: 16
Accepted
time: 1741ms
memory: 802096kb

input:

200000
0 1 2 1 1 2 2 2 2 1 2 1 2 0 0 2 1 1 2 0 2 2 1 2 0 1 2 2 2 2 2 1 2 0 2 2 1 1 0 2 1 2 1 0 2 0 2 1 0 2 2 1 1 1 2 2 2 0 0 1 0 2 1 0 0 0 2 1 0 1 0 0 2 1 2 2 1 2 0 2 2 2 2 2 0 1 2 0 1 1 2 2 0 2 2 1 1 0 2 0 2 1 1 0 1 2 0 2 1 1 1 0 0 1 2 2 0 2 0 1 0 0 2 0 2 1 0 1 0 2 1 2 0 2 0 0 0 1 1 1 1 1 1 1 0 2 1...

output:

98656322568720
98654089382763
98656300074379
98654089382763
98656300074379
98654089382763
98656322568720
98656332308779
98654099189422
98656309947638
98656300074379
98654084729795
98656309947638
98656300074379
98654089382763
98651874038179
98654099189422
98654089382763
98654099189422
98656332308779
...

result:

ok 

Test #56:

score: 16
Accepted
time: 2505ms
memory: 800508kb

input:

200000
0 1 0 2 1 0 2 1 2 0 1 2 2 0 1 2 0 0 1 0 0 2 0 0 1 1 0 0 1 0 2 0 0 1 0 2 2 1 2 0 2 2 0 2 2 1 0 0 0 2 1 1 1 2 1 2 0 2 2 1 2 1 2 0 1 2 0 1 1 0 0 0 1 1 2 2 2 1 2 0 1 0 1 0 0 2 2 1 1 2 1 2 0 2 1 0 2 2 1 1 2 1 1 0 0 0 1 2 0 0 1 1 0 2 2 0 0 0 1 2 1 2 0 2 1 2 2 0 1 2 1 2 1 1 1 0 1 0 2 0 1 1 0 0 0 1 1...

output:

98966103892595
98967140571022
98967143550915
98967142609596
98966185678400
98966421102932
98965911821926
98965913407716
98965918104910
98965913417511
98965122079850
98965524762266
98965522367911
98966328834972
98966123179251
98966127823396
98967012540625
98969031950525
98969028633876
98967004001828
...

result:

ok 

Test #57:

score: 16
Accepted
time: 2482ms
memory: 801528kb

input:

200000
0 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 0 1 2 1 1 2 2 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 2 0 1 1 2 1 2 1 2 2 1 1 1 2 1 2 2 2 1 1 1 2 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 1 1 1 1 1 2 2 1 2 2 2 1 2 2 2 2 0 2 2 2 2 1 2 1 1 1 2 1 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 2 2 2 1 2 1 2 2 2 1 2 2 2 1 1 1 2 2 1 1...

output:

18697396764912
18695300327400
18695417492428
18695412390750
18695497770485
18695645619754
18695621483891
18695621059672
18695547575010
18695796159440
18697905632033
18697974160176
18697990665232
18698059102482
18700429463664
18700271546880
18700128236136
18700269015812
18700479008398
18700459208097
...

result:

ok 

Test #58:

score: 16
Accepted
time: 2417ms
memory: 802360kb

input:

200000
2 2 0 2 2 2 2 2 0 2 2 2 0 2 2 2 0 0 1 2 0 2 0 2 0 0 2 0 0 2 0 0 0 2 0 2 0 2 0 2 2 2 2 0 0 1 0 0 0 0 0 0 0 2 0 0 0 2 0 2 0 0 0 0 0 0 1 0 1 0 2 0 2 2 0 2 2 0 2 2 0 2 0 2 2 0 0 0 0 2 2 2 2 0 2 0 2 2 0 2 0 0 2 2 2 2 0 2 2 2 2 0 0 0 0 0 0 2 0 2 0 0 2 0 2 2 2 0 2 2 0 2 0 2 2 2 0 0 0 2 2 2 0 2 0 0 0...

output:

19301561644377
19301561010923
19301560519357
19301560658860
19301560141868
19301560283528
19301560403681
19301560821780
19301561367932
19301560929964
19297228945278
19297228845345
19297228942726
19297228773359
19297229163546
19297229516549
19297229611392
19297228960187
19297229206178
19297229572763
...

result:

ok 

Test #59:

score: 16
Accepted
time: 2428ms
memory: 797296kb

input:

200000
1 0 1 0 0 2 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 1 1 1 1 0 1 0 0 0 0 1 1 0 1 1 0 2 2 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 1 0 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 0 1...

output:

18631796300984
18631687250817
18631856709119
18631764152424
18631788410608
18631743814247
18631869669973
18631874454986
18631609360317
18633884518788
18633849370968
18633712111542
18633473133941
18633515779302
18633579888709
18633651258564
18633894929986
18634024209976
18634169079793
18634278683400
...

result:

ok 

Subtask #5:

score: 16
Accepted

Test #60:

score: 16
Accepted
time: 3ms
memory: 53232kb

input:

3
2 0 0
0 1
0 2
100
0 1
2 2
2 1
1 1
0 0
2 2
1 2
0 2
0 1
0 0
0 1
0 2
2 1
1 0
2 2
2 0
0 0
0 2
1 1
1 2
2 2
2 1
0 0
2 2
0 1
1 0
0 0
2 0
1 1
1 0
2 1
2 0
0 2
0 1
2 2
1 1
0 0
0 1
2 1
0 0
2 0
0 1
2 1
2 0
0 2
2 2
0 1
2 0
0 0
0 1
2 1
0 2
0 1
0 2
2 2
1 0
1 1
1 2
1 0
1 2
1 0
0 0
1 1
0 1
1 0
2 0
1 2
1 0
0 2
0 0
...

output:

0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #61:

score: 16
Accepted
time: 0ms
memory: 45180kb

input:

4
1 0 1 0
0 1
0 2
1 3
100
0 2
3 2
1 1
0 1
3 1
3 2
3 1
2 2
1 2
2 1
1 0
2 2
3 2
3 1
1 1
3 2
2 0
3 1
0 2
1 2
2 1
2 2
0 1
1 0
3 0
3 2
3 1
3 0
0 0
2 0
1 1
1 2
0 1
1 0
2 2
2 1
1 1
3 2
0 0
2 2
0 1
3 1
1 0
2 1
2 0
1 2
0 2
3 0
3 1
0 1
0 2
3 2
3 1
1 1
1 0
2 2
0 0
0 1
0 0
0 1
0 0
2 0
0 1
3 2
0 2
3 0
2 2
2 1
3 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
2
0
0
0
0
0
0
1
2
1
1
2
0
0
0
0
1
0
2
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
2
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 

Test #62:

score: 16
Accepted
time: 3ms
memory: 50704kb

input:

5
1 0 0 1 1
0 1
0 2
1 3
1 4
100
0 0
0 2
1 1
3 0
3 2
1 0
2 1
0 0
1 2
4 0
0 2
1 0
2 0
1 1
1 0
1 2
3 0
1 0
0 1
0 0
4 1
4 2
3 1
2 1
4 0
3 2
3 1
2 0
2 1
2 0
0 2
2 1
0 0
2 2
1 1
0 2
3 2
4 2
1 2
2 1
0 0
2 0
1 0
0 1
2 2
3 0
3 2
2 0
0 2
1 2
3 1
2 1
4 1
2 2
0 0
0 2
1 0
2 1
4 0
1 2
1 0
1 2
2 0
2 1
0 0
4 1
1 0
...

output:

0
0
0
0
1
1
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
2
3
0
0
0
0
0
0
2
1
2
1
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
2
0
0
2
1
0
1
3
0
0
0
0
0
0
0
0
0
1
2
0

result:

ok 

Test #63:

score: 16
Accepted
time: 0ms
memory: 53116kb

input:

6
2 1 0 2 1 2
0 1
0 2
1 3
1 4
2 5
100
5 1
4 0
3 1
5 2
4 2
2 1
2 0
2 1
5 0
3 0
4 1
0 1
4 0
1 0
0 0
1 1
5 1
4 2
0 1
1 2
3 1
3 2
0 2
1 0
3 0
1 2
1 0
1 1
1 2
4 1
2 0
1 0
5 0
0 0
5 1
5 0
1 2
0 2
5 2
0 0
3 2
3 0
3 2
3 1
0 2
4 0
5 1
4 1
3 0
5 2
3 1
4 0
1 1
5 1
2 2
5 2
5 1
3 2
0 0
0 1
4 2
2 0
5 2
1 0
3 1
2 ...

output:

1
1
3
1
2
1
0
1
0
3
5
2
0
0
0
0
0
0
2
1
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
1
2
3
2
3
3
3
0
4
4
3
2
2
2
1
0
0
0
2
2
2
4
2
4
2
2
0
0
0
0
0
0
3
3
3
3
2
2
2
0
0
3
0
0
0
0
0

result:

ok 

Test #64:

score: 16
Accepted
time: 2ms
memory: 49068kb

input:

400
1 1 1 0 1 0 2 2 0 0 2 1 2 2 1 2 2 1 1 1 2 1 0 1 2 0 0 1 0 0 1 0 1 2 1 2 1 2 0 0 1 1 0 2 1 1 1 1 0 2 2 1 2 0 0 1 1 2 1 2 1 1 0 0 0 2 0 2 2 0 1 2 0 2 0 1 0 0 2 2 1 0 2 2 2 2 1 2 1 1 2 1 2 2 2 2 0 0 2 1 2 0 1 1 1 1 0 1 1 0 2 0 0 1 1 1 1 0 1 2 0 2 1 2 1 1 1 0 0 0 2 2 1 0 1 0 0 1 2 1 1 2 0 2 0 1 1 2 ...

output:

81027
81548
82381
82262
82052
81837
81658
81443
82127
81941
82560
80316
79750
80735
80890
73382
73536
73359
73138
72918
72653
71997
72478
72672
72911
72261
72853
73213
72954
73769
74787
74121
73931
71563
71778
70747
70281
70114
67043
66640
66415
65849
66006
66629
66799
66844
71682
71874
72971
72416
...

result:

ok 

Test #65:

score: 16
Accepted
time: 22ms
memory: 58472kb

input:

4000
1 1 1 0 1 1 0 2 1 1 2 1 2 2 1 0 1 2 2 0 1 1 1 1 2 0 1 1 0 0 2 0 1 1 2 2 2 2 1 1 1 1 0 0 1 2 0 1 0 2 1 2 2 1 2 0 1 2 0 0 0 1 1 0 1 2 1 1 1 1 0 1 0 1 1 2 1 1 0 1 1 0 0 2 2 0 1 0 0 1 1 2 0 0 1 0 0 1 0 0 2 0 2 2 1 1 2 0 2 1 2 2 0 1 1 1 1 1 1 1 0 2 0 2 0 1 1 1 1 1 1 0 0 0 1 2 1 2 0 0 0 0 1 1 2 0 0 0...

output:

14132542
14132780
14127197
14127091
14141758
14141687
14141782
14142021
14142204
14134941
14142824
14142974
14140574
14140667
14180192
14184660
14184584
14184417
14184136
14167667
14167744
14167912
14167710
14167788
14174353
14182082
14181898
14186831
14198546
14205957
14196800
14206231
14206053
141...

result:

ok 

Test #66:

score: 16
Accepted
time: 1370ms
memory: 666604kb

input:

200000
0 1 1 2 2 0 2 2 0 2 0 2 1 1 2 1 1 0 1 1 1 2 1 1 0 1 1 0 2 2 1 0 1 0 1 0 0 1 2 1 1 0 0 1 1 1 1 0 2 0 2 1 0 2 2 0 2 0 0 1 1 1 2 1 0 0 1 0 2 2 2 1 1 2 1 0 0 1 0 2 1 0 1 1 1 2 1 0 1 1 2 2 2 1 2 2 0 1 1 1 2 0 0 2 0 1 0 1 0 2 0 2 1 2 2 1 0 0 0 2 1 2 0 0 1 2 2 1 1 1 0 0 1 2 2 2 2 0 0 1 1 0 1 0 1 2 2...

output:

44705759734

result:

ok 

Test #67:

score: 16
Accepted
time: 1351ms
memory: 673272kb

input:

200000
1 1 2 1 2 0 2 2 1 2 1 2 1 2 2 2 2 2 2 2 1 1 1 1 2 2 1 1 2 1 1 2 2 2 2 1 2 1 2 1 1 1 1 1 0 2 2 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 0 1 2 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 2 1 2 2 2 1 1 2 2 1 2 1 1 1 0 0 1 2 1 1 2 0 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 2 2 1 1 1 2 2 1 2 1 1 2 2 1 1 1 2 2 2 2 1 1 2 1 2 2 1 0...

output:

8081399556

result:

ok 

Test #68:

score: 16
Accepted
time: 1360ms
memory: 683488kb

input:

200000
0 2 2 0 2 2 2 2 2 2 0 2 0 2 0 0 0 0 2 0 0 0 2 0 0 2 1 2 0 2 0 0 0 2 0 0 2 0 2 2 2 2 2 0 0 2 1 0 0 2 2 2 2 0 0 2 2 0 2 0 2 2 0 2 0 2 2 0 0 0 0 2 2 2 2 2 0 2 0 0 2 2 2 0 2 2 0 2 0 0 2 0 2 2 2 0 2 2 0 2 0 2 0 2 2 0 0 2 0 2 2 0 0 0 0 2 2 2 0 2 0 2 2 0 1 0 0 0 0 0 2 0 0 0 2 1 0 0 2 2 2 2 2 0 2 2 1...

output:

7578518269

result:

ok 

Test #69:

score: 16
Accepted
time: 1380ms
memory: 680196kb

input:

200000
1 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0 2 0 1 1 0 1 0 1 0 0 1 1 0 1 0 0 1 1 1 1 0 0 2 1 0 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 0 0 1 2 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 0 2 0 1 1 1 1 0 1 0 0 2 0 0 0 0 1 0 1 0 1 0...

output:

7842611505

result:

ok 

Test #70:

score: 16
Accepted
time: 738ms
memory: 334660kb

input:

100000
0 2 0 0 0 0 2 2 1 1 2 1 1 1 0 2 1 2 1 1 2 1 2 2 1 0 0 0 2 2 1 2 2 2 2 2 2 0 1 2 0 2 1 1 0 1 2 0 2 0 2 0 2 0 2 0 0 1 0 0 0 1 2 2 1 0 2 0 1 2 0 0 2 2 1 1 0 1 2 2 0 1 2 1 0 2 0 0 0 0 0 0 1 0 1 1 0 0 1 2 1 0 2 2 2 0 2 0 2 0 1 2 1 2 1 2 0 1 1 2 2 2 1 1 2 2 2 2 1 0 2 2 2 1 2 2 1 1 2 0 0 1 1 2 1 0 2...

output:

8821295872
8821296147
9564139052
8821295872
8821295681
9564138785
9564557503
9564371980
8821528877
8821295963
8821273000
8821273290
8821273000
9564071254
8821273290
9564071254
8821273000
8821273290
9564071254
8821273290
8820974722
9563750804
8820974722
8820974425
9563750804
8820974722
8821039686
882...

result:

ok 

Test #71:

score: 16
Accepted
time: 918ms
memory: 334472kb

input:

100000
1 0 2 1 0 2 2 0 2 2 2 2 2 0 2 1 1 0 1 1 1 1 0 1 2 1 1 2 2 2 2 2 0 1 1 2 1 1 2 0 1 1 1 1 2 0 0 1 2 0 2 0 1 2 2 1 2 2 2 2 1 2 0 2 2 0 1 1 1 1 2 0 1 1 1 2 1 1 0 2 2 2 1 1 0 2 2 1 2 2 1 2 1 2 1 1 2 0 1 1 2 1 2 1 1 1 2 0 1 2 0 1 0 2 0 0 2 2 0 0 1 1 2 0 1 1 1 1 1 0 0 2 1 2 2 0 1 1 0 0 2 1 2 2 0 0 0...

output:

9900828574
9901123105
9901558117
9901559863
9901561538
9901241053
9901243302
9900841539
9901073511
9900841551
9901224707
9900891827
9901193513
9901191456
9900859127
9900508225
9900868272
9900869818
9901103676
9901101160
9901405928
9901403850
9901736004
9902118965
9902402250
9902404114
9902169373
990...

result:

ok 

Test #72:

score: 16
Accepted
time: 982ms
memory: 350184kb

input:

100000
1 2 2 2 0 2 1 1 0 0 2 0 2 1 0 2 2 1 1 1 2 0 0 2 2 2 0 1 2 2 2 0 0 1 1 1 0 0 0 0 0 1 0 2 0 1 0 1 0 0 0 1 0 2 0 0 2 0 2 2 2 2 1 0 1 2 0 0 0 2 0 0 1 2 1 0 0 1 0 2 1 1 2 2 2 2 2 0 1 0 2 2 2 2 1 0 0 2 2 2 0 2 0 1 2 2 2 2 1 1 0 2 0 2 1 1 2 1 0 0 1 0 0 1 1 2 1 2 1 2 1 0 1 0 0 2 0 1 1 0 1 0 1 2 1 1 2...

output:

8866532903
8866266025
8866265404
8866264491
8865969722
8865968574
8865970233
8866204005
8865029098
8865196570
8865368030
8865370923
8865369538
8865168328
8865135093
8865385470
8865384250
8865383594
8865076149
8865313844
8865546375
8865244496
8864975343
8864974133
8864739724
8864740482
8864739477
886...

result:

ok 

Test #73:

score: 16
Accepted
time: 912ms
memory: 340108kb

input:

100000
1 2 2 0 1 1 2 1 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 1 2 1 2 2 2 1 2 2 2 1 1 1 2 2 1 1 1 1 1 1 2 2 2 0 2 1 1 2 1 2 2 2 2 1 2 2 2 2 2 1 1 1 1 2 2 2 1 1 1 2 1 1 1 1 2 1 2 2 2 1 1 1 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 1 2 2 1 2 1 1 1 2 2 2 1 1 2 0 1 2 1 2 2 2 1 1 2 2 1 1 1 2 1 2 2 1 1 1 1 1 2 2...

output:

1923134841
1923098761
1923068781
1923100856
1923136813
1923178461
1923151422
1923190446
1923139511
1923107348
1923142475
1923193068
1922471761
1922501746
1922531560
1922483959
1923074561
1923029924
1922988637
1923039300
1923012232
1923055404
1923709851
1924332573
1924291452
1924336408
1923841979
192...

result:

ok 

Test #74:

score: 16
Accepted
time: 987ms
memory: 334280kb

input:

100000
2 0 2 2 2 2 0 0 2 0 0 0 0 2 2 2 2 2 2 2 0 0 2 2 2 2 0 2 0 2 0 2 2 2 2 2 2 2 2 0 1 0 0 0 2 0 0 0 2 2 2 2 0 2 1 0 0 2 0 0 0 2 2 0 2 0 2 0 2 2 0 2 0 1 0 0 2 2 2 2 0 2 0 0 0 2 2 0 2 0 0 0 0 2 0 0 0 0 0 0 2 2 2 0 0 2 2 2 0 2 2 2 2 2 0 0 2 0 2 2 0 0 0 0 2 0 0 2 2 2 0 0 2 0 2 2 0 2 1 0 0 2 2 0 2 0 2...

output:

1525082875
1525082664
1525098402
1525098613
1525098402
1525098613
1525098666
1525098457
1530990775
1530990974
1530991108
1530990905
1530990702
1530990737
1530990721
1530990924
1530990945
1530990921
1531653395
1531653190
1531653395
1531653190
1531653147
1531653354
1531653381
1531653176
1531687363
153...

result:

ok 

Test #75:

score: 16
Accepted
time: 899ms
memory: 333292kb

input:

100000
0 1 0 1 1 1 1 1 1 0 0 1 1 1 0 0 1 1 1 0 1 0 0 0 0 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 2 1 0 0 0 1 1 0 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 1 1 1 0 0 1 1 0 0 0 2 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1...

output:

2063072176
2063026328
2063571586
2064283826
2064244031
2064284088
2064324207
2063683556
2063638505
2063590631
2063627298
2063648635
2063605542
2063913146
2063956384
2063999436
2063960585
2063923816
2063883884
2063860177
2063893092
2063929914
2064077069
2064034617
2063988435
2064000191
2063960758
206...

result:

ok 

Test #76:

score: 16
Accepted
time: 1650ms
memory: 674744kb

input:

200000
2 2 2 0 2 0 0 1 2 1 2 2 2 0 2 0 1 2 2 2 2 0 2 0 0 0 1 0 1 1 2 1 2 0 0 0 1 2 2 0 0 2 1 1 2 1 1 1 1 0 0 2 2 0 0 1 1 0 2 1 2 0 1 2 0 2 1 1 0 2 2 2 0 2 1 2 1 1 1 1 0 2 0 2 2 1 2 2 2 0 0 2 0 0 0 2 1 2 0 2 1 1 0 2 1 0 1 1 0 0 1 0 1 1 0 0 2 2 2 0 1 2 0 0 1 1 0 2 0 2 2 0 2 2 0 0 1 1 0 2 2 2 2 0 2 0 0...

output:

35803105614
38762344942
38761437962
35802153839
38761437962
38762063367
35802734800
35802734454
38762063367
35802734800
38762063367
38762064512
35802735377
38762064512
38762643916
35803270356
35803270016
38762643916
35803270016
35803268938
38762642614
35803268938
38762642614
35803269286
35803463662
...

result:

ok 

Test #77:

score: 16
Accepted
time: 2142ms
memory: 681708kb

input:

200000
1 0 1 0 0 2 1 0 1 2 0 1 1 1 0 1 2 2 1 0 2 0 0 2 1 1 1 0 1 1 2 1 2 2 0 2 2 2 0 0 1 1 2 0 0 2 0 1 1 1 0 0 0 1 2 1 0 2 1 0 1 2 0 2 2 0 1 0 0 2 2 1 2 0 1 2 1 0 2 1 1 1 1 1 1 0 1 0 0 2 1 1 2 0 2 2 1 2 1 2 2 0 0 1 2 0 1 1 2 0 2 2 0 0 2 1 2 2 1 0 2 2 1 0 0 0 1 0 0 0 0 0 2 1 0 0 0 2 0 2 2 0 0 2 2 0 2...

output:

43444761896
43445433771
43445977597
43445201981
43445746105
43445006762
43445006666
43445724756
43445723551
43445121919
43445841023
43445839953
43445839539
43445839231
43446516618
43447290990
43448075191
43448075302
43447423180
43447834695
43447163589
43447706753
43447705667
43447704670
43446988668
...

result:

ok 

Test #78:

score: 16
Accepted
time: 2161ms
memory: 680280kb

input:

200000
1 1 2 0 1 0 0 1 1 2 0 0 1 2 2 2 1 0 2 2 0 2 1 0 0 1 0 2 2 1 1 2 2 0 1 1 0 2 0 2 1 0 0 1 2 1 1 0 1 2 0 0 1 1 2 2 0 1 1 0 0 0 1 2 2 1 1 1 0 2 1 0 1 1 1 2 1 2 2 0 0 2 2 1 0 1 0 1 0 2 0 2 2 2 0 2 1 2 1 0 1 1 1 2 2 1 0 2 1 1 1 1 2 2 2 2 2 2 2 1 2 2 0 2 1 0 2 2 1 1 2 0 1 1 1 0 0 2 0 2 2 2 0 0 2 0 2...

output:

44897023717
44897026214
44896465355
44896591251
44896593006
44896590513
44895834212
44895368461
44894907040
44895640846
44895212634
44895677125
44894935040
44895723594
44896330327
44896326613
44896856238
44896170213
44895426076
44895423193
44895428090
44895426675
44895786854
44895241240
44894631441
...

result:

ok 

Test #79:

score: 16
Accepted
time: 2086ms
memory: 675132kb

input:

200000
2 1 1 2 1 2 2 1 1 2 1 1 0 2 2 2 1 1 2 2 2 2 2 2 2 1 1 1 2 2 2 1 2 1 2 2 2 1 2 1 2 2 1 1 0 2 2 1 2 1 1 2 1 2 2 2 2 2 1 1 1 2 1 2 2 2 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 2 2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 1 2 2 2 1 1 1 0 1 2 2 1 1 2 1 2 1 1 1 2 2 2 1 2 1 2 2 1 2 2 0 2 2 1 1 2 1 1 1 1 1 2 1 2 1 2 2 2...

output:

8101789485
8101739494
8103558728
8103498085
8103578182
8103664670
8103590427
8103512505
8103596589
8103555534
8103628457
8103701618
8103629649
8103726089
8103641305
8103685315
8104669426
8104768182
8104683042
8104599420
8104685426
8104775423
8104866920
8104042681
8103946158
8104045127
8103977963
810...

result:

ok 

Test #80:

score: 16
Accepted
time: 2167ms
memory: 683104kb

input:

200000
0 0 1 0 0 0 0 2 0 2 2 2 0 0 0 0 2 0 0 2 2 2 0 2 0 0 2 2 0 0 2 2 2 1 0 2 0 0 2 2 2 0 0 2 2 2 0 2 0 2 2 2 2 2 0 2 2 2 0 0 0 2 2 0 2 2 2 0 0 2 0 1 0 0 0 2 2 0 2 1 0 0 2 2 0 2 2 0 2 2 2 2 2 0 0 0 0 2 2 2 0 0 0 2 2 0 2 0 2 0 0 2 0 0 2 0 2 0 2 0 2 1 2 0 1 0 2 0 2 2 2 2 0 0 2 0 0 0 0 2 0 2 0 2 0 2 0...

output:

11328642689
11329157196
11329157389
11329157196
11329157003
11329157196
11329157033
11329157228
11329157389
11329157582
11329157338
11329157501
11329157338
11329157143
11329157593
11329157752
11329157481
11329157290
11329157455
11329157266
11329157433
11329157600
11329157785
11329157538
11329157701
...

result:

ok 

Test #81:

score: 16
Accepted
time: 2075ms
memory: 677856kb

input:

200000
0 0 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 1 0 0 0 2 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 1 1 0 0 0 1 1 1 0...

output:

7202374285
7202488860
7202567943
7202610579
7202678643
7203651400
7203653724
7203779776
7203727143
7202795337
7202721296
7202788305
7203614354
7203691259
7203631682
7203564301
7203734098
7203722068
7203783310
7203872538
7203799847
7203858616
7203914809
7203824076
7203876720
7203805758
7203894616
720...

result:

ok 

Subtask #6:

score: 34
Accepted

Dependency #2:

100%
Accepted

Test #82:

score: 34
Accepted
time: 1095ms
memory: 379220kb

input:

100000
2 1 0 2 1 2 2 2 0 1 2 1 1 2 1 2 1 1 1 1 1 0 1 0 0 1 0 1 1 2 0 1 2 1 0 1 2 2 2 1 0 1 0 2 1 1 2 0 1 0 0 2 0 2 2 2 2 1 0 2 0 1 1 2 2 2 0 2 1 0 1 1 0 1 1 0 1 1 1 2 2 0 2 1 1 2 0 0 0 2 0 2 2 1 1 2 2 1 2 2 1 0 2 0 1 2 2 1 1 1 2 2 1 1 1 2 0 0 0 0 1 0 0 0 2 0 2 0 0 2 1 0 0 2 2 2 0 1 1 1 1 1 0 1 0 0 1...

output:

9559281849549
9558726709272
9558729881442
9559281849549
9558726709272
9559281849549
9558729881442
9559281849549
9558729881442
9559281849549
9558726709272
9559281849549
9559183715845
9558884413811
9558329259230
9558343181485
9558898362995
9558346366933
9558349676690
9558901679573
9558349676690
955890...

result:

ok 

Test #83:

score: 34
Accepted
time: 1024ms
memory: 390364kb

input:

100000
0 0 1 1 1 2 1 0 1 1 0 2 1 1 1 1 0 0 0 2 1 0 1 2 0 2 0 0 0 2 2 0 2 0 1 1 1 0 2 0 2 1 1 2 1 1 0 0 2 1 0 2 2 1 0 1 1 0 0 2 1 2 0 2 2 1 2 0 2 1 0 2 2 1 0 1 0 1 2 0 0 1 1 2 0 0 0 2 1 2 1 2 0 0 1 2 0 1 2 1 1 1 0 0 1 0 1 2 1 0 2 0 2 2 0 2 0 1 1 1 2 1 1 0 1 0 1 0 0 1 1 1 1 0 2 1 0 0 2 2 2 2 1 1 1 2 1...

output:

9596047596512
9595616104943
9596053532037
9595619499659
9595182072565
9594755235780
9595189245987
9595616104943
9595622020637
9595188010430
9595625415285
9595192640635
9595619499659
9595613541827
9595619499659
9595192640635
9595625415285
9595619499659
9595182072565
9594755235780
9595192640635
959562...

result:

ok 

Test #84:

score: 34
Accepted
time: 1287ms
memory: 397304kb

input:

100000
2 1 2 2 0 0 1 1 1 0 0 2 0 0 2 0 0 2 1 2 2 2 0 0 2 0 2 0 0 1 2 0 1 1 0 0 1 0 0 2 0 0 2 0 1 2 0 1 1 1 2 1 0 1 0 0 2 0 2 1 2 1 1 0 1 2 0 0 2 2 1 2 1 2 1 1 2 2 2 0 1 1 0 1 1 1 0 1 1 0 0 0 0 1 2 0 2 1 2 0 1 1 2 1 2 1 1 2 0 2 2 2 1 0 0 2 1 1 2 2 0 1 2 1 0 0 2 1 0 2 2 0 2 1 1 0 0 1 1 2 0 2 0 0 2 0 1...

output:

9622694298497
9622741686310
9622812806952
9622385374356
9622418884136
9622421503780
9622420867340
9622420434599
9622420218943
9622422748226
9622422450342
9622422397283
9622169880867
9621998244485
9622205951428
9622011532374
9621602858583
9621832212874
9621831997132
9621807638552
9621958911257
962181...

result:

ok 

Test #85:

score: 34
Accepted
time: 1278ms
memory: 389156kb

input:

100000
2 2 1 1 2 1 1 1 1 2 1 1 1 2 1 2 1 2 1 2 2 1 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 1 1 2 1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 2 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 1 1 2 1 2 2 1 1 2 2 1 1 1 1 1 2 2 2 1 2 2 1 2 2 2 2 1 1 2 2 1 0 2 2 1 2 2 2 1 2 1 1 2 2 2 1 2 2 1 1 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 1 0 1 1 2 1 1 1 1 1...

output:

1772658133910
1772639782734
1772648903878
1772618082106
1772649217472
1772697652664
1772731157534
1772763191996
1772788201196
1772800273408
1772798905708
1772762384054
1772809290010
1772773292125
1773433797235
1773430197860
1773394126747
1773373709629
1773409559971
1773427138827
1773429214543
177341...

result:

ok 

Test #86:

score: 34
Accepted
time: 1262ms
memory: 403192kb

input:

100000
2 2 0 0 0 0 0 0 2 0 2 2 2 0 0 0 0 2 0 0 0 2 0 2 0 0 2 2 2 0 2 2 0 1 2 2 2 2 0 0 2 2 2 2 0 2 0 2 0 2 2 0 0 0 2 2 0 0 2 0 2 2 2 2 2 2 0 0 0 2 2 0 0 0 0 0 0 2 2 2 0 0 0 0 0 0 2 0 2 0 0 2 0 2 0 0 0 0 2 2 2 2 2 0 2 2 2 1 2 2 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 0 0 2 2 2 2 0 0 0 2 2 0 2 2 2 2 2...

output:

1843753459322
1843753087792
1843752887582
1843753149703
1843753376437
1842907711904
1843928418693
1843928692910
1843928333235
1843928094156
1843927777974
1844670077790
1844669722756
1844670011062
1844670215928
1844670513830
1844670852422
1844670613096
1844670372198
1844670703956
1845582952910
184558...

result:

ok 

Test #87:

score: 34
Accepted
time: 1314ms
memory: 393484kb

input:

100000
0 1 1 1 1 1 1 1 1 1 0 0 2 1 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 0 0 0 0 1 1 1 0 0 1 1 1 1 1 0 1 2 2 1 1 0 0 1 1 1 0 0 0 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 0 2 0 1 0 2 0 0 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 2 1 1 0 0 0 0 0 1 1 0 2 0 1 0 0 1 1 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0 0 0 0...

output:

1819509716742
1819523711225
1819540834260
1819553383315
1819563838563
1819562574646
1819526028449
1819557687502
1819582585402
1818769577336
1819313617009
1819342800218
1819342227082
1818768476934
1818743031680
1818772634362
1818804432744
1818844001778
1818826931304
1818865298394
1818825092164
181878...

result:

ok 

Test #88:

score: 34
Accepted
time: 1005ms
memory: 344500kb

input:

100000
0 0 0 2 1 1 2 1 0 1 2 2 2 0 1 1 0 2 0 1 2 1 1 0 1 0 1 2 2 2 1 0 2 1 2 0 2 1 2 0 0 2 0 1 1 2 2 0 1 2 0 2 2 1 1 1 2 1 2 0 0 2 1 1 1 2 1 1 0 2 1 1 1 0 1 2 1 0 2 1 1 2 1 1 2 0 2 2 0 1 0 0 2 0 0 0 2 2 0 2 0 0 0 0 0 2 0 0 0 2 2 1 2 0 1 2 2 2 2 2 2 0 0 1 2 1 1 1 1 0 2 1 2 0 0 1 0 2 1 0 2 2 1 2 2 2 0...

output:

85533161552
85530394278
85527900114
85525331224
85522844128
85525611360
85528304613
85530708556
85530692903
85527908072
85530565223
85533241447
85535788637
85533232941
85533217460
85535938670
85533159843
85530417127
85527677728
85530322861
85533020406
85535709872
85538183615
85536297229
85538975445
...

result:

ok 

Test #89:

score: 34
Accepted
time: 1005ms
memory: 368512kb

input:

100000
1 0 1 0 0 1 0 2 1 2 0 2 1 2 2 2 0 1 2 1 0 2 1 1 2 0 0 0 2 1 2 0 1 2 2 0 0 2 1 2 1 2 2 1 0 1 1 1 0 1 2 1 1 0 0 0 2 2 1 2 2 1 0 2 2 0 2 0 2 2 0 2 1 1 2 1 1 1 0 2 2 0 0 1 2 0 2 1 1 1 0 2 1 0 1 2 2 1 0 2 0 0 1 0 2 0 1 1 2 0 2 0 2 1 0 0 2 0 0 0 0 0 0 2 0 0 0 2 1 0 0 1 0 0 0 1 2 2 0 2 0 2 2 0 2 2 0...

output:

88163490600
88160808346
88160823013
88160806597
88163278177
88160659295
88160650228
88160632339
88158778956
88158767343
88158788337
88156045885
88158477899
88161276306
88163944130
88161470349
88161489759
88158923131
88158900690
88158880553
88156266829
88156277772
88158744340
88156157169
88153483056
...

result:

ok 

Test #90:

score: 34
Accepted
time: 1162ms
memory: 343556kb

input:

100000
1 1 2 1 0 2 1 1 2 2 0 2 1 1 2 0 0 1 2 2 0 1 0 0 0 1 2 2 1 2 0 0 2 2 0 1 2 0 0 1 2 1 0 2 0 2 0 0 1 1 2 0 2 1 0 1 0 1 2 0 2 1 1 2 0 1 1 2 1 0 0 2 2 1 1 2 0 1 1 1 0 2 0 2 2 2 2 0 0 2 2 2 0 0 0 2 0 1 1 1 0 2 0 0 0 1 2 0 1 2 0 0 2 1 1 1 0 2 2 1 1 2 2 0 2 2 0 0 0 0 2 1 0 0 2 1 1 0 1 2 2 2 1 0 2 1 1...

output:

29984838387
29985755560
29985756841
29984806281
29985878178
29986890992
29986890294
29985914110
29985913709
29986824656
29985753613
29986630132
29987705519
29986903166
29987877242
29987878744
29987038858
29986095385
29986094477
29985114036
29985115301
29985918815
29985918476
29985047769
29985952726
...

result:

ok 

Test #91:

score: 34
Accepted
time: 1104ms
memory: 345536kb

input:

100000
0 0 2 1 1 2 2 0 1 1 0 2 0 0 2 2 1 1 1 2 2 1 2 0 1 1 1 0 2 1 0 1 0 1 0 1 1 1 0 2 0 1 0 2 2 2 2 0 2 0 2 1 2 1 1 0 0 0 2 0 0 2 1 2 2 0 2 2 2 2 0 0 0 1 0 1 1 0 2 1 0 0 2 2 0 1 1 1 2 0 0 2 0 0 1 2 1 2 2 2 1 2 0 2 0 2 0 1 1 0 2 1 0 0 1 0 1 2 2 2 0 0 1 1 1 0 0 0 0 2 0 2 1 1 2 0 1 0 0 2 1 1 0 0 2 1 2...

output:

93294755255
93291946437
93291905849
93291930160
93291970148
93288955619
93288998449
93289042651
93289002479
93291744929
93294689769
93294650692
93291768144
93294445662
93291579404
93291617784
93294316936
93291496921
93288670156
93285734973
93283089413
93280296518
93277353657
93277315526
93280162676
...

result:

ok 

Test #92:

score: 34
Accepted
time: 1097ms
memory: 330796kb

input:

100000
1 2 2 0 1 1 0 0 0 0 0 0 2 2 1 2 0 0 0 0 0 1 2 0 1 0 2 0 0 2 0 1 0 1 0 1 2 2 0 2 1 2 0 2 2 0 0 1 2 1 1 2 1 0 0 1 2 1 0 2 1 0 1 0 0 2 0 2 2 0 1 1 0 1 2 0 0 2 2 0 1 2 0 1 1 2 2 1 2 0 2 1 0 0 0 1 2 2 1 0 1 1 0 2 1 0 0 2 1 1 1 2 0 1 0 1 0 1 2 0 0 2 1 2 1 1 2 0 2 1 1 1 0 0 0 1 2 1 2 2 1 1 1 2 2 2 2...

output:

316136684336
316136626565
316136536103
316127639502
316118013463
316107977992
316107913417
316117391225
316107301123
316097347283
316087783495
316087737078
316078110459
316087866540
316077980382
316087308618
316097274857
316088143581
316097797283
316107750466
316107683345
316117437095
316117370809
3...

result:

ok 

Test #93:

score: 34
Accepted
time: 1048ms
memory: 320784kb

input:

100000
0 0 2 0 0 0 0 1 0 1 1 0 2 0 2 2 2 1 2 1 2 0 1 2 1 0 0 1 2 2 0 2 2 0 2 1 2 2 2 1 1 0 1 2 1 1 2 1 2 0 2 1 0 1 2 1 2 1 0 1 0 2 0 1 2 2 1 2 1 2 0 2 1 1 1 1 0 0 0 0 0 0 1 0 0 2 0 0 0 1 1 1 0 2 0 2 1 0 1 1 0 1 1 0 1 2 0 2 0 1 0 0 0 0 1 1 1 1 2 1 2 1 1 2 2 2 1 0 2 1 0 0 0 2 0 1 2 2 1 1 1 0 2 2 1 0 2...

output:

1095656831871
1095619257668
1095618839928
1095588795545
1095554618379
1095554736432
1095589461566
1095589737943
1095624279061
1095623976424
1095624284716
1095598229229
1095568067817
1095567763685
1095568137834
1095568080998
1095602558471
1095568532073
1095534383970
1095567808145
1095567574094
109553...

result:

ok 

Test #94:

score: 34
Accepted
time: 1012ms
memory: 370392kb

input:

100000
2 1 0 0 0 2 1 0 1 1 2 1 0 0 1 1 2 2 2 2 1 0 1 2 1 0 0 1 2 1 0 2 2 0 0 0 1 1 1 1 0 2 1 1 2 2 0 1 1 1 0 2 0 1 0 2 1 0 2 1 1 2 2 0 0 0 1 0 1 1 1 1 2 2 1 1 1 0 0 2 0 2 0 1 0 2 1 2 2 0 2 0 0 1 1 0 2 0 1 0 2 2 1 0 0 1 2 0 0 1 0 1 2 2 1 0 1 0 2 1 1 2 2 0 2 0 0 2 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 2 2...

output:

4097865354006
4098331326178
4098516651380
4098050662313
4098049761584
4098050662313
4098516651380
4098050662313
4098516651380
4098050662313
4098516651380
4098050662313
4098516651380
4098049761584
4098050662313
4098142136514
4098141235639
4098608141919
4098142136514
4098238707855
4098237808229
409870...

result:

ok 

Test #95:

score: 34
Accepted
time: 1285ms
memory: 351556kb

input:

100000
1 1 2 1 2 1 2 1 1 2 1 1 2 0 0 0 0 2 2 2 0 1 0 0 1 2 0 0 0 1 0 1 1 1 1 2 1 0 1 1 0 0 1 2 1 0 1 0 1 2 0 1 2 1 0 2 2 2 1 1 2 0 2 1 1 0 1 1 1 2 1 0 0 2 2 0 0 0 1 1 2 2 0 2 0 0 0 0 0 0 1 1 0 0 0 1 2 1 1 0 1 0 0 0 2 0 1 0 0 1 2 2 0 0 2 1 2 2 2 0 0 2 1 0 2 2 0 0 1 2 1 2 1 2 2 1 0 2 2 1 0 2 0 0 1 0 1...

output:

4130152291057
4130056852820
4130179707803
4130180563664
4130181455962
4130294178778
4130174597295
4130298144138
4130393454351
4130394596969
4130393850725
4130488422291
4130372094581
4130372982891
4130512333976
4130606032139
4130484424711
4130485171130
4130485895897
4130611887465
4130730104101
413073...

result:

ok 

Test #96:

score: 34
Accepted
time: 1163ms
memory: 349808kb

input:

100000
0 2 0 0 1 1 1 2 1 2 1 1 0 2 0 1 2 0 1 0 0 0 0 0 1 0 0 2 1 1 0 0 1 2 0 1 2 0 0 2 0 0 0 1 0 2 0 0 1 1 0 2 1 1 2 2 2 0 1 2 2 0 1 0 2 2 2 2 2 0 2 2 1 2 0 2 0 0 2 1 0 1 1 0 2 2 2 2 0 0 1 0 1 1 1 0 2 1 1 0 2 0 0 0 1 0 2 0 0 2 0 1 2 1 1 1 0 0 0 0 1 0 2 0 1 2 0 1 0 0 1 1 2 0 2 1 2 0 0 0 0 2 0 2 1 0 1...

output:

4100962908565
4100510865543
4100607662611
4100487528621
4100488262981
4100865918189
4100866614488
4100865516353
4100866242610
4100728509312
4101187810873
4101062881775
4100692329824
4101011802771
4100762608651
4100761526715
4100630386031
4100765060727
4101084455940
4101085404592
4100706314594
410058...

result:

ok 

Test #97:

score: 34
Accepted
time: 1197ms
memory: 361480kb

input:

100000
1 1 1 1 2 1 2 2 1 1 2 1 2 1 2 2 1 1 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 2 2 1 2 1 1 2 1 2 1 1 1 1 0 1 2 2 1 2 1 1 1 2 1 2 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 1 1 0 2 1 2 1 2 2 1 2 2 1 1 2 1 1 2 2 2 1 1 1 2 1 2 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 2 2 2 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 1 2 2 1 1 1 2...

output:

760293049692
760306100439
760263999028
760480245694
760492615292
760480829183
760493497722
760535256365
760557814477
760545556296
760586281642
760572056367
760550639584
760536606475
760715883136
760715172930
760727499627
760745780459
760758584604
760778253175
760830109490
760842444211
760860329576
7...

result:

ok 

Test #98:

score: 34
Accepted
time: 1349ms
memory: 351304kb

input:

100000
2 0 0 2 2 0 0 0 2 1 0 0 0 2 2 2 2 2 0 2 0 0 0 2 2 2 0 2 2 0 2 0 2 0 0 2 0 0 2 2 2 0 2 1 0 2 2 2 0 0 2 0 2 0 0 0 0 2 0 1 2 0 0 2 2 0 0 0 1 2 0 0 0 0 2 2 0 0 2 2 2 2 0 2 0 2 0 1 2 0 0 2 2 1 2 2 0 0 1 0 2 0 2 2 0 2 2 2 0 0 2 0 1 2 2 2 0 2 0 0 2 0 2 0 0 0 0 2 0 2 2 0 0 2 0 2 0 0 2 2 0 0 2 2 0 2 0...

output:

826654004799
826654194674
826654133463
826654181312
826654023514
826653920266
826653733788
826653945959
826654117797
826653908276
826653782514
826653654511
826653600933
826653703960
826653569046
826653403956
826653364326
826653257770
826653422914
826637448595
826637279229
826637350616
826637456619
8...

result:

ok 

Test #99:

score: 34
Accepted
time: 1305ms
memory: 349384kb

input:

100000
0 0 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 1 2 1 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 0 1 1 1 0 0 0 1 0 0 1 0 0 2 1 0 1 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1 0 0 2...

output:

805664825072
805710705933
805723700257
805746319258
805945918968
805738618967
805724576457
806002959191
805989799837
805977031104
806165842730
806385976425
806408592276
806377174159
806363910989
806347226901
806360612288
806338305997
806276355069
806502601984
806516973760
806533700682
806519137461
8...

result:

ok 

Test #100:

score: 34
Accepted
time: 1138ms
memory: 401340kb

input:

100000
0 1 1 2 1 2 1 0 0 2 0 2 1 1 0 1 0 1 0 2 1 2 0 2 0 2 0 0 1 1 2 1 0 1 1 0 1 0 0 0 2 1 2 1 2 2 0 1 2 0 0 0 0 1 1 2 2 1 1 2 1 2 1 1 0 0 1 1 0 1 2 1 1 1 1 1 1 2 0 2 1 1 0 0 0 0 2 2 1 0 2 2 0 2 1 2 2 0 0 1 1 2 0 0 1 0 2 0 0 2 2 0 0 0 1 0 1 2 2 2 0 1 1 1 0 1 0 1 2 1 2 0 0 1 1 1 2 0 1 0 1 2 0 0 0 2 0...

output:

12378861465034
12378861549997
12379137199914
12378861549997
12378861465034
12379137199914
12378861549997
12379137199914
12378861549997
12379137199914
12378861549997
12378861465034
12379137199914
12378861549997
12378861465034
12379137199914
12379139464690
12378863821511
12378861607010
12378861521021
...

result:

ok 

Test #101:

score: 34
Accepted
time: 1008ms
memory: 396236kb

input:

100000
2 1 0 2 1 1 0 2 1 0 1 0 1 2 0 2 0 0 0 1 0 2 2 1 1 1 1 1 1 2 2 1 2 0 2 2 0 2 1 2 1 0 2 2 0 2 2 2 1 2 0 2 1 0 2 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 2 0 0 2 0 2 2 1 1 2 2 1 0 1 1 2 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 2 0 1 0 0 2 0 0 2 0 1 0 2 0 0 1 1 0 2 1 2 0 0 1 0 2 2 0 1 1 0 0 0 0 0 0 2 2 0 2 0 1...

output:

12356317730902
12355757413015
12355206931832
12355757413015
12356309564939
12355759083756
12356309564939
12355757413015
12356309564939
12356317730902
12355757413015
12355764355718
12356316540921
12355759083756
12356316540921
12355764355718
12355757413015
12355206931832
12355764355718
12356324640326
...

result:

ok 

Test #102:

score: 34
Accepted
time: 1230ms
memory: 414644kb

input:

100000
0 0 2 0 2 1 0 2 0 0 1 2 1 2 2 2 2 2 0 2 1 1 0 1 0 0 0 2 1 1 0 2 2 2 1 1 2 0 0 1 1 1 0 1 1 1 0 1 2 0 0 0 1 0 0 2 0 0 1 0 2 2 2 0 0 0 1 1 2 0 0 1 0 2 1 2 1 1 2 1 0 0 2 0 0 1 2 1 0 2 0 1 0 0 1 1 0 0 0 1 0 2 2 2 1 0 2 0 0 0 0 2 2 2 1 2 2 0 0 1 1 0 1 1 0 1 1 0 1 2 2 0 2 1 0 1 0 2 2 2 1 1 0 1 1 0 2...

output:

12361639333356
12361912035054
12361609273559
12361770767102
12361412299625
12361269172442
12361537499341
12361367443063
12361634309892
12362109703751
12362114355666
12362375712286
12362234785038
12362428752181
12362669907842
12362625781780
12362630221089
12362634525130
12362620483084
12362319321363
...

result:

ok 

Test #103:

score: 34
Accepted
time: 828ms
memory: 338624kb

input:

100000
2 0 2 2 0 2 1 1 1 2 1 2 1 2 0 1 0 0 1 0 1 1 1 1 2 1 2 0 0 0 2 0 2 0 0 2 1 2 0 0 0 2 2 1 0 2 0 1 1 2 2 1 1 1 2 0 2 0 0 0 1 2 2 1 0 2 2 0 0 1 0 0 1 1 1 1 0 2 0 0 2 1 2 0 1 2 2 1 2 1 0 1 2 0 2 0 2 0 1 2 0 2 0 2 1 0 0 2 0 2 1 0 1 0 1 0 2 0 2 1 1 2 2 0 1 0 1 1 2 2 1 2 1 0 1 1 2 0 1 0 0 2 1 1 1 2 2...

output:

145953829313
146504500096
145953786136
146504500096
145953829313
146504500096
145953786136
146504500096
146498364765
146494865483
145944184844
145944228277
145940137065
146490757708
146487565932
145936961863
145866474549
145866437173
145862282860
146412887959
145862282860
146412887959
145862239383
1...

result:

ok 

Test #104:

score: 34
Accepted
time: 968ms
memory: 314860kb

input:

100000
2 2 0 0 2 1 0 1 1 0 0 2 0 1 1 0 2 1 1 1 0 2 1 2 1 1 1 0 0 2 1 0 0 1 1 0 1 0 1 0 0 0 2 2 2 1 0 0 2 1 2 1 0 2 2 2 1 2 1 0 1 2 2 1 2 2 0 2 0 1 2 1 0 2 1 2 0 1 0 2 2 2 2 0 0 1 1 0 2 1 1 0 1 2 1 1 2 0 2 2 1 0 1 1 2 0 0 2 0 1 0 1 0 0 0 0 2 2 1 0 0 0 1 1 1 0 0 2 1 2 1 0 1 0 0 1 0 2 0 1 2 0 1 2 2 1 2...

output:

151045518233
151048940412
151048989721
151053526119
151050138354
151050193203
151055666168
151055685648
151051538661
151051501359
151051437434
151055614564
151055562909
151050782917
151045903094
151045858691
151045902613
151050281551
151054706281
151054659497
151051011982
151051038544
151050997994
1...

result:

ok 

Test #105:

score: 34
Accepted
time: 910ms
memory: 316000kb

input:

100000
2 1 1 2 1 2 1 1 2 2 1 2 2 2 2 1 2 2 2 1 2 2 1 1 2 2 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 1 1 0 2 1 2 2 1 1 2 1 2 2 1 2 2 1 1 1 2 1 2 2 1 1 0 1 1 1 2 2 2 1 1 2 1 2 2 1 1 2 0 1 1 2 1 2 2 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 2 1 1 0 1 2 2 2 2 1 2 2 1 1 2 1 2 1 1 1 2 1 1 1 2 1 2 2 2 2 1 2 2 2 1 1 2 1 2 1 1...

output:

32424642834
32424016637
32423181413
32422521607
32422011030
32421420718
32421975315
32422021723
32421445691
32422124570
32421644969
32437042481
32437981275
32437188280
32437694289
32437234630
32436460553
32435914229
32435762179
32436340401
32437235210
32436735319
32436674155
32436085921
32435406450
...

result:

ok 

Test #106:

score: 34
Accepted
time: 923ms
memory: 320928kb

input:

100000
2 2 0 2 2 0 0 0 2 2 0 2 2 0 2 2 0 2 0 2 2 0 0 0 2 0 0 2 0 2 2 0 2 0 0 0 0 0 0 0 2 0 2 2 2 2 2 2 0 2 0 0 2 2 0 0 2 2 0 2 0 0 0 2 2 0 0 2 0 2 0 2 2 0 2 0 2 0 2 2 2 0 0 2 2 0 2 0 0 0 2 0 0 0 0 0 2 2 2 2 2 0 0 2 2 2 0 2 2 0 0 2 0 2 2 1 2 0 0 2 2 2 2 2 0 0 2 0 0 0 2 0 2 0 2 0 0 0 2 1 2 2 0 0 0 2 0...

output:

30359891732
30359464977
30359456207
30359468177
30359458176
30359469622
30359249191
30359234680
30359226951
30359218756
30297949108
30297963056
30297968904
30297347234
30297356949
30297345763
30297355160
30297345296
30297358418
30297351515
30297358970
30297347945
30297338878
30297327219
30297318098
...

result:

ok 

Test #107:

score: 34
Accepted
time: 921ms
memory: 319804kb

input:

100000
0 0 1 0 0 1 1 1 0 0 1 1 1 1 0 2 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1 2 0 0 0 1 1 1 0 1 1 1 1 0 1 0 2 0 1 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 1 1 1 0 2 1...

output:

30136609798
30136083207
30136736964
30135867822
30136355770
30136818513
30137497353
30137018626
30137619738
30138121767
30138581832
30138076345
30147341758
30147950560
30147393815
30147136333
30157889347
30161770164
30162347130
30161851147
30154669620
30163331241
30162783461
30162151016
30161255000
...

result:

ok 

Test #108:

score: 34
Accepted
time: 933ms
memory: 310412kb

input:

100000
2 0 1 2 1 0 0 1 1 2 2 0 0 0 2 1 1 0 1 1 0 1 1 0 0 0 0 0 1 1 2 2 2 2 1 2 0 2 2 1 2 1 2 0 0 2 2 0 1 0 0 1 0 1 1 0 2 1 2 2 0 1 1 1 2 1 2 2 1 2 1 0 2 2 2 1 0 1 2 0 1 1 0 0 1 0 1 2 0 0 2 1 2 0 1 0 0 1 0 0 0 0 1 0 2 1 1 2 2 2 2 2 2 0 0 0 1 2 0 2 0 0 0 0 0 0 0 0 2 2 1 1 0 1 1 1 2 1 1 1 1 1 2 0 2 2 1...

output:

135628486664
135625574730
135621919068
135617830047
135622386052
135623351927
135623329877
135618955253
135614745390
135618471579
135622037033
135625519834
135625536177
135621562312
135617599779
135621889275
135621856312
135626209041
135629696172
135632966938
135629614690
135633710238
135637450477
1...

result:

ok 

Test #109:

score: 34
Accepted
time: 172ms
memory: 160964kb

input:

100000
2 1 0 2 1 2 2 2 0 1 2 1 1 2 1 2 1 1 1 1 1 0 1 0 0 1 0 1 1 2 0 1 2 1 0 1 2 2 2 1 0 1 0 2 1 1 2 0 1 0 0 2 0 2 2 2 2 1 0 2 0 1 1 2 2 2 0 2 1 0 1 1 0 1 1 0 1 1 1 2 2 0 2 1 1 2 0 0 0 2 0 2 2 1 1 2 2 1 2 2 1 0 2 0 1 2 2 1 1 1 2 2 1 1 1 2 0 0 0 0 1 0 0 0 2 0 2 0 0 2 1 0 0 2 2 2 0 1 1 1 1 1 0 1 0 0 1...

output:

1107046824
0
0
1107046824
0
1107046824
0
1107046824
0
1107046824
0
1107046824
1107013440
1107046824
0
0
1107079985
0
0
1107080208
0
1107080208
0
1107080208
0
0
0
0
0
1107080429
0
0
1107080429
0
0
0
0
0
0
0
1107113592
0
0
0
0
0
0
0
0
0
1107113370
0
0
0
1107113370
1107146532
0
1107146532
0
1107146532
...

result:

ok 

Test #110:

score: 34
Accepted
time: 173ms
memory: 135092kb

input:

100000
2 2 2 1 2 0 2 2 0 1 0 1 0 2 0 0 0 1 0 0 1 1 1 2 0 2 2 0 1 0 2 2 1 0 0 0 2 1 2 1 0 0 2 0 2 2 2 0 2 2 2 0 0 0 1 1 2 0 2 0 2 2 1 1 0 0 0 0 0 1 0 0 0 0 2 2 0 0 2 1 0 0 2 0 2 1 1 1 2 1 0 0 2 0 1 1 2 1 0 1 2 1 2 2 0 2 0 0 2 0 0 2 0 1 2 0 2 2 1 0 2 2 0 0 2 0 0 1 2 1 1 0 0 1 2 1 2 2 1 1 1 2 1 0 2 0 0...

output:

1110249440
1110282960
1110249837
1110283356
1110250232
1110249837
1110250232
1110217108
1110217500
1110251016
1110217500
1110251016
1110251405
1110251792
1110284920
1110251405
1110217890
1110251016
1110284532
1110318048
1110351176
1110384304
1110383913
1110417432
1110383913
1110384304
1110351176
111...

result:

ok 

Test #111:

score: 34
Accepted
time: 205ms
memory: 135288kb

input:

100000
1 1 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 1 2 1 2 1 1 2 1 1 2 1 2 1 2 2 2 2 2 2 2 1 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 2 2 2 2 2 1 1 2 2 1 1 1 2 2 2 1 1 2 2 1 2 1 2 2 2 2 1 1 1 1 2 1 0 2 1 2 2 1 2 2 1 2 1 1 1 1 2 2 0 2 2 1 2 0 1 2 1 1 2 2 2 2 1 2 1 1 1 2 1 2 2 2 1 2 1 2 2 0 2 1 1 2 1 1 2 1 1 2 1...

output:

146452258
146455281
146452258
146455281
146458304
146503728
146500704
146497680
146500704
146503728
146500704
146497680
146494656
146497680
146543100
146546125
146549150
146552175
146549150
146552175
146549150
146546125
146543100
146540075
146585492
146588518
146591544
146588518
146585492
146582466
...

result:

ok 

Test #112:

score: 34
Accepted
time: 222ms
memory: 137748kb

input:

100000
2 0 0 2 2 1 0 0 2 2 2 2 2 2 0 0 2 2 2 0 2 0 2 0 0 2 0 0 0 0 2 0 0 0 2 0 1 0 1 0 2 0 0 0 0 2 2 2 0 2 2 2 0 0 0 0 2 2 0 2 1 2 2 0 2 2 0 2 2 0 0 0 2 0 0 2 0 0 2 2 2 2 0 1 2 0 2 2 0 0 0 2 0 0 2 0 0 1 2 2 0 0 0 0 2 0 0 2 2 0 0 0 2 2 0 0 2 2 2 0 0 1 2 2 2 0 0 0 2 2 0 2 2 2 2 0 2 0 0 2 2 2 2 0 0 0 2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 

Test #113:

score: 34
Accepted
time: 204ms
memory: 148820kb

input:

100000
1 0 0 1 0 2 1 2 1 1 1 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 2 1 0 1 0 0 0 1 2 0 1 0 1 1 1 0 1 0 1 2 0 1 2 1 1 1 0 2 0 1 1 0 0 2 1 1 2 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 1 0 0 0 1 0 1 1 1 1 2 0 0 0 1 1 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 1 1 0 0 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 

Subtask #7:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #114:

score: 14
Accepted
time: 2411ms
memory: 781020kb

input:

200000
2 1 1 1 2 0 2 2 2 0 1 1 0 1 2 1 1 2 1 2 2 2 1 0 0 0 0 2 1 0 2 0 1 1 2 1 0 2 0 2 1 2 1 1 0 1 0 2 0 0 1 2 0 0 0 0 0 2 1 2 0 0 1 1 0 1 2 1 0 0 0 1 1 2 1 0 1 1 1 1 2 0 1 1 1 2 2 0 0 1 0 1 0 2 2 2 2 2 0 1 0 2 2 1 2 1 2 0 0 0 0 1 1 2 1 1 2 1 0 0 2 2 0 2 1 2 1 1 2 2 2 0 1 1 2 2 0 1 1 0 1 2 1 0 2 0 1...

output:

76960503493028
76962705274605
76960496001543
76962705274605
76960503493028
76960511516477
76960504028860
76962713300463
76960511516477
76962713300463
76960504028860
76962713300463
76960511516477
76960504028860
76962713300463
76960504028860
76962713300463
76963427687246
76961218470400
76960703082954
...

result:

ok 

Test #115:

score: 14
Accepted
time: 2421ms
memory: 771328kb

input:

200000
1 1 1 1 2 0 2 1 0 0 2 2 0 0 0 1 1 1 1 0 2 2 1 1 1 2 0 2 1 0 2 0 1 2 0 2 1 1 1 0 2 0 2 1 0 0 0 2 2 1 2 1 1 0 2 1 0 2 2 0 0 1 1 2 2 1 2 0 1 2 2 1 1 1 0 0 1 1 0 0 0 2 2 0 1 1 0 2 2 0 1 0 2 0 0 2 1 2 0 2 1 0 1 0 0 1 1 0 0 2 2 2 2 1 1 0 2 2 1 0 0 0 2 2 0 0 2 1 1 1 0 1 1 2 2 0 2 2 1 1 2 1 2 0 1 1 2...

output:

76935543540291
76935537488010
76937256041318
76937262138072
76937274387699
76935541886938
76933794932586
76935529592622
76935545772484
76935529592622
76935545772484
76937278273461
76937290433696
76935543524040
76937290433696
76935557977408
76937284515266
76935537560921
76937272265653
76935537488010
...

result:

ok 

Test #116:

score: 0
Time Limit Exceeded

input:

200000
1 0 0 0 0 1 2 2 2 0 0 2 0 1 2 0 2 1 1 0 2 1 1 0 2 2 2 1 1 0 1 0 0 2 1 0 0 1 1 2 0 0 0 1 0 2 0 2 2 1 2 1 1 0 0 1 0 0 1 1 2 2 0 1 1 2 0 2 1 0 1 0 2 2 0 1 2 0 2 2 1 2 2 2 0 1 0 2 1 1 2 0 0 1 2 0 2 0 1 0 0 0 2 2 1 0 2 1 2 0 1 2 2 2 1 0 1 1 0 2 1 1 1 0 2 0 0 0 1 1 0 1 2 0 1 1 0 1 1 0 2 0 0 0 0 2 2...

output:

77098179826945
77097160475230
77097151877158
77097142355872
77098127115484
77098115558257
77098508770418
77099479219660
77099491053627
77098924728500
77099711897758
77101370265870
77102509282174
77103297568310
77104480783722
77104488324219
77102768957907
77102754445530
77102761343163
77102768744472
...

result: