QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#521207#5063. FillominoCrysflyAC ✓392ms106728kbC++176.5kb2024-08-16 00:16:392024-08-16 00:16:39

Judging History

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

  • [2024-08-16 00:16:39]
  • 评测
  • 测评结果:AC
  • 用时:392ms
  • 内存:106728kb
  • [2024-08-16 00:16:39]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000006
#define inf 0x3f3f3f3f

#define y1 __ssd
#define N 1005
int T;
int n,m,c1,c2,c3,x1,y1,x2,y2,x3,y3;
char t1,t2,t3;
int a[N][N];
int dx[5]={0,1,0,-1},dy[4]={1,0,-1,0};

int id[N][N];

struct node{
	int x,y,d,op;
	bool operator <(const node &b)const{
		if(op!=b.op) return op<b.op;
		return d<b.d;
	}
};

int dis[N][N];
bool corner(int x,int y,int nd){
	int s=0,c=0;
	For(d,0,3){
		int xx=(x+dx[d])%n,yy=(y+dy[d])%m;
		if(a[xx][yy]==1) s|=(1<<d),c++;
	}
	if(nd==3)return c==3;
	if(nd==2)return c>=2 && (!(s==5||s==10));
	assert(0);
}

int dfn[maxn],low[maxn],fa[maxn],idx,que[maxn],on[maxn];
vi e[maxn],p[maxn];
int cut[maxn];
bool vis[maxn];
void tar(int u,int pa){
	fa[u]=pa;
	dfn[u]=low[u]=++idx,que[idx]=u;
	int ch=0;
	for(auto v:e[u]){
		if(v==pa)continue;
		if(!dfn[v]){
			tar(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>=dfn[u] && pa) cut[u]=1;
			++ch;
		}
		else low[u]=min(low[u],dfn[v]);
	}
	if(!pa && ch>1) cut[u]=1;
}

int q[maxn],len,tim[maxn];
void dfs(int u){
	vis[u]=1;
	q[++len]=u,tim[u]=len;
	for(int v:p[u]) if(!vis[v]) dfs(v);
}
void bipolar(int n,int s,int t){
//	cout<<"bipolar "<<n<<" "<<s<<" "<<t<<"\n";
	For(i,0,n) dfn[i]=low[i]=fa[i]=cut[i]=vis[i]=on[i]=0,p[i].clear(); 
	idx=0,len=0;
	tar(s,0);
	vi path;
	for(int x=t;x;x=fa[x]) on[x]=1,path.pb(x);
	reverse(ALL(path));
	Rep(i,n,1){
		int u=que[i];
		if(!on[u]) p[fa[u]].pb(u),p[que[low[u]]].pb(u);
	}
	for(int x:path) dfs(x);
}

bool give(int cto){
	For(i,0,n-1)For(j,0,m-1)
		if(a[i][j]==1 && mkp(i,j)!=mkp(x1,y1)){
			For(d,0,3){
				int ii=(i+dx[d])%n,jj=(j+dy[d])%m;
				if(a[ii][jj]==cto){
					a[i][j]=cto;
					return 1;
				}
			}
		}
	return 0;
}

bool vs[N][N],flag;
void DFS(int x,int y){
	vs[x][y]=1;
	For(d,0,4){
		int xx=(x+dx[d])%n,yy=(y+dy[d])%m;
		if(!vs[xx][yy] && a[xx][yy]==a[x][y]) DFS(xx,yy);
	}
}
bool chk(){
//	cout<<"chk\n";
	For(i,0,n-1)For(j,0,m-1)vs[i][j]=0;
	DFS(x1,y1),DFS(x2,y2),DFS(x3,y3);
	For(i,0,n-1)For(j,0,m-1)if(!vs[i][j])return 0;
	return 1;
}
void dfs(int x,int y,int r1,int r2,int r3){
	if(r1<0 || r2<0 || r3<0) return;
	if(flag)return;
//	cout<<"dfs "<<x<<" "<<y<<" "<<r1<<" "<<r2<<" "<<r3<<"\n";
	if(x==n){
		if(chk())flag=1;
		return;
	}
	#define GO dfs(x+(y==m-1),(y+1)%m,r1,r2,r3); if(flag) return;
	if(mkp(x,y)!=mkp(x1,y1) && mkp(x,y)!=mkp(x2,y2) && mkp(x,y)!=mkp(x3,y3)) {
		--r1,a[x][y]=1; GO; ++r1; 
		--r2,a[x][y]=2; GO; ++r2;
		--r3,a[x][y]=3; GO; ++r3;
	}else{
		GO;
	}
}

int vx[N],vy[N];

