QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#785376#9645. 字符游戏zhouhuanyi100 ✓2639ms140664kbC++175.4kb2024-11-26 17:41:492024-11-26 17:41:49

Judging History

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

  • [2024-11-26 17:41:49]
  • 评测
  • 测评结果:100
  • 用时:2639ms
  • 内存:140664kb
  • [2024-11-26 17:41:49]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<bitset>
#define N 200000
#define M 1000000
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int n,q,dfn[N+1],rev[N+1],leng,lengths,ST[N+1][21],lg[N+1],delta[N+1],tong[N+1],length,pst[N+1],num[N+1][10],sfa[N+1][21],rt[N+1],sz[N+1],belong[N+1],fa[N+1],depth[N+1];
char c[N+1];
bool used[N+1];
vector<int>E[N+1];
unordered_map<int,int>dp[N+1];
struct reads
{
	int x,y,data;
	bool operator < (const reads &t)const
	{
		if (data!=t.data) return data<t.data;
		else if (x!=t.x) return x<t.x;
		else return y<t.y;
	}
};
reads tongs[M+1];
void add(int x,int y)
{
	E[x].push_back(y),E[y].push_back(x);
	return;
}
void dfs(int x)
{
	dfn[x]=++leng,rev[dfn[x]]=x,sz[x]=1,num[x][c[x]-'0']=x,tong[++length]=dfn[x],pst[x]=length;
	for (int i=0;i<E[x].size();++i)
		if (!dfn[E[x][i]])
		{
			for (int j=0;j<=9;++j) num[E[x][i]][j]=num[x][j];
			fa[E[x][i]]=x,depth[E[x][i]]=depth[x]+1,dfs(E[x][i]),sz[x]+=sz[E[x][i]],tong[++length]=dfn[x];
		}
	return;
}
bool LENG(int x,int y)
{
	return dfn[x]<=dfn[y]&&dfn[y]<=dfn[x]+sz[x]-1;
}
int find(int x)
{
	if (rt[x]==x) return x;
	int y=find(rt[x]);
	delta[x]^=delta[rt[x]];
	return rt[x]=y;
}
void unionn(int x,int y,int z)
{
	rt[x]=y,delta[x]=z;
	return;
}
int lca(int x,int y)
{
	x=pst[x],y=pst[y];
	if (x>y) swap(x,y);
	int lw=lg[y-x+1];
	return rev[min(ST[x][lw],ST[y-(1<<lw)+1][lw])];
}
int calc(int x)
{
	find(x);
	return delta[x];
}
int solve(int x,int y)
{
	return calc(y)^calc(x);
}
int get(int x,int d)
{
	for (int i=lg[n<<1];i>=0;--i)
		if (depth[sfa[x][i]]>=d)
			x=sfa[x][i];
	return x;
}
int query(int x,int y)
{
	if (dfn[x]>dfn[y]) swap(x,y);
	if (x==fa[y]||x==y) return 0;
	if (dp[x].find(y)!=dp[x].end()) return dp[x][y];
	int sx,sy,tx,ty,res;
	bitset<16>used;
	used.set();
	if (LENG(x,y))
	{
		for (int i=0;i<=9;++i)
			if (depth[num[fa[y]][i]]>depth[x])
				sy=num[fa[y]][i],sx=get(sy,depth[x]+1),res=solve(sx,sy)^query(x,sx)^query(sy,y),used[res]=0;
	}
	else
	{
		int z=lca(x,y);
		for (int i=0;i<=9;++i)
			if (depth[num[fa[x]][i]]>=depth[z]||depth[num[fa[y]][i]]>=depth[z])
			{
				if (depth[num[fa[x]][i]]>=depth[z]&&depth[num[fa[y]][i]]>=depth[z])
				{
					sy=num[fa[x]][i],sx=get(sy,depth[z]);
					ty=num[fa[y]][i],tx=get(ty,depth[z]);
					res=solve(sx,sy)^solve(tx,ty)^query(sy,x)^query(sx,tx)^query(ty,y),used[res]=0;
				}
				else if (depth[num[fa[x]][i]]>=depth[z])
				{
					sy=num[fa[x]][i],sx=get(sy,depth[z]);
					res=solve(sx,sy)^query(sy,x)^query(sx,y),used[res]=0;
				}
				else
				{
					sy=num[fa[y]][i],sx=get(sy,depth[z]);
					res=solve(sx,sy)^query(sy,y)^query(sx,x),used[res]=0;
				}
			}
	}
	res=used._Find_first();
	return dp[x][y]=res;
}
int query2(int x,int y)
{
	if (dfn[x]>dfn[y]) swap(x,y);
	int sx,sy,tx,ty,res,cnt=0;
	if (LENG(x,y))
	{
		for (int i=0;i<=9;++i)
			if (depth[num[fa[y]][i]]>depth[x])
			{
				sy=num[fa[y]][i],sx=get(sy,depth[x]+1),res=solve(sx,sy)^query(x,sx)^query(sy,y);
				if (!res) cnt++;
			}
	}
	else
	{
		int z=lca(x,y);
		for (int i=0;i<=9;++i)
			if (depth[num[fa[x]][i]]>=depth[z]||depth[num[fa[y]][i]]>=depth[z])
			{
				if (depth[num[fa[x]][i]]>=depth[z]&&depth[num[fa[y]][i]]>=depth[z])
				{
					sy=num[fa[x]][i],sx=get(sy,depth[z]);
					ty=num[fa[y]][i],tx=get(ty,depth[z]);
					res=solve(sx,sy)^solve(tx,ty)^query(sy,x)^query(sx,tx)^query(ty,y);
					if (!res) cnt++;
				}
				else if (depth[num[fa[x]][i]]>=depth[z])
				{
					sy=num[fa[x]][i],sx=get(sy,depth[z]);
					res=solve(sx,sy)^query(sy,x)^query(sx,y);
					if (!res) cnt++;
				}
				else
				{
					sy=num[fa[y]][i],sx=get(sy,depth[z]);
					res=solve(sx,sy)^query(sy,y)^query(sx,x);
					if (!res) cnt++;
				}
			}
	}
	return cnt;
}
int main()
{
	int x,y,res;
	for (int i=2;i<=N;++i) lg[i]=lg[i>>1]+1;
	n=read(),q=read();
	for (int i=1;i<=n;++i) cin>>c[i],c[i+n]='0';
	for (int i=1;i<=n;++i) add(i,i+n);
	for (int i=1;i<=(n<<1);++i) rt[i]=i;
	for (int i=1;i<=n-1;++i) x=read(),y=read(),add(x,y);
	depth[1]=1,dfs(1);
	for (int i=1;i<=length;++i) ST[i][0]=tong[i];
	for (int i=1;i<=lg[length];++i)
		for (int j=1;j+(1<<i)-1<=length;++j)
			ST[j][i]=min(ST[j][i-1],ST[j+(1<<(i-1))][i-1]);
	for (int i=0;i<=9;++i)
		for (int j=i;j<=9;++j)
		{
			for (int k=1;k<=(n<<1);++k) used[k]=(c[k]-'0'==i||c[k]-'0'==j);
			for (int k=1;k<=(n<<1);++k)
			{
				x=rev[k];
				if (used[x])
				{
					if (belong[fa[x]])
					{
						if (i==j) sfa[x][0]=belong[fa[x]];
						tongs[++lengths]=(reads){belong[fa[x]],x,depth[x]-depth[belong[fa[x]]]};
					}
					belong[x]=x;
				}
				else belong[x]=belong[fa[x]];
			}
		}
	for (int i=1;i<=lg[n<<1];++i)
		for (int j=1;j<=(n<<1);++j)
			sfa[j][i]=sfa[sfa[j][i-1]][i-1];
	sort(tongs+1,tongs+lengths+1);
	for (int i=1;i<=lengths;++i)
		if (i==1||tongs[i].x!=tongs[i-1].x||tongs[i].y!=tongs[i-1].y)
		{
			res=query(tongs[i].x,tongs[i].y);
			if (c[tongs[i].x]==c[tongs[i].y]) unionn(tongs[i].y,tongs[i].x,res);
		}
	for (int qt=1;qt<=q;++qt)
	{
		x=read(),y=read();
		if (x==y) puts("Alice 1");
		else
		{
			query2(x+n,y+n);
			if (query(x+n,y+n)) printf("Alice %d\n",query2(x+n,y+n));
			else puts("Bob");
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 3ms
memory: 30740kb

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: 3ms
memory: 31396kb

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: 6ms
memory: 28912kb

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: 3ms
memory: 31132kb

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: 3ms
memory: 31392kb

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: 0ms
memory: 31060kb

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: 3ms
memory: 29096kb

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: 6ms
memory: 29464kb

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: 3ms
memory: 30808kb

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: 31136kb

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: 0ms
memory: 29356kb

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: 3ms
memory: 29104kb

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: 0ms
memory: 31152kb

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: 3ms
memory: 29108kb

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: 30592kb

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: 32528kb

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: 27ms
memory: 32724kb

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: 57ms
memory: 30732kb

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: 56ms
memory: 34860kb

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: 125ms
memory: 35792kb

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: 683ms
memory: 101140kb

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: 1744ms
memory: 124412kb

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: 109ms
memory: 53620kb

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: 105ms
memory: 52108kb

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: 119ms
memory: 54172kb

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: 72ms
memory: 52256kb

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: 76ms
memory: 49232kb

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: 117ms
memory: 53072kb

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: 115ms
memory: 54888kb

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: 118ms
memory: 53276kb

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: 194ms
memory: 61156kb

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: 164ms
memory: 57504kb

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: 171ms
memory: 57968kb

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: 84ms
memory: 53764kb

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: 88ms
memory: 51620kb

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: 184ms
memory: 59532kb

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: 155ms
memory: 57520kb

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: 201ms
memory: 59012kb

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: 768ms
memory: 99348kb

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: 654ms
memory: 95280kb

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: 727ms
memory: 100640kb

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: 333ms
memory: 92620kb

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: 389ms
memory: 94132kb

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: 720ms
memory: 97852kb

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: 576ms
memory: 99448kb

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: 813ms
memory: 101624kb

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: 2221ms
memory: 137124kb

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: 1654ms
memory: 114300kb

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: 1822ms
memory: 122720kb

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: 363ms
memory: 94488kb

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: 378ms
memory: 90212kb

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: 2253ms
memory: 131472kb

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: 1266ms
memory: 123256kb

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: 2639ms
memory: 140664kb

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