QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783635#9645. 字符游戏Nesraychan100 ✓2604ms78544kbC++144.1kb2024-11-26 11:07:322024-11-26 11:07:32

Judging History

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

  • [2024-11-26 11:07:32]
  • 评测
  • 测评结果:100
  • 用时:2604ms
  • 内存:78544kb
  • [2024-11-26 11:07:32]
  • 提交

answer

#include<bits/stdc++.h>
#define IL inline
#define reg register
#define N 50050
IL int read()
{
    reg int x=0,f=0; reg char ch=getchar();
    while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}

int n,q,a[N];
char s[N];
std::vector<int>G[N];

IL void add(reg int u,reg int v){G[u].push_back(v),G[v].push_back(u);}

int pfa[16][N],*fa=pfa[0],dep[N];
int buc[10],panc[16][N],*anc=panc[0];

void dfs0(reg int u)
{
    dep[u]=dep[fa[u]]+1;
    reg int x=buc[a[u]];
    anc[u]=x,buc[a[u]]=u;
    for(auto v:G[u])if(v!=fa[u])
        fa[v]=u,dfs0(v);
    buc[a[u]]=x;
}

int f[N][10],pf[16][N],lst[N][10];

void dfs1(reg int u)
{
    pf[0][u]=f[fa[u]][a[u]];
    for(reg int o=1;o<16;++o)pf[o][u]=pf[o-1][u]^pf[o-1][panc[o-1][u]];
    buc[a[u]]=u;
    for(reg int i=0;i<10;++i)lst[u][i]=buc[i];
    std::vector<int>P;
    for(reg int i=0;i<10;++i)if(buc[i]&&i!=a[u])P.push_back(i);
    std::sort(P.begin(),P.end(),[&](reg int i,reg int j){return dep[buc[i]]>dep[buc[j]];});
    for(auto i:P)
    {
        std::vector<int>Q;
        static bool vis[200];
        reg int x=buc[i],y,j,o;
        for(j=10;j--;)if(dep[y=buc[j]]>dep[x])
        {
            reg int res=f[u][j];
            for(o=16;o--;)if(dep[panc[o][y]]>dep[x])
                res^=pf[o][y],y=panc[o][y];
            res^=f[fa[y]][i];
            // if(u==7&&i==4&&j==2)
            // {
            //     printf(">> %d\n",res);
            // }
            Q.push_back(res);
        }
        for(auto x:Q)vis[x]=1;
        reg int mex=0;
        while(vis[mex])++mex;
        f[u][i]=mex;
        // printf("f[%d][%d] = %d\n",u,i,mex);
        for(auto x:Q)vis[x]=0;
    }
    for(auto v:G[u])if(v!=fa[u])dfs1(v);
    buc[a[u]]=anc[u];
}

IL int lca(reg int u,reg int v)
{
    if(dep[u]<dep[v])std::swap(u,v);
    for(reg int o=16;o--;)if(dep[pfa[o][u]]>=dep[v])
        u=pfa[o][u];
    if(u==v)return u;
    for(reg int o=16;o--;)if(pfa[o][u]!=pfa[o][v])
        u=pfa[o][u],v=pfa[o][v];
    return fa[u];
}

std::map<std::pair<int,int>,std::pair<int,int>>mp;

std::pair<int,int>query(reg int u,reg int v,reg int w)
{
    if(mp.count({u,v}))return mp[{u,v}];
    reg int cnt=0,mex=0;
    std::vector<int>Q;
    static bool vis[200];

    reg int c=a[w],res=0,x;

    auto slack=[&]() -> void
    {
        if(!res)++cnt;
        Q.push_back(res);
    };

    x=lst[u][c],res^=f[u][c];
    for(reg int o=16;o--;)if(dep[panc[o][x]]>=dep[w])
        res^=pf[o][x],x=panc[o][x];
    x=lst[v][c],res^=f[v][c];
    for(reg int o=16;o--;)if(dep[panc[o][x]]>=dep[w])
        res^=pf[o][x],x=panc[o][x];
    slack();
    for(reg int i=0,nu,nv,x,o;i<10;++i)if(i!=c)
    {
        if(dep[lst[u][i]]<dep[w]&&dep[lst[v][i]]<dep[w])continue;
        x=lst[u][i];
        if(dep[x]>dep[w])
        {
            res=f[u][i];
            for(o=16;o--;)if(dep[panc[o][x]]>dep[w])
                res^=pf[o][x],x=panc[o][x];
            nu=fa[x];
        }else res=0,nu=u;
        x=lst[v][i];
        if(dep[x]>dep[w])
        {
            res^=f[v][i];
            for(o=16;o--;)if(dep[panc[o][x]]>dep[w])
                res^=pf[o][x],x=panc[o][x];
            nv=fa[x];
        }else nv=v;
        res^=query(nu,nv,w).first;
        // printf(">> [%d, %d], i = %d, res = %d\n",u,v,i,res);
        slack();
    }
    for(auto x:Q)vis[x]=1;
    while(vis[mex])++mex;
    for(auto x:Q)vis[x]=0;
    // printf("[%d, %d, %d]\n",u,v,mex);
    return mp[{u,v}]={mex,cnt};
}