void work(int O)
{
	n=read(),m=read();
	dx[3]=n-1,dy[2]=m-1;
	c1=read(),c2=read(),c3=read();
	x1=read(),y1=read(),x2=read(),y2=read(),x3=read(),y3=read();
	
//	if(T==51131){
//		if(O==516){
//			cout<<n<<" "<<m<<"\n";
//			cout<<c1<<" "<<c2<<" "<<c3<<"\n";
//			cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<"\n";
//			exit(0);
//		}return;
//	}
	
	--x1,--y1,--x2,--y2,--x3,--y3;
	
	if(n<=3 && m<=3){
		flag=0;
		a[x1][y1]=1,a[x2][y2]=2,a[x3][y3]=3;
		dfs(0,0,c1-1,c2-1,c3-1);
		assert(flag);
		string out=" ABC";
		For(i,0,n-1){
			For(j,0,m-1)putchar(out[a[i][j]]);
			puts("");
		}
		return ;
	}
	
	t1='A',t2='B',t3='C';
	if(c1>c2) swap(c1,c2),swap(x1,x2),swap(y1,y2),swap(t1,t2);
	if(c1>c3) swap(c1,c3),swap(x1,x3),swap(y1,y3),swap(t1,t3);
	
	auto gdis=[&](int x,int y,int xx,int yy){
		return min(abs(x-xx),n-abs(x-xx)) + min(abs(y-yy),m-abs(y-yy));
	};
	
	For(i,0,n-1) For(j,0,m-1) a[i][j]=id[i][j]=0;
	For(i,0,n-1) For(j,0,m-1) 
		dis[i][j]=min(gdis(x2,y2,i,j),gdis(x3,y3,i,j));
		
//	For(i,0,n-1){
//		For(j,0,m-1) cout<<dis[i][j]<<" "; cout<<"\n";
//	}
	
	a[x2][y2]=2;
	a[x3][y3]=3;
	
	For(i,0,n-1) vx[i]=0;
	For(i,0,m-1) vy[i]=0;
	vx[x2]=vx[x3]=1;
	vy[y2]=vy[y3]=1;
	
	priority_queue<node>q;
	q.push((node){x1,y1,dis[x1][y1],5});
	
	bool qwq=0;
	
	for(int xx:{x1})
		if(!qwq && !vx[xx]){
			For(y,0,m-1) q.push((node){xx,(y1+y)%m,-y,4});
			qwq=1; break;
		}
	for(int yy:{y1}){
		if(!qwq && !vy[yy]){
			For(x,0,n-1) q.push((node){(x1+x)%n,yy,-x,4});
			qwq=1; break;
		}
	}
	
	for(int xx:{(x1+1)%n,(x1+n-1)%n})
		if(!qwq && !vx[xx]){
			For(y,0,m-1) q.push((node){xx,(y1+y)%m,-y,4});
			qwq=1; break;
		}
	for(int yy:{(y1+1)%m,(y1+m-1)%m}){
		if(!qwq && !vy[yy]){
			For(x,0,n-1) q.push((node){(x1+x)%n,yy,-x,4});
			qwq=1; break;
		}
	}
	
	int now1=0;
	while(now1<c1 || (q.size() && q.top().op==2)){
		auto [x,y,dd,op]=q.top(); q.pop();
		if(a[x][y]) continue;
//		cout<<"add "<<x<<" "<<y<<"\n";
		a[x][y]=1;
		++now1;
		For(d,0,3){
			int xx=(x+dx[d])%n,yy=(y+dy[d])%m;
			if(!a[xx][yy]){
				int op2=0;
				if(corner(xx,yy,3)) op2=2;
				else if(corner(xx,yy,2)) op2=1;
				q.push((node){xx,yy,dis[xx][yy],op2});
	//			cout<<"push "<<xx<<" "<<yy<<" "<<op2<<"\n";
			}
		}
	}
	
	
	cerr<<"now1 "<<now1<<"\n";
	For(i,0,n-1){
		For(j,0,m-1)cerr<<a[i][j];
		cerr<<"\n";
	}
	
	a[x2][y2]=a[x3][y3]=0;
	idx=0;
	For(i,0,n-1)For(j,0,m-1)if(!a[i][j])id[i][j]=++idx;
	For(i,0,idx) e[i].clear();
	auto add=[&](int u,int v){
		e[u].pb(v),e[v].pb(u);
	};
	For(i,0,n-1)For(j,0,m-1){
		if(id[i][j] && id[(i+1)%n][j]) add(id[i][j],id[(i+1)%n][j]);
		if(id[i][j] && id[i][(j+1)%m]) add(id[i][j],id[i][(j+1)%m]);
	}
	bipolar(idx,id[x2][y2],id[x3][y3]);
//	For(i,1,idx) cout<<tim[i]<<" "; cout<<"\n";
	
	For(i,0,n-1) For(j,0,m-1) 
		if(id[i][j]) a[i][j]=(tim[id[i][j]]<=c2?2:3);
	if(now1>c1){
		if(!give(3)){
			For(i,0,n-1) For(j,0,m-1) 
				if(id[i][j]) a[i][j]=(tim[id[i][j]]<c2?2:3);
			give(2);
		}
	}
	string out=" "; out+=t1,out+=t2,out+=t3;
	For(i,0,n-1){
		For(j,0,m-1)putchar(out[a[i][j]]);
		puts("");
	}
}

