QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501479#9159. 登山GotoHiotori25 368ms43416kbC++142.8kb2024-08-02 19:17:392024-08-02 19:17:39

Judging History

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

  • [2024-08-02 19:17:39]
  • 评测
  • 测评结果:25
  • 用时:368ms
  • 内存:43416kb
  • [2024-08-02 19:17:39]
  • 提交

answer

#include<stdio.h>
#include<vector>
const int mod=998244353;
int sum(int a,int b){return a<mod-b?a+b:a-(mod-b);}
int dif(int a,int b){return a<b?mod-(b-a):a-b;}
int pro(int a,int b){return (long long)a*b%mod;}
std::vector<int>ch1[100001],ch2[100001],in[100001],out[100001];
int n,p[100001],l[100001],r[100001],h[100001],d[100001],dfn1[100001],dfn2[100001],end1[100001],end2[100001];
int f[100001],g[100001];
int c1[100001],c2[100001],c3[100001];
int query1(int x){
	int s=0;
	for(;x;x-=(x&-x))s+=c1[x];
	return s;
}
void change1(int x,int k){
	for(;x<=n;x+=(x&-x))c1[x]+=k;
}
int query2(int x){
	int s=0;
	for(;x;x-=(x&-x))s=sum(s,c2[x]);
	return s;
}
void change2(int x,int k){
	for(;x<=n;x+=(x&-x))c2[x]=sum(c2[x],k);
}
int query3(int x){
	int s=0;
	for(;x;x-=(x&-x))s+=c3[x];
	return s;
}
void change3(int x,int k){
	for(;x<=n;x+=(x&-x))c3[x]+=k;
}
namespace init1{
	int dfntot;
	void dfs(int u){
		dfn1[u]=++dfntot;
		for(const auto&v:ch1[u])dfs(v);
		end1[u]=dfntot;
	}
	void work(){
		for(int i=1;i<=n;++i)ch1[i].clear();
		d[1]=1,h[1]=0;
		for(int i=2;i<=n;++i)ch1[p[i]].push_back(i),d[i]=d[p[i]]+1,h[i]=d[i]-h[i]-1,l[i]=d[i]-l[i],r[i]=d[i]-r[i];
		dfntot=0,dfs(1);
	}
}
namespace init2{
	int stk[100001],dfntot;
	void dfs1(int u,int m){
		int t=stk[m],p,q,x;
		stk[m]=u;
		if(u>1&&r[u]<=h[u]){
			for(p=1,q=m;p<q;){
				x=p+q+1>>1;
				if(r[u]>h[stk[x]])p=x;
				else q=x-1;
			}in[stk[p+1]].push_back(u);
		}
		if(u>1&&l[u]<=h[u]){
			for(p=1,q=m;p<q;){
				x=p+q+1>>1;
				if(l[u]>h[stk[x]])p=x;
				else q=x-1;
			}out[stk[p+1]].push_back(u);
		}
		for(const auto&v:ch1[u]){
			for(p=1,q=m;p<q;){
				x=p+q+1>>1;
				if(h[stk[x]]<h[v])p=x;
				else q=x-1;
			}ch2[stk[p]].push_back(v),dfs1(v,p+1);
		}
		stk[m]=t;
	}
	void dfs2(int u){
		dfn2[u]=++dfntot;
		for(const auto&v:ch2[u])dfs2(v);
		end2[u]=dfntot;
	}
	void work(){
		for(int i=1;i<=n;++i)ch2[i].clear(),in[i].clear(),out[i].clear();
		dfs1(1,1);
		dfntot=0,dfs2(1);
	}
}
void dfs(int u){
	for(const auto&v:in[u])change1(dfn2[v],1),change2(dfn1[v],dif(0,g[r[v]-1])),change2(dfn1[query3(dfn2[v])],g[h[query3(dfn2[v])]]);
	for(const auto&v:out[u])change1(dfn2[v],-1),change2(dfn1[v],g[l[v]]),change2(dfn1[query3(dfn2[v])],dif(0,g[h[query3(dfn2[v])]]));
	g[d[u]]=sum(g[d[u]-1],f[u]=u>1?dif(query2(end1[u]),query2(dfn1[u]-1)):1);
	for(const auto&v:ch2[u])
		change2(dfn1[v],pro(dif(query1(end2[v]),query1(dfn2[v]-1)),g[h[v]])),change3(dfn2[v],v-u),change3(end2[v]+1,u-v);
	for(const auto&v:ch1[u])dfs(v);
}
void work(){
	scanf("%d",&n);
	for(int i=2;i<=n;++i)scanf("%d%d%d%d",p+i,l+i,r+i,h+i);
	init1::work(),init2::work();
	for(int i=1;i<=n;++i)c1[i]=c2[i]=0,c3[i]=i==(i&-i);
	dfs(1);
	for(int i=2;i<=n;++i)printf("%d ",f[i]);
	puts("");
}
int main(){
	int t;
	for(scanf("%*d%d",&t);t--;work());
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 3ms
memory: 18936kb

input:

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

output:

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

result:

wrong answer 2nd numbers differ - expected: '4', found: '2'

Pretest #2:

score: 0
Wrong Answer
time: 4ms
memory: 17296kb

input:

2
4
300
1 1 1 0
2 1 2 1
3 1 3 1
1 1 1 0
3 1 3 0
4 2 2 3
7 1 2 0
8 2 2 2
7 1 3 4
7 3 4 4
11 1 6 1
12 1 3 5
10 2 5 5
13 1 5 4
13 4 7 2
15 8 8 8
16 8 9 4
15 1 9 6
18 4 5 6
19 3 8 8
18 5 10 2
19 3 7 5
23 5 7 6
22 6 8 10
23 4 7 3
24 1 4 6
24 8 12 9
28 7 11 8
26 1 9 7
28 1 3 1
29 2 5 0
32 1 6 4
30 5 12 7
...

output:

1 3 2 1 5 0 2 0 0 6 17 16 0 37 15 0 9 35 0 0 13 34 22 0 49 0 34 39 12 56 457 320 16 128 81 123 4 14 81 254 1 0 24 0 1 70 2612 704 3189 1915 1117 282 792 576 0 1896 1034 471 25 185 1607 1607 1181 81 509 1019 0 1296 3126 10395 11379 9 0 52 1396 6119 11957 10400 17430 76 11792 3338 3978 7124 13992 9843...

result:

wrong answer 1st numbers differ - expected: '19', found: '1'

Pretest #3:

score: 0
Wrong Answer
time: 3ms
memory: 17112kb

input:

3
4
300
1 1 1 0
2 1 2 1
3 3 3 0
2 1 2 1
3 1 3 1
3 1 3 0
4 1 4 1
6 4 4 2
9 3 5 1
7 3 4 2
10 2 5 4
12 1 5 2
11 1 3 2
12 3 6 6
13 6 6 3
13 3 8 0
14 3 5 0
16 3 5 5
16 6 9 5
20 2 7 3
20 3 7 9
21 7 9 2
23 3 4 8
21 4 9 6
24 11 12 2
25 3 4 1
27 7 13 5
26 1 8 3
29 2 4 6
29 6 15 14
29 5 5 10
32 6 10 11
30 1 9...

output:

1 12 15 1 13 16 14 11 22 3 13 259 25 0 197 60 29 0 248 300 0 167 118 74 118 777 73 1122 105 1 0 0 180 2705 2004 2578 515 1371 2529 200 0 0 2657 1987 1520 13 854 11492 1266 130 3461 745 1324 756 0 228 1289 0 1327 2073 59 38 0 60 1525 0 82 25 108 4348 1240 2849 3949 0 4217 0 3602 5212 1077 4228 0 1345...

result:

wrong answer 1st numbers differ - expected: '20', found: '1'

Pretest #4:

score: 0
Wrong Answer
time: 12ms
memory: 19604kb

input:

4
4
5000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 2 0
5 2 3 2
5 1 3 1
6 2 3 2
6 2 3 1
8 3 5 4
8 4 5 3
11 2 4 4
11 1 3 3
11 5 6 3
12 1 1 6
15 1 5 3
15 1 6 6
17 5 6 5
17 6 8 4
18 7 9 3
19 1 10 3
19 2 4 7
20 1 9 3
23 8 11 7
22 2 5 4
23 7 8 1
24 1 9 8
26 9 11 7
28 8 10 13
29 1 11 3
30 9 9 14
31 11 15 4
32 8 16 8
31 ...

output:

1 1 3 8 3 4 11 11 1 8 0 0 4 1 14 13 53 40 118 34 0 105 25 0 49 11 22 6 333 36 131 251 165 0 720 120 720 347 98 121 1687 0 2751 0 2258 3 1536 0 410 903 0 12071 1713 7936 97 1230 11766 20 2459 2510 10765 15734 10357 383 886 395 111 0 0 18406 5009 7948 75 7944 1173 103 2439 0 1956 1873 0 2443 24921 60 ...

result:

wrong answer 3rd numbers differ - expected: '28', found: '3'

Pretest #5:

score: 0
Wrong Answer
time: 16ms
memory: 19196kb

input:

5
4
5000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 2 0
3 1 1 1
4 1 1 0
6 1 3 2
7 1 3 1
8 2 2 0
8 1 3 2
11 3 5 1
10 1 5 4
13 1 2 4
12 3 4 3
15 3 5 2
15 2 6 2
15 1 3 3
16 7 7 3
19 1 7 4
18 2 3 4
20 1 10 5
21 2 3 8
21 4 9 6
22 7 9 3
24 2 6 8
25 1 3 4
25 3 4 1
26 3 4 3
29 5 11 9
28 8 11 12
29 7 9 11
32 5 12 5
32 11 1...

output:

2 1 2 3 0 5 4 3 0 9 8 1 0 6 55 14 2 42 41 2 28 0 2 13 1 0 83 3 1 0 17 30 51 0 49 0 0 64 0 137 60 6 4 28 23 72 313 33 0 341 269 20 277 554 121 43 412 133 383 273 29 178 302 258 29 670 567 93 28 2 93 1 105 21 273 113 114 50 2440 1881 125 21 130 4168 102 102 0 75 2057 102 0 194 0 0 67 0 77 37 0 967 103...

result:

wrong answer 2nd numbers differ - expected: '35', found: '1'

Pretest #6:

score: 5
Accepted
time: 341ms
memory: 43236kb

input:

6
4
100000
1 1 1 0
2 1 1 0
3 1 1 0
4 2 2 0
5 1 1 0
6 2 2 0
7 6 6 0
8 3 3 0
9 6 6 0
10 8 8 0
11 6 6 0
12 12 12 0
13 11 11 0
14 2 2 0
15 2 2 0
16 2 2 0
17 9 9 0
18 1 1 0
19 4 4 0
20 18 18 0
21 13 13 0
22 20 20 0
23 3 3 0
24 21 21 0
25 8 8 0
26 11 11 0
27 11 11 0
28 3 3 0
29 21 21 0
30 1 1 0
31 27 27 0...

output:

7 90 1343 13340 200010 2186770 17480820 279693113 800242414 420706509 214087588 358274752 946289212 530647994 955227776 663050301 438245147 621009062 780623708 80919478 728275212 743623748 978006196 735181462 256088384 612217572 335562169 696082683 110948988 53450390 637356472 107616671 988788196 54...

result:

ok 399996 numbers

Pretest #7:

score: 5
Accepted
time: 341ms
memory: 36832kb

input:

7
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 1 0
1 1 1 0
3 1 1 0
7 1 1 0
6 1 1 0
9 2 2 0
6 1 1 0
6 1 1 0
7 2 2 0
9 2 2 0
11 1 1 0
11 2 2 0
14 4 4 0
12 1 1 0
16 3 3 0
15 1 1 0
17 3 3 0
20 5 5 0
18 4 4 0
20 2 2 0
19 2 2 0
22 5 5 0
22 2 2 0
22 3 3 0
23 5 5 0
27 7 7 0
26 6 6 0
27 5 5 0
31 1 1 0
33 9 9 0
34 2 ...

output:

1 1 1 1 31 2 2 94 31 1298 33 1 126 41443 62 95 35 93 1490650 94 49108564 2 41443 62 31502098 1491949 41443 1 1 882058713 1298 808538694 650336433 808538694 808538695 53283330 1298 31502098 1 31502098 319947267 692436002 360370658 1534689 1298 41443 692394559 41443 518136386 1298 972986764 32 6923530...

result:

ok 399996 numbers

Pretest #8:

score: 0
Wrong Answer
time: 270ms
memory: 43380kb

input:

8
4
100000
1 1 1 0
2 2 2 0
3 3 3 0
4 4 4 2
5 2 2 1
6 6 6 0
7 2 2 0
8 7 7 3
9 4 4 3
10 1 1 4
11 3 3 0
12 8 8 11
13 13 13 7
14 5 5 10
15 8 8 11
16 14 14 5
17 9 9 2
18 17 17 7
19 3 3 1
20 1 1 9
21 14 14 5
22 5 5 17
23 8 8 14
24 8 8 9
25 24 24 7
26 24 24 7
27 17 17 8
28 27 27 27
29 26 26 6
30 17 17 14
3...

output:

5 4 3 7 9 15 14 5 9 0 5 1 1 0 18 23 19 14 32 23 23 9 9 9 9 4 0 0 3 1 0 9 14 14 9 5 5 12 21 12 35 12 7 7 7 7 14 15 15 47 24 15 24 15 5 5 0 3 3 0 14 14 2 2 2 11 11 2 2 2 2 2 2 11 11 72 72 37 37 2 2 17 40 40 21 35 21 21 21 9 2 20 31 85 85 66 52 48 34 34 26 11 11 2 2 2 2 2 25 25 16 21 16 2 2 2 13 2 11 2...

result:

wrong answer 1st numbers differ - expected: '12', found: '5'

Pretest #9:

score: 0
Wrong Answer
time: 270ms
memory: 35752kb

input:

9
4
100000
1 1 1 0
2 2 2 0
2 1 1 1
2 2 2 1
1 1 1 0
6 1 1 1
3 1 1 0
6 1 1 0
7 1 1 2
6 2 2 0
8 3 3 2
9 1 1 1
9 1 1 0
12 5 5 2
14 1 1 3
13 4 4 3
13 1 1 3
14 3 3 3
17 5 5 2
19 1 1 0
18 3 3 3
22 3 3 5
23 1 1 0
21 5 5 3
22 4 4 4
23 7 7 2
24 6 6 3
25 2 2 1
29 6 6 7
29 8 8 3
31 8 8 7
32 6 6 5
31 5 5 7
31 2 ...

output:

3 2 0 1 2 0 3 2 0 1 4 0 2 1 0 2 0 3 1 6 0 1 1 5 0 1 2 9 0 3 2 3 0 11 0 0 2 12 0 14 0 26 6 0 29 21 2 10 9 2 6 0 7 0 2 2 0 5 2 11 23 4 0 0 4 5 4 3 0 0 0 26 3 8 2 0 12 2 30 10 0 0 27 2 0 2 3 16 2 11 9 29 2 29 3 9 2 3 0 0 37 0 30 27 4 7 0 11 41 0 6 0 11 3 0 7 26 0 9 5 0 0 0 0 0 0 21 7 16 6 0 22 12 6 31 ...

result:

wrong answer 1st numbers differ - expected: '4', found: '3'

Pretest #10:

score: 5
Accepted
time: 340ms
memory: 42892kb

input:

10
4
100000
1 1 1 0
2 2 2 0
3 3 3 0
4 2 2 0
5 2 4 0
6 1 3 0
7 2 4 0
8 3 8 0
9 1 6 0
10 4 6 0
11 2 9 0
12 2 3 0
13 1 13 0
14 4 12 0
15 1 9 0
16 7 13 0
17 10 17 0
18 17 17 0
19 10 11 0
20 2 13 0
21 9 11 0
22 15 18 0
23 9 22 0
24 4 6 0
25 21 22 0
26 9 16 0
27 18 27 0
28 4 16 0
29 13 24 0
30 1 5 0
31 5 ...

output:

27 1160 73079 5773240 508043960 401903691 408194108 913457210 404309453 850776989 162033550 491800762 693950334 88591672 90581013 261837127 124549390 607776285 954584563 426982262 910735533 125508942 301425049 369545791 349157696 256736908 276834134 449249498 408190411 362993320 980271019 745442146 ...

result:

ok 399996 numbers

Pretest #11:

score: 5
Accepted
time: 368ms
memory: 35368kb

input:

11
4
100000
1 1 1 0
1 1 1 0
2 1 2 0
1 1 1 0
2 1 2 0
6 1 3 0
5 1 2 0
7 2 3 0
6 2 2 0
8 1 3 0
9 2 3 0
9 3 5 0
10 2 4 0
13 2 4 0
12 4 6 0
13 1 6 0
16 1 4 0
18 6 7 0
18 2 4 0
20 1 6 0
21 2 9 0
20 1 3 0
23 1 4 0
22 1 8 0
24 10 10 0
23 3 5 0
24 3 11 0
26 8 11 0
27 1 9 0
30 2 11 0
28 12 12 0
32 4 8 0
32 9 ...

output:

41 1 42 3 3401 407995 8 65275757 3484 12 30977333 131377791 3443 65687153 608294415 197064986 558803128 3442 391883539 973952531 292262895 548293486 864139803 925368887 65687235 614731260 251165603 65687194 646118904 822181649 995485114 956758427 65275757 656989819 750355997 665993179 321752162 1997...

result:

ok 399996 numbers

Pretest #12:

score: 5
Accepted
time: 364ms
memory: 36972kb

input:

12
4
100000
1 1 1 0
1 1 1 0
3 1 2 0
3 1 2 0
4 1 1 0
4 1 3 0
6 2 4 0
7 2 4 0
9 1 4 0
8 1 3 0
11 3 3 0
11 5 6 0
12 1 2 0
14 3 3 0
13 2 7 0
16 2 3 0
17 2 4 0
17 7 9 0
17 3 8 0
20 2 6 0
21 10 11 0
21 6 11 0
21 7 9 0
23 3 4 0
24 5 11 0
26 6 9 0
26 5 7 0
27 12 13 0
29 10 10 0
28 1 3 0
31 13 15 0
32 7 13 0...

output:

1 44 3430 45 363401 10424 49055705 17373 31271 763087444 528293936 364247389 57980118 763087444 558370737 701077016 687461217 3475 530193136 875194506 45 47291471 587072521 233025799 902397684 501363487 984008256 763090918 763087444 553932106 460519388 415423761 485110453 526953701 435687917 4594610...

result:

ok 399996 numbers

Pretest #13:

score: 0
Wrong Answer
time: 285ms
memory: 43416kb

input:

13
4
100000
1 1 1 0
2 1 2 0
3 2 2 2
4 2 4 1
5 1 2 4
6 4 6 2
7 1 6 4
8 6 6 5
9 5 8 8
10 6 6 1
11 8 11 5
12 8 11 1
13 4 8 6
14 4 7 1
15 11 15 5
16 1 1 10
17 6 9 7
18 8 16 2
19 2 9 10
20 6 20 7
21 12 14 11
22 9 14 14
23 6 7 22
24 12 14 11
25 20 20 21
26 10 20 0
27 19 26 8
28 21 23 12
29 4 13 23
30 15 2...

output:

2 3 1 6 1 6 5 3 3 48 47 46 34 86 27 25 62 104 36 183 11 0 4 153 18 851 39 24 12 16 58 61 639 854 36 36 218 43 43 568 41 854 472 645 1032 1032 202 2738 122 103 5231 3771 3584 3471 56 56 2670 2644 36 3385 355 908 17 175 893 3 3 3 3460 2228 682 1851 38903 0 194 0 1836 625 4329 2626 218 316 0 0 11223 2 ...

result:

wrong answer 1st numbers differ - expected: '28', found: '2'

Pretest #14:

score: 0
Wrong Answer
time: 307ms
memory: 37348kb

input:

14
4
100000
1 1 1 0
2 1 1 1
1 1 1 0
2 1 2 1
4 2 2 1
5 2 2 1
7 1 4 1
8 2 5 3
8 5 5 3
10 2 3 5
11 1 6 5
10 1 4 5
12 5 8 1
12 3 6 5
13 3 6 2
15 2 5 8
17 6 7 6
18 6 8 5
17 10 10 1
18 4 5 5
20 4 11 7
22 8 9 4
23 9 13 12
24 9 13 10
24 6 8 7
26 3 13 13
26 11 14 11
28 11 11 2
27 9 16 8
30 6 12 0
31 13 17 16...

output:

1 0 1 4 1 6 9 2 1 1 3 0 12 4 20 2 12 16 13 0 18 15 5 11 9 9 11 1 86 46 8 71 26 67 26 0 95 113 539 10 306 60 46 233 7 23 33 0 95 0 733 71 81 578 1078 496 1 601 6 2 4 64 2593 1958 3183 91 25 37 2568 554 144 2617 58 0 1330 113 0 12 27 1115 218 50 64 285 6366 1923 9715 0 11 49 92 1291 4 50 283 79 1 4918...

result:

wrong answer 1st numbers differ - expected: '38', found: '1'

Pretest #15:

score: 0
Wrong Answer
time: 297ms
memory: 34388kb

input:

15
4
100000
1 1 1 0
1 1 1 0
3 1 1 1
3 2 2 0
4 1 2 0
5 1 1 2
2 1 2 0
3 1 2 0
7 3 3 1
9 3 3 1
8 1 2 1
10 1 5 1
8 2 3 0
9 1 2 1
11 3 3 3
14 1 2 2
15 1 3 1
15 2 4 0
15 1 4 3
17 3 4 2
19 5 5 2
21 4 6 4
21 6 6 2
24 2 4 6
24 3 7 4
22 3 4 0
23 1 5 5
23 5 6 6
26 2 8 3
30 5 9 8
27 4 6 1
27 3 7 2
31 6 8 7
32 5...

output:

7 16 0 1 16 1 41 190 34 1 7 19 33 396 0 32 206 4354 1 155 4717 8 99 0 98 38329 0 0 114 1 15661 13011 41 10705 5146 4940 8054 9071 603 3700 396 0 0 7831 3114 212794 602 71562 18398 9071 4956 0 84026 4204 0 602 206 9657 213978 26366 0 206 74971 326703 0 603 793800 74162 311365 218511 202039 1 436929 5...

result:

wrong answer 1st numbers differ - expected: '8', found: '7'

Pretest #16:

score: 0
Wrong Answer
time: 300ms
memory: 36868kb

input:

16
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 1 1
1 1 1 0
2 1 2 0
7 2 3 2
3 2 2 0
6 2 2 0
8 2 3 0
11 1 5 1
11 2 5 3
11 3 3 4
14 2 6 2
14 2 3 0
12 2 3 0
12 4 5 0
16 3 7 1
19 3 7 2
18 3 4 2
21 2 4 0
22 1 3 0
21 1 6 6
21 4 5 3
21 1 7 4
23 1 10 2
26 1 6 4
23 9 10 0
25 7 8 1
25 3 9 2
27 9 11 3
29 4 11 7
33 2 6...

output:

2 2 1 0 2 3 9 1 1 99 107 3 2 15 224 108 479 114 115 573 3034 5383 0 228 23 1279 108 18 6 700 6 15 479 0 15 0 0 1267 215 1 685 0 19350 0 10187 3 9469 0 685 3947 1522 811 3229 700 0 4 1504 5 1520 1052 2694 1620 218 1535 1638 14279 458 8699 0 3 0 2209 0 234 206 1301 0 3949 0 573 5044 221 3158 6682 1625...

result:

wrong answer 1st numbers differ - expected: '55', found: '2'

Pretest #17:

score: 0
Wrong Answer
time: 296ms
memory: 36916kb

input:

17
4
100000
1 1 1 0
2 2 2 0
1 1 1 0
1 1 1 0
5 1 2 1
5 1 2 1
6 2 2 2
7 1 1 0
8 1 1 3
8 3 4 2
6 1 3 2
9 2 4 1
8 4 4 0
11 1 4 2
10 3 3 1
11 2 5 0
14 2 3 0
17 4 4 2
14 3 4 4
17 1 4 2
19 2 6 6
17 1 1 5
18 1 5 3
23 3 7 2
22 2 3 7
24 4 6 3
23 1 7 4
23 7 7 5
27 5 6 2
26 6 9 5
28 1 7 4
30 1 9 5
29 2 6 6
29 4...

output:

2 1 1 1 1 2 4 6 0 5 1 4 9 2 1 7 8 1 0 5 0 13 8 12 1 18 5 22 12 7 6 7 1 109 6 0 123 37 212 81 53 32 3 17 34 85 1 0 6 100 25 12 138 18 274 527 79 14 18 16 322 263 17 0 305 834 0 9 202 0 420 933 301 0 0 299 311 1448 0 893 0 0 891 53 819 420 0 0 387 2462 10 2 5289 54 337 4429 47 8 651 1196 819 18 318 0 ...

result:

wrong answer 4th numbers differ - expected: '54', found: '1'

Pretest #18:

score: 0
Wrong Answer
time: 293ms
memory: 36944kb

input:

18
4
100000
1 1 1 0
2 1 2 1
2 1 2 0
2 1 2 0
3 3 3 1
5 1 3 1
4 2 3 2
7 1 3 1
8 2 4 0
9 1 4 1
8 2 3 3
12 2 5 3
9 2 3 2
11 1 1 1
11 2 4 1
14 1 6 2
15 7 7 0
17 2 4 4
18 6 7 1
17 2 6 6
17 5 5 1
20 2 5 7
22 1 7 3
23 6 10 7
25 4 4 6
25 8 11 7
26 2 10 3
26 6 7 6
27 12 12 2
28 1 1 0
29 8 11 11
32 3 9 12
30 2...

output:

15 2 16 178 1 222 2 1274 32 1138 1 16 743 323 1674 1009 323 0 322 0 1867 129 1689 841 1770 817 3780 1234 2813 3780 96 156 0 2812 0 18418 3458 11156 25624 222 0 322 16 12109 1330 8959 194 3379 1162 0 1325 2657 4611 2657 59746 1461 1674 3531 2660 1425 10768 0 1690 10183 3151 3925 0 8245 6967 70563 0 1...

result:

wrong answer 1st numbers differ - expected: '60', found: '15'

Pretest #19:

score: 0
Wrong Answer
time: 301ms
memory: 36972kb

input:

19
4
100000
1 1 1 0
1 1 1 0
2 1 1 1
4 1 3 1
1 1 1 0
6 2 2 1
5 2 2 1
6 1 1 0
5 2 3 1
9 1 3 0
10 1 5 3
11 2 4 1
10 2 5 2
13 1 2 2
15 1 3 0
16 1 3 1
16 3 4 6
14 6 6 0
18 6 6 1
19 1 7 2
21 6 6 4
20 9 9 3
21 1 4 5
22 4 8 7
24 2 9 8
26 7 8 0
25 1 2 8
28 1 9 8
26 2 5 3
30 2 2 1
27 9 9 3
30 4 9 2
29 3 7 8
3...

output:

1 1 13 26 3 1 13 11 63 30 2 15 60 0 45 15 1 134 12 133 29 1 0 17 3 39 19 84 1086 3 13 1025 227 29 476 1150 1976 1057 582 4423 6533 459 728 6038 2975 540 471 433 14 669 436 270 429 9097 198 624 580 92 1944 297 2872 0 373 897 896 19 104 812 0 0 332 316 330 27 30884 42749 6 0 12765 0 806 9 1777 12571 0...

result:

wrong answer 1st numbers differ - expected: '38', found: '1'

Pretest #20:

score: 0
Wrong Answer
time: 290ms
memory: 37324kb

input:

20
4
100000
1 1 1 0
2 1 1 0
3 1 3 2
4 4 4 1
5 1 5 0
6 1 6 3
4 2 2 1
3 3 3 2
8 1 1 3
7 2 5 0
10 1 3 4
11 1 7 5
9 1 1 3
14 1 3 1
12 4 6 4
16 1 4 7
15 2 4 4
17 2 7 1
19 6 9 6
18 4 6 2
18 2 7 4
18 2 4 3
22 1 7 0
19 3 9 6
20 4 7 7
26 5 10 9
27 2 7 10
27 3 10 6
29 8 9 10
26 7 8 5
31 3 9 1
31 5 13 5
32 10 ...

output:

1 1 4 7 17 4 1 1 0 29 1 2 1 4 2 4 4 23 20 3 5 1 17 6 36 1 0 6 0 49 51 32 1 5 26 2 29 43 161 82 13 1 0 1 2 52 3 2 3 13 11 38 6 44 42 5 66 13 6 14 0 6 14 143 273 158 55 14 0 0 7 3 175 0 261 0 9 0 0 0 161 56 2 1022 975 134 91 1249 10 638 0 10 539 223 1087 268 2128 12 449 324 248 4 15 58 102 169 0 160 1...

result:

wrong answer 1st numbers differ - expected: '52', found: '1'


Final Tests

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 17864kb

input:

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

output:

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

result:

wrong answer 1st numbers differ - expected: '4', found: '3'

Test #2:

score: 0
Wrong Answer
time: 3ms
memory: 18224kb

input:

2
4
300
1 1 1 0
2 1 1 0
1 1 1 0
4 1 2 1
2 2 2 0
6 1 2 1
3 1 3 0
4 1 2 1
6 1 1 1
10 2 3 0
6 2 3 2
11 2 4 0
11 4 5 2
14 4 4 5
10 1 3 2
12 3 4 0
12 2 4 1
15 7 7 5
17 3 4 1
16 4 4 0
21 2 2 5
20 2 4 2
20 2 2 1
23 3 5 1
20 3 4 0
22 4 5 0
26 5 7 1
28 1 8 1
27 2 6 6
26 1 5 2
30 1 3 6
28 1 1 4
28 2 7 6
34 2 ...

output:

4 9 1 1 6 4 14 1 13 38 7 23 5 1 8 51 11 1 75 4 1 26 51 64 242 24 165 386 5 64 11 0 18 17 0 24 1 23 0 0 386 183 69 9 317 6 143 940 0 0 0 568 425 9 39 0 7 1783 767 1536 932 7242 386 339 3050 144 1472 3289 213 133 2794 32 375 2781 283 2626 3955 155 133 3160 190 2299 981 144 75 144 4916 0 2267 1545 8345...

result:

wrong answer 1st numbers differ - expected: '34', found: '4'

Test #3:

score: 0
Wrong Answer
time: 2ms
memory: 17576kb

input:

3
4
300
1 1 1 0
2 1 2 0
3 1 3 0
4 1 3 2
4 1 4 2
3 1 2 0
5 1 5 0
4 1 2 3
4 1 4 3
5 1 2 2
8 5 6 3
10 1 3 2
9 4 5 3
13 4 6 1
10 1 4 3
12 4 5 5
13 1 2 1
13 2 3 4
18 6 7 6
17 6 8 3
19 1 3 3
21 9 9 4
22 2 4 5
21 5 7 4
22 1 5 1
23 3 9 3
24 1 1 6
25 1 2 7
28 1 8 6
30 1 11 2
30 4 9 0
32 2 10 3
30 6 8 8
32 6 ...

output:

8 63 109 36 9 71 236 1 15 0 19 252 9 72 8 18 15 149 1 289 699 217 590 208 525 471 779 0 1542 4368 3701 1877 214 804 416 1892 194 1789 7609 7311 597 71 71 4803 5644 0 10198 0 597 58369 0 8309 34142 1437 0 1563 252 8516 44858 11337 128239 22150 16245 804 7460 7416 4376 7908 17620 10429 1877 538436 131...

result:

wrong answer 1st numbers differ - expected: '25', found: '8'

Test #4:

score: 0
Wrong Answer
time: 11ms
memory: 17952kb

input:

4
4
5000
1 1 1 0
2 1 2 1
1 1 1 0
4 1 1 0
1 1 1 0
3 2 3 2
6 1 2 1
5 1 2 0
8 3 3 1
10 1 3 2
8 2 2 0
11 1 5 4
11 3 5 3
13 4 5 3
12 3 3 1
16 1 5 1
13 4 5 5
18 1 5 5
17 1 6 5
17 1 5 4
20 5 7 4
19 1 1 7
23 1 8 3
23 4 6 4
23 8 9 7
24 3 4 2
27 3 6 3
28 5 8 9
26 1 4 4
27 3 10 8
28 8 11 9
31 4 6 3
31 10 10 2
...

output:

1 1 1 2 1 1 4 3 3 3 7 1 2 5 7 13 0 0 2 1 6 30 119 6 2 107 1 0 0 168 5 30 199 105 4 67 200 11 521 1463 0 656 836 74 181 0 575 181 181 19 0 0 171 19 0 19 30 320 0 4 7 0 159 186 0 607 0 1359 274 168 7 11 2 2842 11 13 498 209 267 20 633 30 0 205 11 1603 381 1841 18 0 635 1711 501 2489 156 12 0 7709 2345...

result:

wrong answer 1st numbers differ - expected: '3', found: '1'

Test #5:

score: 0
Wrong Answer
time: 12ms
memory: 19752kb

input:

5
4
5000
1 1 1 0
2 2 2 1
3 1 2 2
1 1 1 0
3 1 1 0
4 2 2 3
5 1 1 1
8 3 3 1
8 2 3 2
6 4 4 3
10 2 4 2
10 2 4 2
12 4 5 3
11 2 3 4
11 5 5 1
14 1 3 5
16 1 1 2
15 1 3 0
17 1 4 2
18 3 7 3
21 5 8 6
18 6 7 2
22 1 5 5
24 4 7 4
21 5 7 7
24 2 9 0
26 9 9 2
24 5 9 9
29 8 11 2
30 3 7 4
30 8 9 6
31 5 10 6
30 3 5 4
34...

output:

1 1 0 1 1 0 1 1 4 5 4 2 2 0 11 0 8 6 8 6 3 2 4 17 1 36 1 2 24 45 22 45 20 3 46 33 17 0 65 19 0 87 8 0 3 36 23 0 21 39 101 20 7 0 1 89 9 203 6 158 42 0 16 27 13 0 487 34 59 3 27 133 66 27 142 40 384 89 17 87 0 511 96 59 41 25 1395 315 143 122 1186 26 81 0 0 0 168 0 0 8 1203 9 1250 30 73 170 589 527 0...

result:

wrong answer 1st numbers differ - expected: '34', found: '1'

Test #6:

score: 5
Accepted
time: 320ms
memory: 43052kb

input:

6
4
100000
1 1 1 0
2 2 2 0
3 2 2 0
4 2 2 0
5 3 3 0
6 3 3 0
7 6 6 0
8 3 3 0
9 5 5 0
10 2 2 0
11 4 4 0
12 6 6 0
13 8 8 0
14 6 6 0
15 2 2 0
16 2 2 0
17 17 17 0
18 5 5 0
19 15 15 0
20 2 2 0
21 14 14 0
22 17 17 0
23 10 10 0
24 23 23 0
25 10 10 0
26 17 17 0
27 23 23 0
28 21 21 0
29 29 29 0
30 7 7 0
31 21 ...

output:

13 116 1159 11577 150385 1654119 16540031 198480359 787928493 734581969 103223677 120676063 963754385 618704320 378636756 206516872 241703175 693677871 68103114 817225791 671888130 60162705 601476665 456558188 30918290 836035627 422508580 961059777 721412290 780076554 866081801 542037914 961741065 6...

result:

ok 399996 numbers

Test #7:

score: 5
Accepted
time: 348ms
memory: 35596kb

input:

7
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
1 1 1 0
5 2 2 0
5 2 2 0
7 1 1 0
8 1 1 0
6 1 1 0
7 3 3 0
9 3 3 0
12 2 2 0
10 2 2 0
13 1 1 0
13 4 4 0
13 7 7 0
15 1 1 0
15 7 7 0
16 7 7 0
19 1 1 0
18 8 8 0
19 2 2 0
23 1 1 0
23 5 5 0
24 8 8 0
23 6 6 0
27 3 3 0
28 4 4 0
26 12 12 0
29 6 6 0
30 1 1 0
31 12 12 0
30 9 9 0...

output:

1 1 1 21 1 376 9022 162020 2 1 3879458 77588784 1 475771479 9043 1 475771500 836010287 21 836010287 21 723456114 723627157 3879458 171043 462547233 193433576 974019581 162021 821331611 162021 376 162020 686601685 418942555 31199510 217891022 462547233 836010287 944144826 217891022 575663750 44315401...

result:

ok 399996 numbers

Test #8:

score: 0
Wrong Answer
time: 273ms
memory: 43416kb

input:

8
4
100000
1 1 1 0
2 2 2 0
3 2 2 1
4 2 2 2
5 3 3 0
6 6 6 2
7 1 1 6
8 8 8 2
9 1 1 6
10 2 2 3
11 4 4 2
12 6 6 5
13 2 2 11
14 1 1 6
15 7 7 4
16 7 7 3
17 14 14 15
18 12 12 12
19 17 17 3
20 20 20 11
21 5 5 7
22 12 12 3
23 14 14 10
24 3 3 1
25 23 23 10
26 5 5 18
27 5 5 25
28 18 18 1
29 2 2 14
30 23 23 3
3...

output:

3 2 4 1 3 1 2 2 1 1 3 2 1 1 4 2 1 5 5 3 3 3 3 5 2 0 0 1 6 6 4 0 6 8 8 5 2 1 0 0 0 0 0 3 3 6 3 7 7 3 0 3 0 1 1 1 7 7 7 5 4 14 16 14 16 15 12 11 16 14 14 11 13 12 11 11 25 11 15 18 24 16 15 21 18 11 11 22 11 11 11 12 21 21 15 12 12 15 13 27 14 13 20 13 11 11 12 12 22 10 10 13 21 11 10 11 12 12 11 14 1...

result:

wrong answer 1st numbers differ - expected: '7', found: '3'

Test #9:

score: 0
Wrong Answer
time: 299ms
memory: 37052kb

input:

9
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 1 0
4 2 2 1
6 2 2 2
6 1 1 2
8 3 3 2
9 1 1 4
8 4 4 0
9 4 4 0
12 6 6 3
13 3 3 4
13 6 6 3
15 5 5 0
15 2 2 7
15 4 4 2
17 5 5 2
18 5 5 0
18 4 4 6
19 2 2 8
22 8 8 9
23 3 3 10
24 6 6 12
25 7 7 13
24 1 1 11
27 3 3 7
27 12 12 2
28 4 4 0
30 3 3 9
31 15 15 15
32 1 1 7
31 ...

output:

1 1 1 1 1 0 2 4 0 1 3 2 0 3 2 0 8 4 4 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 4 0 0 0 0 0 0 0 2 0 0 0 0 0 0 14 9 0 3 9 9 0 0 9 0 0 9 7 7 0 7 0 0 7 0 7 7 6 0 4 0 2 3 0 2 3 0 6 0 15 0 3 3 0 3 2 0 0 9 2 6 2 6 6 9 2 0 5 2 0 9 1 0 8 0 8 13 0 0 31 3 27 18 9 7 15 0 9 9 7 0 7 12 14 0 12 0 0 11 0 0 21 21 0 0 21 ...

result:

wrong answer 3rd numbers differ - expected: '15', found: '1'

Test #10:

score: 5
Accepted
time: 352ms
memory: 42920kb

input:

10
4
100000
1 1 1 0
2 1 1 0
3 3 3 0
4 3 4 0
5 3 5 0
6 1 4 0
7 5 5 0
8 5 7 0
9 3 6 0
10 6 10 0
11 1 2 0
12 8 11 0
13 4 12 0
14 2 12 0
15 7 10 0
16 6 8 0
17 13 15 0
18 8 9 0
19 2 6 0
20 8 14 0
21 3 18 0
22 11 18 0
23 5 11 0
24 6 12 0
25 3 24 0
26 13 23 0
27 3 8 0
28 14 22 0
29 4 26 0
30 1 5 0
31 13 17...

output:

16 527 25807 1883910 167667973 634982620 705207129 488881034 887725160 151025554 347960978 855383206 80305903 380559379 538908054 777587576 260990688 523673420 353610155 624705377 700258326 228676702 200177699 984634103 68249951 263072670 517709689 650106087 34684922 592160972 944601706 376074738 79...

result:

ok 399996 numbers

Test #11:

score: 5
Accepted
time: 368ms
memory: 36364kb

input:

11
4
100000
1 1 1 0
2 1 2 0
3 1 2 0
3 1 2 0
5 3 4 0
5 1 3 0
5 2 3 0
8 1 3 0
9 2 5 0
10 3 5 0
11 4 6 0
10 1 3 0
11 6 8 0
13 4 8 0
13 2 7 0
14 1 3 0
17 3 8 0
17 5 7 0
19 10 11 0
19 1 2 0
20 5 12 0
22 12 12 0
22 8 10 0
23 6 14 0
23 2 8 0
25 2 9 0
27 6 9 0
26 9 15 0
29 3 10 0
30 9 9 0
30 12 13 0
32 14 1...

output:

37 2478 2515 242769 38 245284 32040440 39124800 942462595 336524633 32285687 63297973 516597219 32285725 15628766 418384838 352153362 613054463 541763722 33194948 718423411 374189456 71408009 227001638 334965261 356495372 886316800 521955760 368374612 227507583 587492770 498900953 709154717 10323060...

result:

ok 399996 numbers

Test #12:

score: 5
Accepted
time: 354ms
memory: 36700kb

input:

12
4
100000
1 1 1 0
2 1 2 0
3 2 3 0
4 1 3 0
2 1 1 0
4 2 2 0
3 1 2 0
8 1 4 0
8 1 3 0
5 2 5 0
9 1 4 0
10 3 5 0
11 1 6 0
11 3 6 0
11 3 3 0
14 2 6 0
17 3 7 0
14 2 4 0
14 4 6 0
18 2 8 0
18 6 9 0
21 8 10 0
22 5 5 0
20 6 8 0
22 1 4 0
24 3 9 0
26 3 8 0
25 3 3 0
24 6 7 0
25 5 9 0
27 2 9 0
32 4 6 0
32 9 11 0
...

output:

69 7796 1278127 262008169 69 7796 39327 94385 55058 777304836 141577 7866 482180153 1285993 1278127 465685418 825856966 42346779 575383498 990228081 154169563 7866 833831197 726620149 749228357 498747852 817824963 482180153 41068652 699428075 474778269 447467594 402643074 564999930 7866 869370470 84...

result:

ok 399996 numbers

Test #13:

score: 0
Wrong Answer
time: 279ms
memory: 43336kb

input:

13
4
100000
1 1 1 0
2 1 2 1
3 1 2 2
4 1 3 2
5 1 5 4
6 1 4 4
7 6 6 1
8 3 7 5
9 3 4 4
10 5 6 2
11 6 9 4
12 5 11 9
13 1 3 4
14 6 10 10
15 4 6 8
16 3 8 6
17 1 9 3
18 3 13 8
19 3 11 10
20 2 4 11
21 12 13 0
22 13 17 20
23 9 17 1
24 10 11 16
25 22 25 9
26 5 9 4
27 12 27 26
28 13 13 22
29 8 23 1
30 21 23 19...

output:

1 1 0 1 2 5 7 7 7 16 8 4 2 2 9 58 74 30 9 9 16 2 76 3 3 138 3 28 384 179 471 463 161 812 465 121 137 405 475 332 128 24 24 176 442 3561 160 455 1126 114 135 3624 5691 6976 6824 9012 9004 78 1982 430 680 458 11208 0 6 2035 41 67204 13 13 34 66095 558 110245 69326 646 103722 1702 2208 8549 13 75042 20...

result:

wrong answer 1st numbers differ - expected: '25', found: '1'

Test #14:

score: 0
Wrong Answer
time: 292ms
memory: 35844kb

input:

14
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 2 1
1 1 1 0
5 1 1 2
6 1 1 0
6 2 2 1
5 2 3 2
5 1 2 1
7 2 2 1
8 1 2 1
11 2 4 1
11 4 4 2
15 2 4 0
13 1 3 3
15 1 3 3
18 2 4 4
16 2 5 5
16 4 4 0
18 6 6 4
22 4 4 5
18 2 5 5
20 5 6 5
24 1 6 4
25 5 6 2
22 3 4 1
28 3 7 0
25 2 4 4
29 1 6 4
27 3 8 0
28 5 5 7
30 2 3 1
33 ...

output:

1 1 1 4 1 0 1 1 1 5 4 1 6 3 14 0 1 0 0 4 2 0 0 2 5 36 22 14 0 8 27 0 2 3 0 63 38 0 11 38 1 4 10 5 0 37 34 0 6 0 103 112 65 104 402 2 0 665 13 350 0 37 96 656 8 10 0 104 164 1859 114 83 0 9 60 1111 26 9 945 566 6 14 0 1 825 11 129 38 1022 156 0 34 149 0 166 36 112 3 146 196 0 632 106 25 0 209 901 551...

result:

wrong answer 3rd numbers differ - expected: '68', found: '1'

Test #15:

score: 0
Wrong Answer
time: 287ms
memory: 37012kb

input:

15
4
100000
1 1 1 0
1 1 1 0
2 1 2 0
1 1 1 0
4 1 3 1
3 2 2 1
5 1 2 0
5 2 2 1
7 2 3 1
9 1 2 0
9 2 3 0
8 1 2 1
9 1 2 0
10 3 3 2
11 2 3 1
13 2 3 3
15 3 5 4
14 4 4 2
16 2 4 0
20 4 5 5
18 1 6 4
21 2 5 6
19 4 5 4
23 3 7 4
23 3 5 0
25 3 3 8
26 4 8 8
26 3 7 6
28 6 9 5
26 6 9 2
29 8 9 7
29 6 10 1
31 4 4 5
34 ...

output:

3 1 8 2 4 2 3 3 2 5 3 2 6 1 10 0 2 1 10 0 2 10 1 10 110 0 0 9 20 59 5 21 48 48 8 0 3 27 27 0 157 187 54 302 77 87 35 299 578 189 15 151 25 25 120 82 92 3 1080 593 624 627 427 0 258 0 35 162 12 18 2059 0 777 3 618 2 32 179 831 351 767 745 47 331 181 0 577 32 633 2068 2363 32 0 10 56 0 3349 1341 327 2...

result:

wrong answer 2nd numbers differ - expected: '5', found: '1'

Test #16:

score: 0
Wrong Answer
time: 293ms
memory: 37344kb

input:

16
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
1 1 1 0
5 2 2 1
5 1 1 0
5 1 2 1
4 1 2 0
7 1 2 2
6 1 2 0
7 2 3 0
12 1 4 0
11 1 1 2
13 1 4 0
14 3 3 4
12 1 4 0
16 2 2 1
18 1 7 5
19 6 6 5
20 4 5 1
17 2 5 4
22 1 3 4
23 1 3 3
21 5 5 9
22 3 4 3
24 1 7 3
23 2 5 1
27 2 5 4
25 2 8 7
29 6 7 3
27 5 9 6
30 10 11 6
30 1 2 3
...

output:

1 1 2 4 1 23 1 3 0 5 88 231 0 346 1 116 5 5 1 1 4 23 777 1 23 1473 231 1303 26 1245 55 23 0 231 5541 7911 18 31 25 10 7823 673 0 0 7591 6786 1260 800 3784 614 199 2277 3811 2781 161 0 8057 8078 2250 2527 1261 4798 1052 15864 2739 5 5018 2808 249 10598 11684 9991 36207 222 3782 93 227 3580 6451 45004...

result:

wrong answer 4th numbers differ - expected: '60', found: '4'

Test #17:

score: 0
Wrong Answer
time: 284ms
memory: 36964kb

input:

17
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 1 0
2 1 2 1
4 1 1 0
3 1 2 1
7 2 3 0
8 3 3 0
6 1 3 0
9 2 3 0
8 1 3 1
9 3 4 2
11 3 4 3
13 2 3 0
12 4 5 4
16 1 2 1
15 1 2 2
19 2 5 5
16 3 5 4
19 1 4 5
21 3 4 5
23 3 5 0
21 1 6 1
23 3 3 2
25 1 2 2
26 1 3 0
26 5 6 6
27 2 4 3
28 1 5 8
31 2 3 5
29 3 7 1
32 7 10 10
32...

output:

1 1 3 1 2 14 3 25 1 4 17 3 4 1 4 1 3 0 0 2 0 0 10 12 4 0 6 0 4 3 9 12 1 5 26 5 27 22 0 27 22 15 24 31 22 31 30 1 0 14 24 22 13 101 10 109 29 13 6 25 24 1 6 14 0 42 126 24 6 82 35 26 0 0 86 149 267 17 36 15 76 14 9 519 6 291 0 49 0 44 649 17 224 53 247 225 43 423 0 28 43 152 1608 14 0 0 382 105 0 323...

result:

wrong answer 1st numbers differ - expected: '4', found: '1'

Test #18:

score: 0
Wrong Answer
time: 291ms
memory: 36724kb

input:

18
4
100000
1 1 1 0
1 1 1 0
3 1 2 1
2 1 2 0
2 2 2 0
5 1 3 1
6 1 1 1
6 2 3 2
6 1 3 2
9 1 4 1
10 2 3 1
12 1 3 0
10 1 4 2
11 2 5 0
12 4 5 1
14 2 4 1
15 5 6 2
16 4 5 5
18 3 3 5
18 1 6 4
18 3 4 4
21 2 4 3
21 4 7 4
23 7 9 3
23 1 5 3
25 3 5 3
26 5 6 2
25 1 7 4
29 3 4 6
30 4 11 2
29 1 3 3
29 1 5 6
32 9 12 0...

output:

4 1 1 10 1 5 0 21 3 106 11 15 9 121 5 8 94 0 0 120 0 1486 26 1652 454 215 227 1525 132 1953 1573 0 5178 2544 4 5151 718 22 5125 586 9242 0 1821 11675 133 782 133 0 10204 742 3666 335 69 1 374 113 3606 9115 0 44810 133 10572 63562 9242 1700 49840 48177 26476 5421 0 67517 66690 0 0 0 66690 0 9274 3013...

result:

wrong answer 1st numbers differ - expected: '47', found: '4'

Test #19:

score: 0
Wrong Answer
time: 289ms
memory: 35704kb

input:

19
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 2 1
2 2 2 0
3 1 1 1
4 1 1 0
8 1 3 0
7 2 2 0
8 2 2 2
8 1 1 1
11 2 4 3
13 1 3 2
13 1 3 1
12 1 2 0
15 2 5 1
16 4 5 0
18 4 5 3
17 2 4 0
19 3 6 5
21 4 8 2
21 2 6 4
23 7 8 6
22 1 4 3
22 1 3 2
24 1 8 1
25 5 5 1
26 3 3 2
26 1 10 5
30 8 9 0
29 3 5 2
29 3 6 0
31 4 7 10
...

output:

2 1 6 1 1 0 41 48 1 0 34 1 41 88 150 49 75 68 89 33 546 122 88 150 518 523 75 310 314 82 647 722 19 2 3332 1186 47 382 47 1786 8 232 1 654 1857 1820 6 0 628 68 6 479 68 1378 520 0 0 0 5097 3795 4819 1527 9899 1786 1004 8685 4912 313 0 8198 0 1383 0 176 4761 75 5607 953 2494 264 8573 1028 7262 0 1035...

result:

wrong answer 1st numbers differ - expected: '3', found: '2'

Test #20:

score: 0
Wrong Answer
time: 294ms
memory: 36920kb

input:

20
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 2 1
5 1 1 0
4 1 2 1
5 1 1 2
8 4 4 0
8 1 2 3
10 3 4 0
11 5 5 3
10 3 4 2
11 2 3 3
12 1 7 6
14 1 2 1
15 5 8 3
15 1 2 6
17 5 8 4
17 3 4 0
18 7 9 6
20 1 10 2
21 1 4 9
22 1 9 9
23 3 8 6
25 3 7 8
24 2 7 6
27 1 9 8
27 12 12 8
29 3 11 3
30 2 6 4
31 6 14 8
30 6 8 3
33 8...

output:

1 1 1 1 1 1 1 1 0 2 1 2 0 7 2 14 2 3 23 3 20 0 9 1 0 17 0 19 193 55 12 113 14 73 35 129 137 83 46 27 59 0 49 0 0 4 0 4 394 285 49 0 49 112 5 1 13 0 25 328 1367 0 764 549 0 0 56 2 1164 0 44 495 0 193 369 1148 0 922 73 0 1335 57 0 1229 1 134 102 816 2585 1064 7 3112 6004 261 3 0 21 3 109 3591 1418 3 1...

result:

wrong answer 2nd numbers differ - expected: '44', found: '1'