main()
{
    n=read(),q=read(),scanf("%s",s+1);
    for(reg int i=1;i<=n;++i)a[i]=s[i]-'0';
    for(reg int i=1;i<n;++i)add(read(),read());
    dfs0(1);
    for(reg int o=1,i;o<16;++o)for(i=1;i<=n;++i)
        pfa[o][i]=pfa[o-1][pfa[o-1][i]],panc[o][i]=panc[o-1][panc[o-1][i]];
    memset(buc,0,sizeof(buc));
    dfs1(1);
    // query(3,7,lca(3,7));
    // printf("%d\n",f[7][4]);
    for(reg int u,v;q--;)
    {
        u=read(),v=read();
        auto [x,y]=query(u,v,lca(u,v));
        if(!x)puts("Bob");
        else printf("Alice %d\n",y);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 0ms
memory: 13308kb

input:

8 1000
20002200
7 5
1 4
4 2
8 5
4 6
4 5
3 7
2 6
1 3
6 4
4 4
6 8
3 1
2 6
1 2
2 2
5 3
4 1
4 3
8 6
2 7
5 6
5 8
8 4
2 1
4 6
5 2
5 6
6 8
4 1
7 2
6 4
7 5
5 2
1 2
5 7
6 3
8 8
7 1
3 1
4 1
7 6
7 2
1 2
1 8
2 3
5 5
7 3
8 3
2 1
8 2
7 6
1 8
8 1
1 5
2 3
5 3
6 4
2 4
8 4
5 3
3 2
3 1
4 1
2 2
3 6
6 6
5 3
5 8
4 8
3 2
...

output:

Bob
Alice 2
Bob
Alice 1
Alice 2
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 2
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 2
Alice 2
Bob
Alice 2
Alice 1
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 2
...

result:

ok 1000 lines

Test #2:

score: 7
Accepted
time: 0ms
memory: 15580kb

input:

8 1000
21120020
2 1
4 2
5 7
4 3
6 8
5 2
6 4
4 1
6 1
2 1
2 3
3 2
4 1
2 1
4 6
2 1
4 4
1 2
6 5
8 5
3 6
4 1
5 7
8 1
6 4
1 4
7 7
8 4
2 3
4 7
1 2
5 1
5 1
2 8
7 7
4 7
2 1
1 3
6 1
2 1
7 2
5 6
5 6
3 5
2 8
3 5
7 2
6 1
6 1
1 6
1 4
6 8
2 8
3 5
1 7
1 8
2 4
6 8
4 8
4 6
3 1
7 3
6 6
3 7
1 4
4 3
5 4
5 8
3 2
2 6
5 8
...

output:

Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Alice 3
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
...

result:

ok 1000 lines

Test #3:

score: 7
Accepted
time: 2ms
memory: 12932kb

input:

8 1000
12110101
8 4
2 6
7 5
8 1
1 6
7 3
2 5
8 7
4 5
5 8
8 3
5 7
7 7
7 1
8 1
4 3
8 1
3 1
5 4
6 3
6 2
4 2
8 3
5 7
2 5
1 5
3 8
1 2
6 2
4 2
5 3
4 4
3 3
6 3
1 7
6 6
2 8
1 8
6 3
8 1
3 2
3 3
7 1
4 5
7 2
8 4
4 2
2 5
1 1
8 5
6 6
4 1
8 1
4 6
6 7
2 2
6 2
4 1
6 6
5 1
3 5
2 6
5 4
7 7
1 4
8 7
6 2
8 5
8 7
5 4
1 8
...

output:

Alice 3
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Alice 3
Bob
Alice 1
Bob
Bob
Alice 1
Alice 3
...

result:

ok 1000 lines

Test #4:

score: 7
Accepted
time: 0ms
memory: 13252kb

input:

8 1000
10100100
3 8
8 6
1 8
7 8
8 5
4 8
2 8
8 8
4 1
2 2
5 7
5 8
5 3
8 4
5 1
1 5
5 1
8 2
6 7
2 3
8 3
7 8
5 7
3 7
4 4
1 2
7 5
3 7
5 1
3 6
1 5
6 7
1 8
4 1
7 6
1 4
4 6
7 8
8 4
2 4
3 7
2 8
8 4
5 3
4 1
2 5
3 3
6 6
4 1
3 6
8 6
5 3
7 3
3 6
2 2
4 6
2 4
7 3
8 4
1 4
3 2
3 2
5 2
2 2
6 2
6 7
8 7
3 6
1 8
2 1
4 2
...

output:

Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Alic...

result:

ok 1000 lines

Test #5:

score: 7
Accepted
time: 0ms
memory: 13564kb

input:

8 1000
21010212
3 7
8 3
4 1
3 6
2 1
5 3
3 1
3 8
6 2
3 5
5 7
6 2
6 2
3 8
1 4
2 7
7 8
8 8
1 8
7 1
2 5
3 5
8 3
6 1
7 2
4 8
5 6
8 8
7 8
6 3
3 4
7 7
4 1
8 6
2 4
2 7
7 5
4 3
2 7
5 1
8 4
2 2
6 8
6 5
8 1
5 5
6 6
8 6
2 5
4 3
3 2
2 3
4 7
1 8
5 6
8 6
1 1
4 2
7 3
8 1
2 5
8 4
1 2
5 3
7 2
4 6
4 3
7 6
2 3
2 2
8 8
...

output:

Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Alice 3
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
...

result:

ok 1000 lines

Test #6:

score: 7
Accepted
time: 2ms
memory: 13540kb

input:

8 1000
21101220
2 7
5 3
2 6
4 5
1 4
8 2
4 8
5 1
6 3
4 2
2 6
3 7
1 8
6 4
1 1
4 3
4 3
8 8
7 5
4 4
4 2
1 3
8 7
1 5
5 8
6 8
2 3
7 4
6 3
2 6
8 6
4 6
2 8
3 1
1 6
5 7
7 4
6 6
2 8
6 5
2 4
1 2
6 7
5 5
8 5
7 2
4 3
6 3
5 4
7 4
1 6
7 5
8 6
4 4
8 8
5 8
4 7
5 7
8 3
4 1
7 6
6 2
6 6
2 4
6 7
4 3
5 6
3 7
6 6
3 5
4 7
...

output:

Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
...

result:

ok 1000 lines

Test #7:

score: 7
Accepted
time: 0ms
memory: 13160kb

input:

8 1000
12221101
5 7
3 1
1 7
7 6
2 6
1 8
5 4
7 4
3 3
5 8
7 4
4 6
1 2
7 8
7 1
6 8
2 7
4 8
7 6
8 3
6 3
5 1
6 2
1 7
7 7
2 5
6 6
4 6
4 4
4 3
8 3
1 8
8 2
5 6
4 3
8 8
4 4
5 6
4 6
4 4
7 1
6 4
1 6
4 8
4 3
1 1
4 3
3 3
3 3
6 6
6 7
1 7
5 2
6 4
7 1
6 4
4 1
3 5
1 5
5 4
8 1
6 1
5 1
6 8
2 3
7 1
3 8
1 8
3 7
8 6
6 3
...

output:

Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alic...

result:

ok 1000 lines

Test #8:

score: 7
Accepted
time: 2ms
memory: 14216kb

input:

8 1000
21001110
2 8
1 6
2 3
4 3
6 7
7 8
4 5
5 7
1 5
6 7
7 3
4 4
1 4
3 1
3 7
7 6
5 4
2 4
3 7
1 2
3 1
7 3
2 7
1 6
8 1
1 5
7 4
4 6
8 1
3 5
6 4
6 8
8 5
4 1
3 2
4 8
6 3
7 7
5 5
3 4
7 8
2 2
8 1
1 8
8 1
2 8
1 3
2 1
4 2
3 6
5 1
3 5
3 1
4 1
1 6
2 1
8 2
8 7
3 1
3 1
1 4
5 3
6 6
3 2
2 2
8 3
8 2
8 2
1 1
5 3
7 3
...

output:

Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 3
Alice 1
Alice 2
Alice 2
Alice 3
Bob
Alice 2
Bob
Alice 2
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Alice 2
Alice 1
Bob
...

result:

ok 1000 lines

Test #9:

score: 7
Accepted
time: 2ms
memory: 13244kb

input:

10 1000
8402982536
9 10
2 6
3 1
5 9
8 1
6 7
9 4
3 10
9 6
9 1
7 7
3 3
3 3
4 2
2 3
9 2
5 3
5 5
4 7
6 6
8 10
1 5
1 8
9 7
7 2
8 7
9 3
9 7
7 6
6 7
6 10
8 8
9 6
10 4
2 2
4 8
10 6
7 7
9 10
2 2
1 3
9 7
2 3
1 4
5 7
6 3
7 7
3 2
1 2
10 6
7 3
1 5
6 1
10 6
6 4
3 1
5 4
7 4
4 2
3 10
9 7
6 3
7 8
8 6
1 4
7 7
4 7
1 7...

output:

Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 5
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 5
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 5
Alice 5
Bob
Bob
Alice 1
Alice 5
Alice 1
Alice 3
Alice 5
Alice 5
Alice 3
...

result:

ok 1000 lines

Test #10:

score: 7
Accepted
time: 0ms
memory: 14108kb

input:

10 1000
0069433911
2 8
4 6
4 7
3 9
4 3
5 2
9 8
6 1
10 3
1 7
9 4
9 3
2 3
1 9
1 6
4 10
9 8
10 8
9 7
9 4
2 1
5 2
9 10
3 9
9 9
10 2
5 7
8 4
5 2
8 10
1 2
1 10
2 8
9 5
3 2
1 4
6 4
5 3
7 6
5 7
3 9
1 7
3 3
9 10
7 6
5 3
8 4
7 8
9 3
5 9
10 6
2 1
7 10
5 2
7 7
5 7
10 10
4 9
5 9
7 7
9 10
5 6
6 6
7 5
3 1
9 8
3 9
...

output:

Alice 1
Alice 3
Bob
Bob
Alice 5
Bob
Alice 3
Bob
Alice 1
Bob
Alice 3
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Alice 1
Alice 2
Alice 5
Bob
Bob
Bob
Alice 3
Bob
Alice 5
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 5
Alice 1
Alice 2
Bob
Bob
Bob
Alice 2
Bob
Bob
Alice 1
Alic...

result:

ok 1000 lines

Test #11:

score: 7
Accepted
time: 2ms
memory: 13012kb

input:

10 1000
2402249289
8 6
9 7
8 4
9 2
5 1
1 4
3 10
2 3
7 6
8 6
5 6
5 10
7 4
9 5
10 9
1 1
6 7
8 2
6 3
6 2
9 7
3 3
8 6
9 5
2 10
6 1
3 2
1 4
7 4
7 1
2 3
3 8
4 10
9 6
3 3
5 10
6 1
3 8
1 6
4 6
7 2
7 5
3 2
5 6
3 8
8 3
3 5
8 9
8 2
9 3
3 2
2 4
4 9
9 8
6 2
8 5
2 6
1 1
9 1
7 10
2 2
3 7
5 6
9 10
4 6
6 9
6 6
5 10
...

output:

Bob
Bob
Alice 1
Alice 3
Bob
Bob
Alice 1
Bob
Alice 2
Alice 2
Alice 1
Bob
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alice 3
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Alice 3
Bob
Alice 2
Bob
Bob
Alice 1
Alice 1
Alic...

result:

ok 1000 lines

Test #12:

score: 7
Accepted
time: 0ms
memory: 13464kb

input:

10 1000
5440855673
5 10
5 6
8 5
7 5
5 3
1 5
5 4
5 9
5 2
10 1
9 10
1 2
4 8
4 2
6 5
8 4
7 4
9 10
10 1
6 10
9 5
5 2
1 10
6 2
3 10
4 1
5 8
10 3
9 8
3 7
10 5
2 10
4 2
9 8
8 1
1 10
5 3
10 4
6 5
5 5
4 10
9 2
5 7
3 3
8 8
2 7
1 8
8 6
8 7
8 10
1 7
7 1
5 10
10 1
7 6
8 3
3 2
6 1
3 1
10 4
8 4
3 3
3 7
10 1
2 3
1 ...

output:

Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Alice 1
Alice 3
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alic...

result:

ok 1000 lines

Test #13:

score: 7
Accepted
time: 2ms
memory: 14120kb

input:

10 1000
2192963407
9 8
2 9
4 1
1 5
9 6
10 1
7 1
1 9
1 3
4 6
9 4
1 7
9 10
7 7
7 10
5 8
2 9
2 1
3 10
8 3
2 7
2 3
2 4
4 7
7 2
5 2
6 8
5 8
2 4
2 2
7 1
7 1
4 5
1 3
10 3
4 7
10 8
6 6
3 9
8 8
9 9
4 1
10 8
5 9
2 2
4 10
2 1
1 1
7 1
3 8
6 8
8 2
7 10
1 7
8 5
8 7
3 8
6 9
1 5
5 5
3 7
5 1
5 7
1 1
1 7
5 10
2 8
8 8...

output:

Alice 3
Bob
Bob
Alice 3
Alice 1
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Bob
Bob
Alice 3
Bob
Bob
Bob
Alice 3
Bob
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 3
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
...

result:

ok 1000 lines

Test #14:

score: 7
Accepted
time: 2ms
memory: 13564kb

input:

10 1000
3386934725
9 6
4 10
7 3
3 2
7 8
5 3
4 7
1 9
9 8
6 10
4 10
8 3
3 8
6 9
9 1
3 4
3 4
8 7
4 6
8 10
5 5
5 1
4 4
9 5
6 8
7 1
7 5
10 4
4 2
10 4
9 8
3 6
5 2
4 5
6 6
5 3
8 1
5 2
3 7
10 1
8 8
2 6
3 6
1 4
9 8
3 8
1 8
5 3
6 10
1 6
9 6
3 5
2 10
5 2
10 1
3 4
4 1
2 9
9 5
4 8
10 3
2 4
6 9
10 7
4 1
4 2
3 6
6...

output:

Bob
Bob
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Alice 5
Bob
Alice 1
Bob
Alice 1
Alice 5
Alice 3
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 5
Alice 3
Bob
Alice 1
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Alice 1
Alice 5
Alice 5
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Bob
Alice 5
Alice 3
Bob
Alice 3
Alice 5
Alic...

result:

ok 1000 lines

Test #15:

score: 7
Accepted
time: 2ms
memory: 14524kb

input:

10 1000
0783411333
9 5
1 4
1 2
3 1
4 10
8 1
3 9
8 6
1 7
3 6
2 5
4 9
2 8
9 9
1 6
4 4
7 9
6 7
5 1
10 8
4 9
7 5
6 9
9 10
7 1
1 4
2 7
1 10
7 6
6 4
8 5
8 6
2 7
8 4
5 8
1 9
5 7
2 4
1 3
1 1
8 7
1 10
9 4
3 8
4 10
7 8
10 10
7 8
5 5
10 10
2 8
1 1
7 1
5 9
9 1
5 7
3 6
10 5
7 4
8 1
1 5
9 1
4 1
9 3
9 7
9 7
4 9
6 ...

output:

Bob
Alice 5
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 5
Alice 2
Alice 1
Bob
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 3
Alice 1
Alice 2
Alice 3
Alice 5
Alice 3
Bob
Alice 1
Alice 3
Bob
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 3
...

result:

ok 1000 lines

Test #16:

score: 7
Accepted
time: 0ms
memory: 13476kb

input:

10 1000
4318437248
3 6
10 9
7 8
2 8
1 5
7 3
4 1
9 2
8 5
3 2
2 4
8 5
9 8
9 3
2 4
10 5
1 10
9 6
7 5
1 3
2 9
1 3
10 5
3 5
1 2
10 2
5 5
2 2
6 3
5 3
3 7
9 2
6 8
8 9
3 4
1 6
3 2
3 2
1 5
2 10
3 4
10 9
7 8
5 5
5 5
9 2
4 7
3 9
6 1
7 10
1 2
9 7
5 2
9 5
6 1
5 4
3 9
3 3
10 7
6 7
10 5
9 4
5 3
3 1
3 3
9 2
5 7
6 8...

output:

Bob
Bob
Bob
Alice 3
Alice 5
Bob
Alice 2
Alice 2
Alice 1
Alice 3
Bob
Bob
Bob
Alice 2
Bob
Alice 3
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 3
Alice 5
Alice 5
Bob
Bob
Alice 1
Alice 3
Alice 5
Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 5
Alice 5
Alice 5
Alice 3
Bob
Alice 3
Alice 1
Alice 5
Bob
Alice 5
...

result:

ok 1000 lines

Subtask #2:

score: 13
Accepted

Test #17:

score: 13
Accepted
time: 29ms
memory: 14744kb

input:

480 20000
32012301130203122211230023310322103223212113200231311033220010333333321311120012223103131311311301133221302321303010010022110030012100331300310310311022022323203133200022232131230000211133110313130331312231301200120332012021021132321030321120330201330112231031300132223110203123333321033013...

output:

Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 2
Alice 2
Alice 1
Alice 4
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
...

result:

ok 20000 lines

Test #18:

score: 13
Accepted
time: 59ms
memory: 15024kb

input:

500 20000
73687348165015627904416892848753049277736455324346250540516375277947857861973194207059437453784014238783781479748334028755967119529784157735609134344453271739463723221429334773709757461340229620064198948768302403565379630679235113271028908928419462143360342711694298852690722169197788083620...

output:

Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 3
Alice 2
Alice 3
Alice 2
Alice 1
Alice 2
Alice 1
Alice 3
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Alice 2
Alice 2
Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Alice 2
Alice 1
...

result:

ok 20000 lines

Subtask #3:

score: 12
Accepted

Dependency #2:

100%
Accepted

Test #19:

score: 12
Accepted
time: 51ms
memory: 17156kb

input:

2900 20000
4141100311441022141004021100422204333020421404142000021040413142102014130414141343213023410222003014133204210013013312214421010201202231032034141334413222133200331424424033310242341021230001103432022431243131313312334000202130304142220121434012122232402403340002143234321441304320413214214...

output:

Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Alice 1
Alice 1
Bob
Alice 2
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 2
Alice 1
Bob
...

result:

ok 20000 lines

Test #20:

score: 12
Accepted
time: 117ms
memory: 17972kb

input:

3000 20000
0632646244233053883653005902095690349866815175579636899613527485536586407428380999423236264050013980205742691453835142820657794940427740023522125242887874701190042600813771108844757657136827100662657033479283859173358522259944337315076287587724207344864952582542839573938367304692884891988...

output:

Bob
Alice 2
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Alice 3
Alice 2
Alice 1
Bob
Bob
Alice 2
Bob
Alice 1
Alice 3
Alice 2
Alic...

result:

ok 20000 lines

Subtask #4:

score: 19
Accepted

Dependency #3:

100%
Accepted

Test #21:

score: 19
Accepted
time: 618ms
memory: 49732kb

input:

49000 100000
01023213304220000331213311230202011441012123004001030133104430442321203014010201400203431331230331121033312443112103302201330131221321212410313022210413142421100301313021132032220012203434402133300323421110033440400111441044234320123340033222442012103044043422420113001121033032014004014...

output:

Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 2
Bob
...

result:

ok 100000 lines

Test #22:

score: 19
Accepted
time: 1501ms
memory: 67216kb

input:

50000 100000
28389295275554509470597994895319759760941267257897055842298078178986380422073104189201510046554719704690426374041857717076905776680508059522444566764985590363287700638676939048897823271225995386225345535104415608407773286763759702247029533606363850114135108326528698187966786409003286200...

output:

Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 2
Bob
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Alice 1
...

result:

ok 100000 lines

Subtask #5:

score: 24
Accepted

Test #23:

score: 24
Accepted
time: 53ms
memory: 17736kb

input:

19000 20000
102021210212211220210110112221121210201110111120112111122211020121110112100120010111010011110122211022001210202111112120211102021001200110111001202011100212112112002221022112021122001001120010111210011110021012122000122022020101201022011202011221021202120100112220021112201022221220120100...

output:

Alice 2
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 1
Alice 2
Alice 3
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alic...

result:

ok 20000 lines

Test #24:

score: 24
Accepted
time: 43ms
memory: 16092kb

input:

19000 20000
001212200001011122012011201101022022120020112102112221002010112210011012212002020222010210221011120222210021001022000010020011111212122200110220122000120010101101001010202102210000022201120020020200201010022211211210002111110021200100010102111101100120022110101201200000120020002200020012...

output:

Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 2
Bob
Bob
Bob
Bob
Alice 2
Alice 2
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
...

result:

ok 20000 lines

Test #25:

score: 24
Accepted
time: 63ms
memory: 20664kb

input:

19000 20000
101001001010112210021021102021111020202220000001222002021012021201101222210110211101021022201120112010202221210022211112221210101021201012020112100121012210111000012221120121101221020001210021221122112211110200122222020202001221022001221101221100002120112222102101212012210222001201120210...

output:

Alice 1
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
...

result:

ok 20000 lines

Test #26:

score: 24
Accepted
time: 26ms
memory: 17856kb

input:

19000 20000
122201222212000201120212010200121110102111211200221110212100220001110200012022210120022022220122202110120121112220010110110011020021001002021212000112201000022012110111000111021002201222210021210212220102010010211020110002121202011111021002100002220122212101111221121000210101110002101120...

output:

Alice 3
Bob
Bob
Alice 3
Alice 1
Alice 1
Bob
Alice 3
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Bob
Alice 1
Alice 3
Bob
Alice 3
Bob
Alice 3
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Bob
Alice 1
Alice 3
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Bob
Bob
Bob
...

result:

ok 20000 lines

Test #27:

score: 24
Accepted
time: 38ms
memory: 19232kb

input:

19000 20000
210021212112211001001212101200220200121022201102020101011111100020102121122122020021101220020211012122111122102221011201100021012011120102112211222211221221202012200001202222211002110220202211020002211020211210122120110100012021211022022002020221001021011111200222101211002022010102112202...

output:

Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 3
Bob
Alice 2
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Bob
Bob
...

result:

ok 20000 lines

Test #28:

score: 24
Accepted
time: 37ms
memory: 17684kb

input:

19000 20000
012212100211022001111000121220221220210020210221012010201222011020022201120000112110212120210201121001221202121122010122020220111201222000121202020212212121220210212111211110222110002220220012112012010010011002102011020121101202001121002102122021000122212001200012222010000200000202020122...

output:

Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 1
Bob
Alice 2
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 3
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Alic...

result:

ok 20000 lines

Test #29:

score: 24
Accepted
time: 55ms
memory: 20860kb

input:

19000 20000
111020221220022022221212012102200011221010000021201210001022200012211002110110220212111120100212221011201020200200001020000212002122222010210101212120102010112012001212201201120211012220121200022210022111221201221021020222211210121211011011121201122210202022122000221011201111221021202211...

output:

Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Bob
Bob
Alice 2
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 3
...

result:

ok 20000 lines

Test #30:

score: 24
Accepted
time: 57ms
memory: 19068kb

input:

19000 20000
212121011100020120011010212001210001121102220220010111022221000011101120222200012000100002000021022122001202222112202110012011000220010202121111211011000222211201000120220212200220212220210221212100022121122220112222212010111012111110121020112020120110222220002211010002101210011220000112...

output:

Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 2
Alice 2
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 2
Alice 1
Alice 2
Bob
Alic...

result:

ok 20000 lines

Test #31:

score: 24
Accepted
time: 107ms
memory: 18944kb

input:

20000 20000
122040040244103312230142440114443123421301104124042200130230204043422223112114232243020034024024322422423413343311333104311230002132040410041440432143434114042314012334111343243441433021424013322424314203133241022111220012211101323433302021212000422313330200303231312343303003231330233431...

output:

Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 4
Alice 3
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
...

result:

ok 20000 lines

Test #32:

score: 24
Accepted
time: 65ms
memory: 18136kb

input:

20000 20000
103042110023010301132120302120220234202044140131034402431230030404113121031342432313013003201002021000141003022210122430220102201334441420244312223410030323302442430142314140024440044022343111301230414123314102034201133030232441441041244114222010144341210411104020140342410024014004011003...

output:

Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 2
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Alice 1
Alice 4
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Bob
Alice 2
Bob
Alic...

result:

ok 20000 lines

Test #33:

score: 24
Accepted
time: 112ms
memory: 22904kb

input:

20000 20000
032042014243202311132010423311310141420000204331010143142242434420121341344434204233404304043402423034014001042410343304302300030130131321231333401010423302331443014222112403441202241010421332323444332113344104224430111223324211204323210302023234143232434141243410331013212322434433133132...

output:

Alice 2
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Alice 2
Bob
Alice 2
Alice 1
Bob
Bob
Bob
Alice 2
Alice 1
Bob
Bob
Bob
Alice 2
Bob
Bob
Bob
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Bob
Alice 1
Alic...

result:

ok 20000 lines

Test #34:

score: 24
Accepted
time: 41ms
memory: 18864kb

input:

20000 20000
342412301031234340421203301204300224204141110202003030421243112043234334422333444222111222412043202100212021334240313420000224222401220431001124433402313000012110410143104412312222224114030220314010130111040403241423013132034243131112223340101102131023210420420033432222133214403304121403...

output:

Alice 1
Bob
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Bob
Alice 1
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Bob
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Alice 1
...

result:

ok 20000 lines

Test #35:

score: 24
Accepted
time: 47ms
memory: 18672kb

input:

20000 20000
301222212241221113302144432111042342424100042212330024130323242433301240410303221033130110041012302144210204213233203214023331423222230232414020024111300033201223121021433040120212000310030224002011414032143022020311100404104022232410124040341420134033120322042233422214110403320024032344...

output:

Alice 1
Bob
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Bob
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Bob
Bob
...

result:

ok 20000 lines

Test #36:

score: 24
Accepted
time: 95ms
memory: 20108kb

input:

20000 20000
340303430120122112023131443104134024123341230440041044132120330342023424132243001420203410302114433240321200010441010143212404204330241240141200313104414140320421421221132140044043222130302202312010432140441421032032143020412034201123244122131331204120124320040024023224412302203212343344...

output:

Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 2
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
...

result:

ok 20000 lines

Test #37:

score: 24
Accepted
time: 75ms
memory: 20712kb

input:

20000 20000
231311434332214340400012211401443124334122440434340441023401241300121310113013124412304022232301130033213341120121021144423431040133142203204031131040213022132433403203133241331443321302223231031410143041214243122430123444022340043143322003033421200034144033302434322443244341432011023001...

output:

Alice 3
Alice 2
Alice 3
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Bob
Alice 1
Bob
Alice 1
Alice 3
Bob
Bob
Bob
Alice 1
Alice 3
Alice 2
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
...

result:

ok 20000 lines

Test #38:

score: 24
Accepted
time: 131ms
memory: 19200kb

input:

20000 20000
033112233132001144414022313432103213143440024123402410032310032031302040430441433431000341213024422212324343124334443031432200431134234224220301223412443034243044134010234313030112330431324412213210314241023000130432014244412133422431243041242030112240114114320422324022431333324014041203...

output:

Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 1
Bob
Bob
Bob
Alice 2
Alice 1
Alice 2
Alice 2
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 3
Bob
Bob
Alice 1
Bob
Alice 2
Alice 3
Bob
Bob
Bob
Alice 3
Bob
Alice 2
Bob
Alice 2
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alic...

result:

ok 20000 lines

Subtask #6:

score: 25
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #39:

score: 25
Accepted
time: 469ms
memory: 35680kb

input:

49000 100000
44344304234013323112013232104112310431100104433113242444303323133000044231121001323211432322402240141133210311003021330042412111202313312000021300341302402104204313211323442413333420321103213213141431203143112404310033010312024020121414144022221300431244022312144103333211041140320011313...

output:

Alice 3
Alice 2
Alice 3
Alice 1
Alice 3
Alice 1
Alice 2
Alice 4
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 2
Bob
Alice 3
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 2
Alice 4
Bob
...

result:

ok 100000 lines

Test #40:

score: 25
Accepted
time: 406ms
memory: 28928kb

input:

49000 100000
12334203112402241402042211341441120304324122334313041231144400102103121223344042421441044213024031423331240001104142021241003440012430033202344131033224024431341222312420320303443122044100130302033120024433021121423200314413224301000424034044421113341143030440204232032211432043201040231...

output:

Alice 2
Bob
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Alice 2
Bob
Bob
Bob
Alice 1
Alice 1
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 2
Bob
Alice 1
Bob
Bob
...

result:

ok 100000 lines

Test #41:

score: 25
Accepted
time: 560ms
memory: 44000kb

input:

49000 100000
22040403244230023240140222430100003030013231413430444033013242112440233434221320444142423021111434404014223421232102413241001424112410130004043244241311421331414031304020121343010331040103041021230323244033441111003344420221214220022303222222144224120232320134410043342131014421120011204...

output:

Bob
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Bob
Bob
Alice 2
Alice 2
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Alice 2
Alice 3
Bob
Bob
Alice 1
Bob
...

result:

ok 100000 lines

Test #42:

score: 25
Accepted
time: 184ms
memory: 30952kb

input:

49000 100000
00431430440123000030414142311202030243204333423300211310223400310231341223024343203012202444033321421220142203312314231034130014310213002433212231430011440314030300131020104130000001020024413343000443221311412101142223324334341030013101004123234313402404022031140302310423220424130224422...

output:

Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Alice 3
Bob
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 3
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Alice 3
Alice 3
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alic...

result:

ok 100000 lines

Test #43:

score: 25
Accepted
time: 219ms
memory: 32588kb

input:

49000 100000
30234331131414312340303403024400113030243324300440112433344222324131120113312201223144414101040232223342014434404341430001022321331344111234241211343222042410312443112320120300212300214303004342410240013120211140144130321300410234224430341324244201012101403012043143101430024433003130312...

output:

Alice 1
Alice 3
Alice 3
Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 3
Bob
Alice 3
Alice 3
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 3
Alice 1
Alice 3
...

result:

ok 100000 lines

Test #44:

score: 25
Accepted
time: 456ms
memory: 33320kb

input:

49000 100000
12300131241002334223001002133241233020302010032334430140134220130143430133033142141100043313023114021200023110031200333140434331422104104022110404340120110302141033222130414344013400232034433344432130002124020113244100410211023403234204121132020333213034333222102000342321342442401304324...

output:

Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Alice 2
Alice 1
Alice 3
Alice 1
Bob
Alice 2
Alice 2
Bob
Alice 3
Bob
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Alice 2
Bob
Alice 2
Alice 3
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alic...

result:

ok 100000 lines

Test #45:

score: 25
Accepted
time: 468ms
memory: 41284kb

input:

49000 100000
32423201134220013011443440342243341340012024103432302342200443444440440133310024302423140100202401404103120132033423413242131443111230031101133424210243324414241303133120121233200324413440412024032112332413332002243301214444201100313140302344413234213241422214021202030212313341443113020...

output:

Alice 1
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 4
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Alice 1
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alic...

result:

ok 100000 lines

Test #46:

score: 25
Accepted
time: 648ms
memory: 36860kb

input:

49000 100000
03430322244101002314013110113433304021344224223040003012032334234413200121142304224130342301140032431141230124242334143410213030342140120303302204214031202024304014021311120202344441111112214144321212244223303000233320244133021331104120313120031023430210103413422203011432331424421043111...

output:

Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 2
Alice 2
Alice 3
Bob
Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 2
Bob
Bob
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 2
Alic...

result:

ok 100000 lines

Test #47:

score: 25
Accepted
time: 1844ms
memory: 70972kb

input:

50000 100000
41469402892856288847143622096526154430711506024592621224250665670589886799055712412767877447024342805760868278585714139039219581918284580209996705719191117734423250225312365389063887110584070828466227656537031103910550357032933688391981836157181600199922714786625099595689132004921267731...

output:

Alice 3
Alice 1
Alice 2
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 3
Alice 4
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 3
Bob
Bob
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Alice 4
Alice 2
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alic...

result:

ok 100000 lines

Test #48:

score: 25
Accepted
time: 815ms
memory: 32516kb

input:

50000 100000
11865236105525638025450753567662408874839720373357296130202499648922182856711967053996235798835957166020568903128611644629449362918814286646529702262545419076422470672309642712190488512718240963801282717745145940463034015168816814946466408374946805073868041811076784260404862312201570474...

output:

Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 2
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Alice 3
Alice 1
Alice 1
Alice 4
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Alice 3
Alice 2
Bob
Alice 1
Alice 1
Bob
Alice 2
...

result:

ok 100000 lines

Test #49:

score: 25
Accepted
time: 1369ms
memory: 60848kb

input:

50000 100000
95791805558433242901730123925290382126441257842394948855116220826708749127436521411648043400328895423785265719141375893099305149648223634093981998174444749252404042459200916217116896792954792027925096924195484337827186259268671783621340464833865710277793814768563333947092183303340134957...

output:

Alice 1
Bob
Bob
Bob
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Alice 3
Alice 2
Alice 1
Bob
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 2
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 4
Alice 1
Alice 2
Alice 1
Bob
Bob
Alic...

result:

ok 100000 lines

Test #50:

score: 25
Accepted
time: 206ms
memory: 31760kb

input:

50000 100000
70268630453970609470081174370346734791021955916959002631950179222499310204430721681437673209780591437436627361459598465195231975548186808693759894224415731951058192158278443737072147033171612250085310825742591653595219677566957959807552678754589099917647798406892867612523421393692712048...

output:

Alice 3
Alice 3
Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Alice 1
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 3
Alice 3
Alice 3
Alice 3
Alic...

result:

ok 100000 lines

Test #51:

score: 25
Accepted
time: 244ms
memory: 33988kb

input:

50000 100000
87155569333392685251947463630455773945301750656190842742541929645395304199289870767768109538853071791546490916631060850465302220101065354985752737472890367830675943654261039579726436880901178543855772927164050009575855044882308998785248941893362797284655251887963668453327461073373282848...

output:

Alice 1
Bob
Bob
Bob
Bob
Alice 3
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Alice 3
Bob
Bob
Bob
Alice 3
...

result:

ok 100000 lines

Test #52:

score: 25
Accepted
time: 1893ms
memory: 64660kb

input:

50000 100000
44419020988909849128380660219815265098033185605780321578129831190849711514462258377178525731026888859989582246441712466828929576002835376645951508059710740353811314953067769912398478352454113400287419557733259646551170816588197320966228388102712967302793851052620500568593214040910118507...

output:

Alice 2
Bob
Bob
Alice 4
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 3
Alice 3
Alice 2
Alice 2
Bob
Alice 1
Bob
Alice 3
Alice 2
Bob
Alice 3
Bob
Alice 2
Alice 2
Alice 2
Bob
Alice 2
Alice 3
Alice 1
Alice 2
Alice 1
Alice 3
Alice 3
Bob
Alic...

result:

ok 100000 lines

Test #53:

score: 25
Accepted
time: 1045ms
memory: 58532kb

input:

50000 100000
99015175527161039711968308158970401111186859450515996867236884760481432211517725200133986977826853926132487154132411695127231398362005404031697446152212085146898544662653330395884300461721426324950097687328156545596739137847482582859122599355791463215213743774816441008120370170744664085...

output:

Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 3
Alice 2
Alice 3
Alice 1
Alice 2
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 5
Alice 1
Alice 3
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alic...

result:

ok 100000 lines

Test #54:

score: 25
Accepted
time: 2604ms
memory: 78544kb

input:

50000 100000
05034210319141086175468297740092605715584081891367533616727739984122457828829167650055213173196536176507535633569140088468486836787253623935206504598955495351850464934785686726789538927885557993298322739505161908747127297945313771753354416257942712612472906096556599052477671977401135599...

output:

Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Bob
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Bob
Alice 2
Alice 3
Bob
Bob
Alice 2
Alice 2
Bob
...

result:

ok 100000 lines