signed main()
{
	T=read();
	For(_,1,T)work(_);
	return 0;
}
/*
3 10
10 7 13
1 1 2 5 3 9


2
3 3
1 3 5
1 1
2 2
3 3
4 4
5 5 6
2 2
2 3
3 3
*/

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 75528kb

input:

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

output:

ABB
CBC
CCC
CABB
CABC
CACC
AABB

result:

ok ok (2 test cases)

Test #2:

score: 0
Accepted
time: 118ms
memory: 54812kb

input:

100000
3 3
2 1 6
3 3
1 2
2 2
3 3
7 1 1
3 1
1 1
2 3
3 3
1 7 1
1 1
3 1
1 3
3 3
2 1 6
3 3
1 3
1 1
3 3
7 1 1
2 1
3 2
1 1
3 3
3 2 4
2 2
2 1
1 2
3 3
3 2 4
3 3
1 1
2 1
3 3
2 4 3
2 1
1 2
1 3
3 3
3 5 1
1 2
3 1
2 2
3 3
2 4 3
1 1
2 1
2 3
3 3
1 5 3
3 3
2 2
1 2
3 3
5 1 3
2 1
1 2
2 2
3 3
3 5 1
2 1
2 3
3 2
3 3
7 1...

output:

CBA
CCC
CCA
BAA
AAC
AAA
ABC
BBB
BBB
CCB
CCA
CCA
CAA
AAA
ABA
BCA
BAA
CCC
BAA
CCC
BCA
ABC
ABB
CBC
AAA
BCB
BBB
AAB
BCC
BCB
BCB
BBB
CCA
ABA
ACA
ACC
AAB
ABB
BCB
BAA
AAC
AAA
BAB
BAB
CBB
BCB
BBB
ABB
AAB
CCC
CBB
AAB
BBC
ABB
AAA
BBB
BCB
BAA
CCC
CAC
BAA
AAC
CAC
BBB
CBC
ABC
AAA
BAC
ACC
BCC
ACC
CCC
AAB
CCB
CCC
...

result:

ok ok (100000 test cases)

Test #3:

score: 0
Accepted
time: 392ms
memory: 71172kb

input:

51263
3 10
19 7 4
1 1
2 7
2 9
3 7
1 5 15
1 6
2 2
2 7
3 3
1 2 6
1 3
3 1
2 2
3 6
13 1 4
2 1
2 6
3 6
3 8
10 10 4
2 8
1 5
3 1
3 5
11 3 1
1 3
2 4
2 5
3 10
14 9 7
2 2
1 2
3 1
3 9
3 2 22
3 6
2 7
2 1
3 10
12 6 12
3 5
2 9
2 5
3 3
2 6 1
1 3
2 1
1 2
3 10
10 14 6
2 10
1 4
1 9
3 8
3 20 1
2 6
1 1
1 2
3 10
13 3 14...

output:

AAAAABBCCA
AAAAABBBCA
AAAAAABBCA
BBCCCAB
BBCCCCC
CCCCCCC
BCA
CCC
BCC
AAAAAA
ACAAAB
CCAAAC
BBBBBAAB
BBBBAAAA
CCCCAAAA
AAAAA
AAABC
AABBA
BBAAABBBBB
BAAAAAAAAB
CCCCCCCAAA
CCCCCCCCC
CCCCACBCC
CCCCAABCC
CCCCCAAABB
CCCACAAABB
CCCAAAAABB
ACA
BBB
BBB
AAABBBBCCA
AABBBBBCCA
AABBBBBCCA
BCBBAABB
BBBBBABB
BBBBBB...

result:

ok ok (51263 test cases)

Test #4:

score: 0
Accepted
time: 391ms
memory: 73272kb

input:

51131
5 3
9 2 4
4 2
4 1
1 1
9 3
2 18 7
6 3
8 2
3 3
9 3
5 15 7
5 3
4 2
1 1
10 3
1 25 4
3 1
1 2
4 2
8 3
9 8 7
6 3
3 1
1 1
9 3
15 9 3
5 1
6 3
2 3
8 3
6 4 14
7 2
6 3
4 3
6 3
10 6 2
3 2
4 3
1 2
7 3
5 2 14
1 2
5 1
2 1
9 3
4 1 22
2 3
4 2
9 2
3 3
7 1 1
1 2
1 1
2 3
4 3
5 6 1
2 3
1 1
2 1
10 3
20 6 4
2 2
5 2
2...

output:

