QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524797#9159. 登山Butanlishi10 913ms255020kbC++144.2kb2024-08-20 07:36:272024-08-20 07:36:28

Judging History

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

  • [2024-08-20 07:36:28]
  • 评测
  • 测评结果:10
  • 用时:913ms
  • 内存:255020kb
  • [2024-08-20 07:36:27]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
//#define int long long
#define ci const int
#define rg int
#define ld long double
#define ls (x<<1)
#define rs (x<<1)|1
#define mid ((l+r)>>1)
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
#define fd(i,l,r) for(int i=(l);i>=(r);--i)
#define fu(i,l,r) for(int i=(l);i<(r);++i)
#define gcd __gcd
#define P(x) __builtin_popcountll(x)
#define W(x) __builtin_ctzll(x)
#define lowbit(x) (x&-x)
using namespace std;
ci N=1e6+5,mod=998244353; 
const ll inf=1e18;
inline ll read(){ll u,f=1;char o;while((o=getchar())<48||o>57)if(o==45)f=-1;u=(o^48);while((o=getchar())>=48&&o<=57)u=(u<<1)+(u<<3)+(o^48);return u*f;}
void write(ll x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+48);}
mt19937 rad(chrono::steady_clock::now().time_since_epoch().count());
ll n,m,s;
struct BIT
{
	ll dfn[N],ed[N],tree[N];
	vector<ll>w[N];
	void add(int x,ll v)
	{if(x==0)return;
//		cout<<x<<' '<<v<<'\n';
		for(rg i=x;i<=n;i+=lowbit(i))tree[i]=(tree[i]+v)%mod;
	}
	ll cha(int x)
	{
		ll q=0;
		for(rg i=x;i;i-=lowbit(i))q=(q+tree[i])%mod;
		return q;
	}
}t1,t2;
ll ceng[N],last[N],l[N],r[N],lim[N],f[N],qz[N],to[N],use[N],seg[N];
ll lca[N][20],zhi[N][20];
vector<ll>ch1[N],ch2[N],ch3[N];
struct node
{
	ll id,tp;
};
vector<node>add[N];
void clear()
{
	fo(i,1,n)vector<ll>().swap(t1.w[i]);
	fo(i,1,n)vector<ll>().swap(t2.w[i]);
	fo(i,1,n)vector<ll>().swap(ch1[i]);
	fo(i,1,n)vector<ll>().swap(ch2[i]);
	fo(i,1,n)vector<ll>().swap(ch3[i]);
	fo(i,1,n)vector<node>().swap(add[i]);
	memset(use,0,sizeof(use));
	memset(qz,0,sizeof(qz));
	memset(t1.tree,0,sizeof(t1.tree));
	memset(t2.tree,0,sizeof(t2.tree));
}
void dfs(int x,int c)
{
	ceng[x]=c;
	last[c]=x;
	t1.dfn[x]=++s;
	if(x!=1)
	{
		lim[x]=c-lim[x]-1;
		int L=ceng[x]-r[x],R=ceng[x]-l[x];
		l[x]=L,r[x]=R;
//		cout<<x<<' '<<lim[x]<<' '<<l[x]<<' '<<r[x]<<'\n';
		ch1[last[l[x]-1]].push_back(x);
		if(lim[x]>=r[x])ch2[last[r[x]]].push_back(x);
	}
	for(auto d:t1.w[x])
	{
		int s=0;
		zhi[d][0]=lim[x];
		lca[d][0]=x;
		while(lca[lca[d][s]][s])
		{
			zhi[d][s+1]=min(zhi[d][s],zhi[lca[d][s]][s]);
			lca[d][s+1]=lca[lca[d][s]][s];
//			cout<<d<<' '<<s+1<<' '<<zhi[d][s+1]<<'\n'; 
			++s;
		}
		dfs(d,c+1);
		int now=d;
		fd(i,19,0)
		{
//			cout<<now<<' '<<i<<' '<<lim[d]<<'\n'; 
			if(zhi[now][i]>=lim[d])
			{
				now=lca[now][i];
			}
		}
		now=lca[now][0];
//		cout<<now<<' '<<d<<'\n';
		t2.w[now].push_back(d);
	}
	t1.ed[x]=s;
}
void tree(int x)
{//cout<<x<<' ';
	seg[t2.dfn[x]=++s]=x;
	for(auto d:t2.w[x])
	{
		to[d]=x;
		tree(d);
	}
	t2.ed[x]=s;
//	cout<<x<<' ';
	add[t2.dfn[x]-1].push_back({x,-1});
	add[t2.ed[x]].push_back({x,1});
	ch3[lim[x]].push_back(x);
}
void dfs1(int x)
{
	if(x!=1)
	{
		f[x]=(t1.cha(t1.ed[x])-t1.cha(t1.dfn[x]-1)+mod)%mod;
		qz[x]=(qz[x]+f[x])%mod;
	}
	for(auto d:ch1[x])//-
	{
		int now=d;
		fd(i,19,0)if(zhi[now][i]>=l[d])
		{
			now=lca[now][i];
		}
		now=lca[now][0];
//		cout<<x<<' '<<d<<"@ "<<now<<'\n';
		t1.add(t1.dfn[now],qz[x]);
		t1.add(t1.dfn[d],mod-qz[x]);
	}
	for(auto d:ch2[x])//+
	{
		int now=d;
		fd(i,19,0)if(zhi[now][i]>=r[d])
		{
			now=lca[now][i];
		}
		now=lca[now][0];
//		cout<<x<<' '<<d<<"! "<<now<<' '<<f[x]<<'\n';
		t1.add(t1.dfn[now],mod-qz[x]);
		t1.add(t1.dfn[d],qz[x]);
	}
	for(auto d:ch3[x])//+
	{
//		cout<<x<<' '<<d<<' '<<use[d]<<' '<<qz[x]<<'\n';
		t1.add(t1.dfn[to[d]],mod-use[d]*qz[x]%mod);
		t1.add(t1.dfn[d],use[d]*qz[x]%mod);
	}
	for(auto d:t1.w[x])
	{
		qz[d]=qz[x]; 
		dfs1(d);
	}
}
signed main()
{//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	int id=read();
	int T=read();
	while(T--)
	{
		n=read();
		clear();s=0;
		fo(i,2,n)
		{
			ll x=read();
			t1.w[x].push_back(i);
			l[i]=read();
			r[i]=read();
			lim[i]=read();
		}
		qz[1]=f[1]=1;
		dfs(1,1);
		s=0;
		tree(1);
		fo(i,1,n)
		{//cout<<i<<'\n';
			t2.add(l[seg[i]],1);
			t2.add(r[seg[i]],-1);
//			cout<<i<<'\n';
			for(auto d:add[i])
			{
				use[d.id]+=d.tp*t2.cha(lim[d.id]);
//				cout<<i<<' '<<d.id<<' '<<d.tp*t2.cha(lim[d.id])<<'\n';
			}
		}
//		fo(i,1,n)cout<<use[i]<<' ';
		dfs1(1);
		fo(i,2,n)cout<<f[i]<<' ';cout<<'\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 24ms
memory: 176792kb

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 4 2 1 5 
3 4 3 1 998244352 
1 2 1 2 2 
2 2 5 3 3 

result:

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

Pretest #2:

score: 0
Wrong Answer
time: 32ms
memory: 180536kb

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:

19 18 35 1 38 998244348 998244310 998244280 998244333 14 187 187 998244352 484 49 998244352 998244335 450 998244285 998244333 44 172 285 998244315 381 998243897 358 122 998244351 998243232 1710 513 36 1371 998244285 998243829 37 998242713 847 2442 19 998244280 173 998244333 19 858 998243365 99824338...

result:

wrong answer 6th numbers differ - expected: '15', found: '998244348'

Pretest #3:

score: 0
Wrong Answer
time: 23ms
memory: 175708kb

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:

20 18 40 1 232 80 39 211 228 41 189 920 56 998244352 941 710 118 998244082 1194 1128 998244314 998243722 998243261 998244332 998239517 3034 899 998239479 998239060 1 998240399 998243643 998244142 7818 565 2653 2721 1203 998237103 411 998241593 4037 7856 6276 7196 38 44 4179 2967 6787 998236330 3263 ...

result:

wrong answer 5th numbers differ - expected: '233', found: '232'

Pretest #4:

score: 0
Wrong Answer
time: 40ms
memory: 183372kb

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 28 56 25 2 81 84 1 79 998244345 998244268 29 998244104 0 998244349 101 194 477 0 998244083 559 165 998244083 232 998244328 72 998244263 998244303 998244151 771 538 998244350 998242993 1369 149 2819 1441 998244340 998244340 1358 998242642 998244207 998244092 998243416 1 585 998242903 998243220 27...

result:

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

Pretest #5:

score: 0
Wrong Answer
time: 38ms
memory: 185276kb

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 35 2 3 33 5 34 3 34 79 206 1 998244250 137 267 5 998244317 121 86 998244238 116 998243965 67 110 998244281 998243440 171 998243926 35 998244317 998244313 102 144 998243759 75 998243864 998244284 39 998243864 67 329 0 67 29 998244250 998244088 998243371 998243867 998243965 998243672 998244308 99824...

result:

wrong answer 5th numbers differ - expected: '34', found: '33'

Pretest #6:

score: 5
Accepted
time: 671ms
memory: 248436kb

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: 0
Wrong Answer
time: 773ms
memory: 237180kb

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:

wrong answer 200001st numbers differ - expected: '723', found: '677'

Pretest #8:

score: 0
Wrong Answer
time: 680ms
memory: 245216kb

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:

12 23 22 21 42 4 3 998244314 998244344 998244213 998244263 998244302 76 998244339 998244303 39 16 55 82 122 43 190 179 89 998244253 998244241 998244218 5 139 117 998243768 185 998244165 96 41 998244027 60 200 95 56 104 65 5 998244288 998244127 258 237 182 998243804 87 44 42 998243771 998243592 99824...

result:

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

Pretest #9:

score: 0
Wrong Answer
time: 653ms
memory: 234856kb

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:

4 6 998244352 1 23 998244352 11 43 998244329 1 5 998244332 60 1 998244286 2 998244287 17 1 194 998244330 998244287 998244330 177 998244329 1 43 221 998244329 51 23 17 998244226 375 998243617 998243838 998243771 998243992 998243191 113 998243617 645 194 998243617 998244208 425 998243589 998243426 243...

result:

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

Pretest #10:

score: 5
Accepted
time: 694ms
memory: 247224kb

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: 0
Wrong Answer
time: 768ms
memory: 235060kb

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 15493 46 998133676 3484 50 997235325 998156013 3443 998152570 997661164 998064272 44570333 3442 189637360 464948842 232520291 522349409 203596874 929989425 998152652 42978073 640061809 998152611 597458038 797851216 247154854 663324736 998133676 232504799 764707807 384541484 847442286 ...

result:

wrong answer 6th numbers differ - expected: '407995', found: '15493'

Pretest #12:

score: 0
Wrong Answer
time: 807ms
memory: 237904kb

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 248 45 4491 630 42516 585 1507 115956 77931 997427863 309843 115956 989623204 981730134 988922670 293 149614551 322947942 45 133263588 243732553 133100332 787098590 989081434 816768528 116248 115956 725183405 812148481 118642428 690553698 406632269 690506443 360771705 25477142 690390443 1348326...

result:

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

Pretest #13:

score: 0
Wrong Answer
time: 789ms
memory: 245192kb

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:

28 54 25 108 998244295 242 159 77 23 897 789 923 708 1680 524 998239005 1064 1202 998244028 2989 998244074 998243815 998238194 2689 80 1841 1167 532 998238362 998243906 998244168 734 842 736 998243695 998240075 998235528 998239456 759 998239765 602 12075 10262 2174 6457 6642 5168 2132 2300 998241961...

result:

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

Pretest #14:

score: 0
Wrong Answer
time: 805ms
memory: 236332kb

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:

38 998244352 2 37 1 150 111 39 34 998244310 109 998244314 226 31 336 998244159 998244201 295 998244308 998243982 998244307 291 30 998244352 185 331 998244352 34 1725 100 254 1034 437 998244033 295 998243664 998244201 998242376 1062 998244256 2740 268 57 122 998244122 58 998244040 998243982 719 99824...

result:

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

Pretest #15:

score: 0
Wrong Answer
time: 735ms
memory: 232748kb

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:

8 69 998244352 2 68 998244284 62 326 139 0 8 69 36 256 998244352 27 69 2428 1 80 2032 8 998244284 998244282 1 6394 998244344 998244352 1 1 1629 4183 998244344 978 998244098 998243703 998240344 998243838 582 998243093 998244026 998243701 998244283 998242838 1428 26680 998239892 12573 998242871 4460 3...

result:

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

Pretest #16:

score: 0
Wrong Answer
time: 720ms
memory: 235980kb

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:

55 2 1 998244352 2 109 53 1 1 93 998244280 56 998244299 0 713 146 496 567 256 332 935 2202 998244297 405 998244187 383 998244188 56 259 734 165 0 998244280 998243287 95 998244042 998244135 53 998243256 998243497 278 998243619 998243183 998242882 998243401 998244230 998244115 998243619 1484 998244226...

result:

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

Pretest #17:

score: 0
Wrong Answer
time: 782ms
memory: 237388kb

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 54 51 2 48 59 998244247 104 1 57 58 3 51 196 58 51 998244352 998244300 0 998244139 998244312 258 998244096 254 7 176 101 154 1 2 998244300 827 153 998244124 597 128 998244166 53 153 560 4 998243271 998244050 964 998244097 998243899 998244200 965 998244306 998244305 998244329 998242999 1582 998...

result:

wrong answer 7th numbers differ - expected: '49', found: '48'

Pretest #18:

score: 0
Wrong Answer
time: 776ms
memory: 236268kb

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:

60 2 64 1192 1 1131 3 3466 125 2210 0 61 1318 998238141 5789 187 998243991 998243100 998243990 998244352 2444 998242738 1252 716 998244282 2449 5789 998239152 998240850 5789 585 998239149 998243230 998241972 998241969 998227172 1425 998234746 998242941 998243225 492 4364 998242928 1598 998244200 998...

result:

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

Pretest #19:

score: 0
Wrong Answer
time: 790ms
memory: 235732kb

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:

38 1 36 873 5 1 36 84 828 181 39 91 715 998244264 998244182 998244088 998244264 715 85 714 711 1 998243408 675 3 945 998241070 403 442 3 36 6138 998243244 998244352 650 2257 998243739 3279 1542 15020 117 998244352 3205 998242448 998243346 998243330 947 2977 998243850 3596 4358 1895 3881 998240363 99...

result:

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

Pretest #20:

score: 0
Wrong Answer
time: 814ms
memory: 236436kb

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:

52 103 49 571 1190 414 200 2 998244245 2068 998244294 155 998244198 256 200 998244193 104 2632 2043 157 311 49 673 204 1634 103 998244056 3629 998243948 18152 4955 3254 52 1810 2749 155 2039 998240003 27083 9677 2304 103 998237807 1761 53 6902 998237871 155 998237807 3479 2227 297 82 39 998239816 36...

result:

wrong answer 9th numbers differ - expected: '97', found: '998244245'


Final Tests

Test #1:

score: 0
Wrong Answer
time: 39ms
memory: 176884kb

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:

4 10 5 0 1 
1 2 0 2 3 
5 1 6 1 6 
1 998244352 2 1 998244352 

result:

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

Test #2:

score: 0
Wrong Answer
time: 24ms
memory: 176272kb

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:

34 69 3 1 236 34 104 1 138 679 28 408 1 998244319 69 928 271 1 893 998243979 998243945 998244283 928 1192 964 374 735 305 0 998244318 0 998241269 193 998244352 998244319 0 998244319 388 998243875 998243944 1960 998241678 1227 89 998243229 69 270 1628 998241269 998244318 998240104 4011 1892 20 998240...

result:

wrong answer 9th numbers differ - expected: '173', found: '138'

Test #3:

score: 0
Wrong Answer
time: 31ms
memory: 175840kb

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:

25 249 421 129 26 274 877 998244328 16 998244078 52 1288 26 275 25 26 130 488 1 1899 2978 825 2557 799 998244078 998244352 998242140 998242573 5925 8624 6721 645 548 636 1792 7953 998244242 2486 998243074 15968 2488 274 274 3037 998242456 998241865 998241906 998236330 2488 12639 998241865 16493 9982...

result:

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

Test #4:

score: 0
Wrong Answer
time: 42ms
memory: 180476kb

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:

3 2 1 4 41 1 40 5 42 41 93 34 4 81 52 7 32 998244344 2 3 82 998244155 998243987 998244277 42 998244009 998244115 998244229 998244154 998244224 998244322 998244178 998243224 998244238 998244317 998244296 998243184 40 998243684 998238965 998244311 998243896 998241075 998244329 998243355 998244188 9982...

result:

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

Test #5:

score: 0
Wrong Answer
time: 48ms
memory: 178692kb

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:

34 33 998244352 6 65 998244318 4 1 4 32 42 35 7 998244318 197 998244342 31 62 998244349 161 94 35 998244310 65 0 647 1 25 998244073 319 229 484 998243392 132 520 647 998243991 998244015 523 132 998243822 434 998244023 998243127 23 435 998244228 998243960 198 998244316 568 133 1674 998243355 34 99824...

result:

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

Test #6:

score: 5
Accepted
time: 708ms
memory: 255020kb

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: 0
Wrong Answer
time: 745ms
memory: 235124kb

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:

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

Test #8:

score: 0
Wrong Answer
time: 808ms
memory: 245332kb

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:

7 13 12 998244350 18 5 998244309 25 15 20 998244338 29 998244308 998244273 43 18 3 2 50 37 70 71 51 106 36 998244265 998244195 11 998243987 998244344 35 188 179 998244336 998244294 998244287 998244280 998244325 998244270 998244091 998244328 174 360 998244340 998244279 998244347 998244125 998244309 3...

result:

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

Test #9:

score: 0
Wrong Answer
time: 782ms
memory: 236536kb

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 15 1 14 998244352 998244350 57 998244326 1 42 27 998244326 23 998244350 998244238 30 83 57 998244269 998244203 998244349 998244318 998244200 998244200 36 16 14 51 55 10 998244266 998244292 998244251 15 10 21 68 17 998244303 47 998244349 998244238 998244238 998244327 214 135 10 312 253 125 998244...

result:

wrong answer 6th numbers differ - expected: '0', found: '998244352'

Test #10:

score: 5
Accepted
time: 817ms
memory: 247004kb

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: 0
Wrong Answer
time: 849ms
memory: 236580kb

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 807420 38497285 131950165 91134175 1052667 343807729 238768717 1052705 171500154 69544659 262634292 533473697 723382935 603018356 780341825 446670089 39547474 456613145 884261448 953454451 932921248 123179148 955343168 571455901 641955294 793160964 332687184 351992227 3...

result:

wrong answer 7th numbers differ - expected: '32040440', found: '807420'

Test #12:

score: 0
Wrong Answer
time: 830ms
memory: 237776kb

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 1333185 55058 777304836 1380377 7866 347683919 1285993 1278127 322433592 712094231 42346779 390062021 712480021 405569938 7866 811123294 388776029 217607142 391979996 426314168 347683919 41068652 382348766 102293246 441853408 149449423 905582452 7866 211708639...

result:

wrong answer 8th numbers differ - expected: '94385', found: '1333185'

Test #13:

score: 0
Wrong Answer
time: 913ms
memory: 245880kb

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:

25 24 22 48 23 96 194 169 118 284 213 96 998243608 998244328 998243797 1439 1000 865 265 109 214 998244280 998243533 998243133 93 2474 21 230 8638 4902 5489 5276 3656 3727 741 998243471 2924 5790 5670 950 998242878 998241013 998242466 998209855 6802 36590 1885 7500 998232440 998214303 91532 90245 69...

result:

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

Test #14:

score: 0
Wrong Answer
time: 808ms
memory: 234436kb

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 68 67 2 998244284 2 1 1 67 67 0 136 64 268 998244352 998244347 998244284 998244352 67 64 998244217 998244352 2 1 66 317 260 998244150 0 533 998244279 1 916 998244028 858 0 998244153 189 567 1 998244286 998243770 61 998244352 264 73 998243711 998244150 998244028 134 998243476 578 202 409 99824415...

result:

wrong answer 6th numbers differ - expected: '0', found: '998244284'

Test #15:

score: 0
Wrong Answer
time: 787ms
memory: 236396kb

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 5 8 46 4 4 49 44 13 224 47 2 92 7 134 998244352 2 2 353 39 4 998244346 1 11 384 998243551 998244352 14 448 998244013 90 317 998243733 229 998244318 998244306 998244221 998244133 998243614 998243904 1185 998244105 998242651 998243610 237 228 998243205 813 2059 429 998243218 1218 998244153 79 377 99...

result:

wrong answer 7th numbers differ - expected: '93', found: '49'

Test #16:

score: 0
Wrong Answer
time: 850ms
memory: 236520kb

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 60 3 177 1 3 998244352 65 118 358 998244291 713 998244294 408 998244294 3 4 998244166 52 998244170 998243645 998244287 998244294 1107 755 1044 998244297 2448 3 71 231 60 1458 2896 56 998244000 998244056 47 2778 998243480 998243321 998242277 2014 998242633 998242461 998243462 998244352 99823911...

result:

wrong answer 6th numbers differ - expected: '355', found: '177'

Test #17:

score: 0
Wrong Answer
time: 826ms
memory: 236252kb

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:

4 54 4 4 3 19 53 34 1 9 24 59 5 1 49 1 998244245 998244339 998244352 50 998244348 998244346 161 998244204 998244228 998243979 998244152 998244298 998244195 998244234 998244211 204 0 998244156 998244299 55 102 998244316 998244186 998244237 998243759 998244131 998244286 998244102 998244298 998243611 1...

result:

wrong answer 12th numbers differ - expected: '159', found: '59'

Test #18:

score: 0
Wrong Answer
time: 876ms
memory: 235988kb

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:

47 2 1 96 44 48 998244305 40 3 1575 90 137 95 1615 47 94 1483 998244352 998244221 1527 998244261 4240 998244352 2433 3150 998242838 3190 3956 998239691 10571 998241691 998241078 1746 14115 47 1614 3544 998244305 1615 27 998242686 998244221 998242778 998236201 998231761 998244351 1707 998242555 99824...

result:

wrong answer 7th numbers differ - expected: '0', found: '998244305'

Test #19:

score: 0
Wrong Answer
time: 839ms
memory: 234196kb

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:

3 1 43 1 1 998244352 154 198 1 0 63 1 998244311 998244242 518 5 301 257 998244243 60 998243955 155 155 998243880 998241487 352 301 998242950 70 998243639 998244272 220 998243618 998244157 998243305 824 197 1330 198 998244200 998243049 779 1 998244002 998237037 63 998243397 998243354 998240231 998243...

result:

wrong answer 6th numbers differ - expected: '0', found: '998244352'

Test #20:

score: 0
Wrong Answer
time: 753ms
memory: 236100kb

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 44 2 43 43 1 998244350 1 998244349 84 85 87 998244265 41 50 294 998244190 80 295 88 126 998244188 41 0 998244272 395 3 342 499 998243973 40 802 294 998244231 998244277 998244221 998243750 998244137 998243330 584 998243633 998244188 998243677 998244103 998243768 998244346 998244062 998244303 998243...

result:

wrong answer 7th numbers differ - expected: '42', found: '998244350'