CCA
ACA
ACA
BAA
BAA
BBB
CBB
CBC
CBC
CBC
ABA
BBB
BBB
BBB
CCB
CCB
CCB
CBB
ABA
AAA
BBB
BBB
BBB
BBB
CCB
ACB
BCB
BBB
BBB
BBB
BBB
BBB
BBB
CCC
BCB
BAB
BAB
BAB
AAA
AAA
CCC
BBB
CCC
AAA
AAA
AAA
AAB
AAB
BAB
BAB
CCC
CCC
CCC
CCC
BCC
BBB
AAA
AAA
ACC
AAA
BAB
BAB
BAA
BAA
CAC
CCC
CCC
CCC
BBC
AAC
AAC
CCC
CAA
CAA
CBC
...

result:

ok ok (51131 test cases)

Test #5:

score: 0
Accepted
time: 235ms
memory: 71432kb

input:

6487
3 80
136 62 42
2 62
3 53
3 69
3 82
51 5 190
1 55
3 46
3 28
3 37
26 38 47
2 29
1 4
3 1
3 44
66 32 34
1 37
2 1
2 14
3 60
55 19 106
2 22
2 60
1 9
3 54
3 37 122
1 25
2 21
2 34
3 20
20 7 33
2 8
1 8
1 3
3 28
32 28 24
3 26
2 22
2 11
3 67
1 12 188
1 17
1 67
3 48
3 3
5 1 3
1 1
3 1
1 2
3 20
17 9 34
2 5
3...

output:

CCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCCCCCCC
CCAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAACCCCCCCCCCCC
CCAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAACCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBAAAAAAAAAAA...

result:

ok ok (6487 test cases)

Test #6:

score: 0
Accepted
time: 339ms
memory: 75516kb

input:

6524
69 3
149 24 34
60 3
19 3
58 1
43 3
48 63 18
7 3
6 2
24 1
42 3
7 26 93
2 1
13 3
28 1
22 3
10 22 34
5 1
10 2
21 3
97 3
27 29 235
70 2
94 2
88 3
83 3
32 165 52
36 2
58 3
73 3
81 3
54 9 180
40 2
52 1
79 1
41 3
85 23 15
41 3
31 3
23 2
22 3
17 20 29
10 1
18 2
17 1
45 3
29 20 86
45 3
33 3
2 3
42 3
91 ...

output:

AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
CCC
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
CAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
BBB
BBB
BBB
BBB
BBB
BBB
...

result:

ok ok (6524 test cases)

Test #7:

score: 0
Accepted
time: 240ms
memory: 74616kb

input:

1381
3 404
10 1176 26
2 204
1 403
3 224
3 286
72 258 528
1 266
3 59
1 135
3 52
21 19 116
1 33
3 38
1 32
3 248
330 382 32
2 185
2 242
3 1
3 440
496 92 732
2 227
1 354
2 357
3 37
8 95 8
2 10
3 34
1 1
3 136
255 104 49
2 43
3 29
1 114
3 56
81 28 59
1 3
1 32
3 40
3 20
31 20 9
3 11
1 5
1 19
3 100
233 5 62...

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok ok (1381 test cases)

Test #8:

score: 0
Accepted
time: 364ms
memory: 78564kb

input:

1341
128 3
70 177 137
85 2
77 3
120 1
204 3
302 188 122
182 3
76 1
185 3
85 3
97 122 36
49 3
84 2
53 2
70 3
70 67 73
40 1
61 2
48 1
346 3
84 346 608
53 3
114 3
13 1
310 3
135 723 72
142 1
263 3
204 1
329 3
282 207 498
22 3
145 1
271 1
53 3
59 27 73
1 2
23 2
20 2
439 3
241 29 1047
229 2
345 3
398 2
5...

output:

CCC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBC
BBB
BBB
...

result:

ok ok (1341 test cases)

Test #9:

score: 0
Accepted
time: 303ms
memory: 73744kb

input:

4899
3 98
83 104 107
2 58
3 38
1 88
3 92
89 6 181
3 79
2 46
3 52
4 22
42 35 11
2 8
1 13
1 1
4 63
47 68 137
2 55
1 4
4 56
5 74
68 121 181
2 69
2 18
2 11
5 66
249 22 59
3 65
3 3
4 61
4 33
61 24 47
3 1
3 33
1 15
4 77
1 208 99
3 12
2 45
2 53
3 37
67 14 30
2 6
3 3
2 1
4 17
23 34 11
3 15
4 16
3 6
4 28
80 ...

output:

BBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBBBBB
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCC...

result:

ok ok (4899 test cases)

Test #10:

score: 0
Accepted
time: 312ms
memory: 73660kb

input:

4817
71 3
92 42 79
60 1
24 2
64 3
98 5
258 176 56
34 2
13 3
92 3
85 3
96 122 37
1 1
51 2
63 2
51 3
30 110 13
27 2
20 3
25 2
62 5
154 40 116
11 5
55 1
4 3
38 5
112 37 41
5 1
15 3
6 2
94 5
173 112 185
16 3
5 2
19 3
63 3
51 112 26
39 3
6 3
7 3
9 3
1 4 22
7 1
1 1
6 2
95 3
12 236 37
71 3
46 2
48 2
21 5
5...

output:

CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
CCC
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
BBB
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
AAA
ACA
ACA
CCA
CAA
CAA
CAC
CAC
CAC
CAC
CAC
CAC
CAC
CAC
BBAAA
BBAAA
BBAA...

result:

ok ok (4817 test cases)

Test #11:

score: 0
Accepted
time: 208ms
memory: 74936kb

input:

999
3 159
102 4 371
3 86
3 31
2 102
5 490
684 1550 216
5 235
4 143
3 344
4 481
374 687 863
2 387
2 279
3 29
3 105
90 54 171
2 80
2 98
1 78
4 74
135 119 42
1 70
4 65
2 10
5 477
1829 45 511
5 92
3 346
4 280
5 457
1582 426 277
3 126
1 172
2 191
3 236
160 100 448
1 133
1 163
1 87
5 402
1241 419 350
4 18...

output:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok ok (999 test cases)

Test #12:

score: 0
Accepted
time: 287ms
memory: 78992kb

input:

994
204 5
355 440 225
202 1
6 1
73 4
32 5
12 86 62
31 2
1 1
11 5
360 3
648 265 167
151 1
11 3
55 3
68 5
232 91 17
33 2
50 4
56 4
93 5
98 74 293
56 2
27 1
37 3
419 5
1539 70 486
69 2
113 3
91 5
442 4
95 291 1382
377 3
367 2
345 2
293 3
37 84 758
164 2
3 1
130 2
162 4
140 308 200
140 3
135 3
39 2
357 ...

output:

BBAAA
BBAAA
BBAAA
BBAAA
BBAAA
BBAAA
BBAAA
BAAAA
BAAAA
BAAAA
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BAAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
BBAAB
...

result:

ok ok (994 test cases)

Test #13:

score: 0
Accepted
time: 324ms
memory: 71288kb

input:

23621
4 10
32 6 2
2 1
4 2
3 1
5 5
1 12 12
1 5
3 5
5 5
4 5
2 8 10
4 3
4 1
4 5
9 6
6 47 1
8 4
2 4
6 3
3 7
2 14 5
2 4
2 6
1 5
3 10
6 7 17
1 3
1 4
1 1
3 3
4 2 3
1 3
2 2
2 3
6 3
2 12 4
1 1
5 2
2 1
7 6
36 4 2
3 4
7 3
2 2
6 3
6 11 1
6 1
2 1
3 2
9 10
72 3 15
5 1
2 8
3 8
9 3
8 8 11
2 1
8 3
3 2
5 5
5 8 12
2 3...

output:

AAABAAAAAA
AAABAAAAAA
CCBBAAAAAA
ABBAAAAAAA
BBBBA
BCCBB
BCCBB
BCCCC
BCCCC
BBACC
BBCCC
BBCCC
BBACC
BBBBBB
BBBBBB
BBBBBB
BBBBBB
BBBBBB
BBCBBB
BBAABB
BBAABB
BBAABB
BCCCCCB
BBBABBB
BBBABBB
CAABBBCCCC
CAABBCCCCC
CAABBCCCCC
AAA
ABC
CBC
AAB
CCB
BCB
BCB
BBB
BBB
AAAAAA
ACCAAA
AAAAAA
AABAAA
AABAAA
AABAAA
AABA...

result:

ok ok (23621 test cases)

Test #14:

score: 0
Accepted
time: 379ms
memory: 75364kb

input:

23582
5 6
11 4 15
5 6
3 4
3 2
6 10
29 21 10
3 9
6 5
2 8
10 5
26 17 7
5 1
9 2
8 3
9 10
36 36 18
1 9
5 1
6 2
7 5
18 6 11
5 4
2 3
6 4
3 9
2 1 24
2 3
3 1
3 9
5 4
6 6 8
1 3
2 1
3 3
9 9
2 71 8
3 8
2 7
7 2
10 4
2 16 22
4 4
10 4
6 3
9 3
5 14 8
1 2
2 3
6 1
6 4
6 3 15
4 2
2 4
6 1
6 10
8 25 27
1 6
3 6
2 9
6 5
...

output:

CCCBAA
CCCAAA
CCCBAA
CCCBAA
CCCBAA
AAAAAAABBB
CCCCCCCCCC
AAAAAAAAAA
ABBBBBBBBB
ABBBAAAAAB
ABBBBAAAAB
AAABB
AAABB
AAABB
AAABB
AAABB
AAABB
AAACC
CCCCC
ABBBB
AAAAB
BBAAAAAAAB
BBAAAAAAAB
BBAAAAAAAB
BBAAAAAAAB
BAAAAAAAAB
CCCCCCCCCC
BCCCCCCCCB
BBBBBBBBBB
BBBBBBBBBB
BACCC
BBBBB
AAAAA
AACAA
AACAA
AACCC
AACC...

result:

ok ok (23582 test cases)

Test #15:

score: 0
Accepted
time: 340ms
memory: 71232kb

input:

23640
5 3
3 4 8
5 2
2 1
1 1
8 8
7 44 13
3 5
8 5
6 3
7 6
32 6 4
4 4
4 3
5 5
8 6
1 34 13
6 2
3 5
1 4
10 3
23 1 6
7 3
8 2
7 1
3 9
5 3 19
1 5
2 7
1 3
7 5
4 19 12
7 3
2 5
5 4
4 6
11 11 2
1 5
2 5
3 5
4 3
3 7 2
4 1
1 3
2 2
3 4
3 8 1
3 4
3 1
3 3
10 6
36 20 4
1 5
4 6
10 6
3 9
15 6 6
2 5
1 3
2 2
7 5
16 7 12
1...

output:

CCB
BCB
CCB
CCC
AAA
BBBBBBBB
BBBBBBBB
AAABAAAA
CCCBBBBB
CCCBBBBB
CCCBBBBB
CCBBBBBB
CCBBBBBB
AAAAAA
ABBAAA
ABBAAA
ABBAAA
CCAACC
AAAAAA
AAAAAA
CCCCCB
CBBBCB
CBBBBB
CBBBBB
CBBBBB
CABBBB
CBBBBB
CBBBBB
AAA
CAA
CAA
CAA
CAA
CAA
CAA
ABA
AAA
AAA
CCCCAAAAA
CCCCCCBBB
CCCCCCCCC
BBBBB
BCCBB
BCCBB
BCCBB
BCCCB
BCC...

result:

ok ok (23640 test cases)

Test #16:

score: 0
Accepted
time: 287ms
memory: 73352kb

input:

13306
9 16
46 66 32
2 5
5 9
3 9
10 4
11 24 5
1 4
9 3
1 1
5 6
12 8 10
5 5
5 4
3 5
5 10
27 14 9
2 4
3 3
2 1
9 7
23 28 12
4 6
2 3
9 7
3 18
4 49 1
2 15
3 4
2 14
4 20
50 15 15
2 19
3 5
2 10
3 10
2 1 27
2 1
2 4
1 5
5 18
55 23 12
3 18
5 12
5 14
7 3
9 7 5
4 3
5 2
1 1
3 7
5 11 5
2 5
2 1
2 7
8 18
16 43 85
7 7...

output:

AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA
CCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCC
AAAAAAAABBBBBBBB
ABBBBBBBBBBBBBBB
ABBBBBBBBBBBBBBB
ABBBBBBBBBBBBBBA
ABBBBBBBBBBBBBBA
CBBA
CBBA
CBBA
CBBA
CBBA
BBBA
BBBA
BBBA
BBBA
BBAA
CABBCC
CABBCC
AABBCC
AAABCC
AAABAA
BBBBAAAAAC
CBBAAAAAAC
CBBBAAAAAC
CBBBAAAAAC
CBBAAAAAAC
BBBAABB...

result:

ok ok (13306 test cases)

Test #17:

score: 0
Accepted
time: 348ms
memory: 73404kb

input:

13232
8 8
30 23 11
1 5
7 4
6 4
4 5
14 1 5
4 2
4 5
2 3
17 9
24 28 101
14 2
4 6
15 7
19 4
61 10 5
1 2
4 3
4 2
17 7
49 32 38
2 1
3 7
12 2
10 3
6 5 19
1 3
8 2
10 3
4 8
4 18 10
2 2
4 6
4 5
20 10
14 102 84
13 3
7 6
12 6
17 7
41 36 42
5 4
3 2
13 3
15 4
10 46 4
11 3
2 1
15 2
6 9
21 1 32
6 3
5 8
1 6
18 3
25 ...

output:

AAAAABBB
AAAABBBB
AAAABBBB
AAAABBBB
CAAABBCC
CCCCCCCC
AAABBBBB
AAAAAAAB
AACCC
AACAC
AAAAA
AAAAB
CCCBBBCCC
CCCCCBCCC
CCCCCBCCC
CCCCCBCCC
CCCCCCCCC
CCCCCCCCC
CCCCCCCCC
CCCCCCCCC
CCCCCCCCC
CCCCCCCCC
CCCCCCCCC
AAAAACCCA
AAAAAAAAA
AAAAAAAAA
BBBBBBCCC
BBBBBBBBC
BBBBBBBBC
AABB
ABBB
ABBB
ACBB
CCCC
AAAA
AAAA...

result:

ok ok (13232 test cases)

Test #18:

score: 0
Accepted
time: 255ms
memory: 74148kb

input:

3062
5 38
108 18 64
5 28
5 36
4 2
4 65
132 95 33
4 55
4 21
3 20
7 85
169 131 295
3 2
1 77
6 44
9 5
11 12 22
7 1
4 1
2 4
9 100
567 50 283
7 21
5 13
3 54
10 37
22 154 194
3 21
2 13
5 15
5 46
43 144 43
5 40
4 30
3 43
5 79
40 225 130
4 60
2 61
3 36
4 33
22 69 41
4 22
2 8
3 19
5 60
39 74 187
1 32
4 3
3 1...

output:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCAAAAABBBCC
CCCCCAAAAAAAAAAAAAAAAAAAAAACAAAABBBBCC
CCCCCCAAAAAAAAAAAAAAAAAAAAACAAAABBBBCC
CCCCCCAAAAAAAAAAAAAAAAAAAAACAAAABBBBCC
CCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAABBBCC
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAA...

result:

ok ok (3062 test cases)

Test #19:

score: 0
Accepted
time: 340ms
memory: 71948kb

input:

3006
49 10
155 40 295
2 2
18 1
39 8
21 9
33 35 121
12 7
1 6
5 3
18 10
121 20 39
18 6
2 6
2 8
23 4
29 26 37
18 2
17 4
17 3
67 3
25 133 43
10 2
59 2
13 3
72 9
42 265 341
65 7
59 8
44 9
4 8
7 17 8
2 8
2 2
2 1
20 6
16 31 73
7 4
12 4
12 1
4 8
9 11 12
3 1
2 3
4 1
73 3
22 109 88
40 2
17 2
62 1
32 7
50 3 17...

output:

AAAAAAAACC
AAAAAAAACA
AAAAAAAACA
AAAAAAAACA
AAAAAAAACA
AAAAAAAACA
AAAAAAAACA
AAAAAAAACA
AAAAAAACCA
AAAAAAACAA
AAAAAAACAA
AAAAAAACAA
AAAAAAACAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
AAAAAAAAAA
BBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBB
BBBBBBBBBB
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCC...

result:

ok ok (3006 test cases)

Test #20:

score: 0
Accepted
time: 284ms
memory: 77444kb

input:

606
7 169
500 93 590
3 84
1 7
2 39
3 231
602 25 66
3 162
1 80
2 102
3 339
954 20 43
2 277
2 61
3 304
9 215
951 665 319
9 142
6 135
6 77
10 378
216 2334 1230
4 203
2 236
6 298
8 354
883 1486 463
4 340
1 302
5 247
10 12
1 32 87
10 3
3 9
10 1
9 235
1944 142 29
2 106
6 114
7 221
5 451
731 85 1439
4 208
...

output:

CCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok ok (606 test cases)

Test #21:

score: 0
Accepted
time: 300ms
memory: 79020kb

input:

615
31 9
21 99 159
16 4
24 4
28 3
249 4
375 437 184
213 2
55 1
133 2
367 10
34 2150 1486
334 7
90 1
133 7
273 5
288 628 449
235 4
203 2
139 3
242 9
915 897 366
122 8
34 2
95 6
90 6
97 297 146
11 2
54 5
39 1
280 4
463 194 463
35 2
239 1
12 3
64 7
212 19 217
4 2
47 2
54 6
334 3
346 291 365
136 3
171 2...

output:

BBBBCCCCC
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCCCB
BBBBCCAAA
AAAAAAAAA
AAAAAAAAA
BBBBCCCCC
BCCBCCCCC
BCCBCCCCC
BCCBCCCCC
BCCBCCCCC
BCCBCCCCC
BCCBCCCCC
BCCBCCCCC
BCCCCCCCC
BCCCCCCCC
BCCCBCCCC
BCCCBCCCC
BCCCBCCCC
BCCCBCCCC
...

result:

ok ok (615 test cases)

Test #22:

score: 0
Accepted
time: 263ms
memory: 73620kb

input:

399
45 97
74 3467 824
44 96
30 86
1 69
89 26
269 1649 396
14 8
66 21
79 19
51 38
1762 46 130
35 24
37 29
49 13
63 60
1253 311 2216
56 24
41 40
30 2
71 74
1904 2403 947
67 52
35 46
55 57
72 60
2311 1012 997
28 45
18 12
64 19
69 51
177 1537 1805
68 35
59 6
59 45
96 59
748 1594 3322
62 40
40 38
20 13
9...

output:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBBBBBB
CCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBB
CCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBB
CCCCCC...

result:

ok ok (399 test cases)

Test #23:

score: 0
Accepted
time: 275ms
memory: 80004kb

input:

360
41 43
235 529 999
3 21
34 4
35 13
83 94
3614 93 4095
61 82
21 15
16 17
53 27
408 74 949
6 11
52 25
5 22
15 26
9 176 205
2 19
8 12
8 8
14 46
589 18 37
14 1
10 5
1 4
94 100
6296 1371 1733
10 54
54 61
91 5
28 6
144 4 20
2 4
4 2
18 5
43 70
160 1177 1673
22 33
30 54
2 37
83 12
190 570 236
22 7
82 12
...

output:

BBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
BBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCB
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok ok (360 test cases)

Test #24:

score: 0
Accepted
time: 256ms
memory: 75548kb

input:

373
37 97
1778 1378 433
32 54
16 42
22 39
26 24
213 243 168
2 5
14 19
14 21
94 76
1744 1911 3489
85 9
52 54
32 29
4 100
46 75 279
4 100
2 53
3 92
56 19
270 98 696
28 8
51 17
32 18
17 62
326 211 517
11 34
8 54
7 57
34 20
109 33 538
22 2
20 17
3 7
40 33
81 401 838
11 22
10 6
40 7
42 42
275 352 1137
13...

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBB...

result:

ok ok (373 test cases)

Test #25:

score: 0
Accepted
time: 248ms
memory: 73400kb

input:

385
33 64
791 261 1060
25 39
17 14
17 18
20 91
537 585 698
8 23
3 5
7 48
96 17
2 1614 16
48 13
6 5
32 17
43 76
900 280 2088
36 39
30 33
42 65
87 89
3076 583 4084
63 83
38 74
9 39
89 53
736 2326 1655
24 1
19 14
7 6
50 83
145 3131 874
19 2
37 17
25 60
85 95
1125 741 6209
4 16
36 92
7 5
30 14
275 81 64...

output:

AAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCAAAAAAAAAAAAAAAAA
AAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCAAAAAAAAAAAAAAAAA
AAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCAAAAAAAAAAAAAAAAA
AAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCA...

result:

ok ok (385 test cases)

Test #26:

score: 0
Accepted
time: 232ms
memory: 77476kb

input:

395
39 60
86 693 1561
12 40
23 60
13 47
71 51
750 2577 294
40 39
52 29
13 1
97 25
1776 492 157
19 14
56 24
69 1
82 52
2707 1061 496
18 42
70 34
39 22
21 61
588 136 557
16 20
8 26
3 6
23 5
23 62 30
17 1
14 1
8 5
57 96
3061 2036 375
5 45
13 70
26 11
82 58
1124 2280 1352
3 8
35 37
61 24
67 85
2782 996 ...

output:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok ok (395 test cases)

Test #27:

score: 0
Accepted
time: 371ms
memory: 104512kb

input:

16
268 416
66697 38289 6502
195 219
144 362
123 122
308 351
26341 30585 51182
244 132
203 111
298 18
378 477
117148 23075 40083
310 405
70 133
126 447
382 406
28319 102643 24130
3 128
22 204
10 176
281 431
2894 102825 15392
199 258
228 6
230 250
388 449
113240 18680 42292
105 16
169 308
47 113
322 3...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok ok (16 test cases)

Test #28:

score: 0
Accepted
time: 296ms
memory: 106728kb

input:

32
146 330
9614 1064 37502
85 303
89 97
10 54
485 232
76840 3126 32554
195 33
413 164
441 106
103 208
4787 3495 13142
14 129
58 126
14 122
455 142
7668 25161 31781
253 12
47 125
433 10
74 223
2576 10287 3639
68 95
9 15
65 82
348 152
27400 9988 15508
185 34
216 85
335 24
459 137
13558 12839 36486
307...

output:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok ok (32 test cases)

Test #29:

score: 0
Accepted
time: 252ms
memory: 102948kb

input:

22
24 435
2979 5676 1785
13 27
8 163
13 264
473 102
21515 24622 2109
408 102
201 93
64 65
315 246
21840 37125 18525
145 111
61 158
267 61
220 198
2402 27918 13240
151 19
106 197
19 67
27 176
3525 174 1053
24 55
22 28
27 120
497 194
45328 29337 21753
225 52
364 110
179 145
435 240
27814 61553 15033
1...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok ok (22 test cases)

Test #30:

score: 0
Accepted
time: 316ms
memory: 100764kb

input:

20
62 189
16 11141 561
32 187
31 45
42 120
313 482
58905 24263 67698
281 435
77 299
110 366
366 475
24689 63283 85878
154 287
66 205
6 31
454 432
45618 80608 69902
324 388
256 197
181 161
479 306
72621 67410 6543
432 160
241 26
197 105
457 88
24785 14632 799
329 54
72 68
296 2
423 35
6959 6572 1274
...

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok ok (20 test cases)

Test #31:

score: 0
Accepted
time: 263ms
memory: 105824kb

input:

23
100 441
12680 23952 7468
93 398
96 11
54 421
140 203
7131 20588 701
81 101
99 63
86 76
430 206
38715 30668 19197
414 126
266 71
250 8
219 328
7040 1475 63317
143 43
35 36
14 325
272 98
14508 2290 9858
189 5
189 10
240 62
257 129
28235 506 4412
99 69
116 111
245 34
61 138
805 4878 2735
34 41
48 59...

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok ok (23 test cases)