QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#509910#9159. 登山JCY_35 411ms40960kbC++173.2kb2024-08-08 19:41:582024-08-08 19:41:59

Judging History

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

  • [2024-08-08 19:41:59]
  • 评测
  • 测评结果:35
  • 用时:411ms
  • 内存:40960kb
  • [2024-08-08 19:41:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i128 = __int128;
using u128 = unsigned __int128;
template <typename T>
void chkmax(T &x, const T &y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, const T &y) {
  x = min(x, y);
}
constexpr int MOD = 998244353;
int add(int x, int y) {
  x += y;
  return x >= MOD ? x - MOD : x;
}
int sub(int x, int y) {
  x -= y;
  return x < 0 ? x + MOD : x;
}
void inc(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
constexpr int MAXN = 1e5 + 10;
int n, anc[17][MAXN], dep[MAXN], mn[17][MAXN], cnt[MAXN], dp[MAXN], dfn[MAXN], lst[MAXN], dfc;
vector<int> g[MAXN];
pair<int, int> rg[MAXN];
vector<tuple<int, int, int>> buc[MAXN];
namespace bit {
int bit[MAXN];
void clear() { fill(bit + 1, bit + n + 1, 0); }
void update(int p, int x) {
  for (; p <= n; p += p & -p) inc(bit[p], x);
}
int query(int p) {
  int ret = 0;
  for (; p >= 1; p -= p & -p) inc(ret, bit[p]);
  return ret;
}
}  // namespace bit
int jump(int u, int k) {
  for (int i = 0; 1 << i <= k; ++i)
    if (k >> i & 1) u = anc[i][u];
  return u;
}
int find_le(int u, int x) {
  for (int i = 16; i >= 0; --i)
    if (mn[i][u] >= x) u = anc[i][u];
  return u;
}
void dfs(int u) {
  dfn[u] = ++dfc;
  for (auto v : g[u]) dfs(v);
  lst[u] = dfc;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int sid, cas;
  cin >> sid >> cas;
  while (cas--) {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      buc[i].clear();
      g[i].clear();
      cnt[i] = 0;
    }
    dep[1] = 1;
    for (int i = 2, l, r, h; i <= n; ++i) {
      cin >> anc[0][i] >> l >> r >> h;
      g[anc[0][i]].emplace_back(i);
      dep[i] = dep[anc[0][i]] + 1;
      rg[i] = {dep[i] - r, dep[i] - l};
      mn[0][i] = dep[i] - h - 1;
    }
    dfc = 0;
    dfs(1);
    for (int i = 1; i < 17; ++i) {
      for (int j = 1; j <= n; ++j) {
        anc[i][j] = anc[i - 1][anc[i - 1][j]];
        mn[i][j] = min(mn[i - 1][j], mn[i - 1][anc[i - 1][j]]);
      }
    }
    for (int i = 2; i <= n; ++i) {
      int up1 = find_le(i, rg[i].first);
      buc[jump(i, dep[i] - rg[i].first + 1)].emplace_back(i, up1, MOD - 1);
      int up2 = find_le(i, rg[i].second);
      buc[jump(i, dep[i] - rg[i].second)].emplace_back(i, up2, 1);
      ++cnt[up2];
      --cnt[up1];
    }
    for (int i = n; i >= 2; --i) {
      int up = find_le(i, mn[0][i]);
      buc[mn[0][i]].emplace_back(i, up, cnt[i]);
      cnt[up] += cnt[i];
    }
    bit::clear();
    for (int i = 1; i <= n; ++i) {
      if (i == 1) {
        dp[i] = 1;
      } else {
        dp[i] = add(dp[anc[0][i]], sub(bit::query(lst[i]), bit::query(dfn[i] - 1)));
      }
      for (auto [x, y, c] : buc[i]) {
        bit::update(dfn[x], (ll)dp[i] * c % MOD);
        bit::update(dfn[y], (ll)dp[i] * (MOD - c) % MOD);
      }
    }
    for (int i = 2; i <= n; ++i) cout << sub(dp[i], dp[anc[0][i]]) << " \n"[i == n];
  }
  return 0;
}
/*
g++ B.cpp -o B -std=c++17 -O2 -Wall -Wextra -Wshadow -g -fsanitize=address,undefined
*/
/*
0 1
5
1 1 1 0
2 1 1 0
2 1 2 1
4 2 3 0
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 5
Accepted
time: 0ms
memory: 23568kb

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

result:

ok 20 numbers

Pretest #2:

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

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 15 50 0 0 15 263 261 0 525 109 0 22 490 0 0 103 202 307 0 556 0 378 281 2 998243077 2277 782 112 1831 118 1763 37 265 1132 2983 19 0 211 0 19 1049 2877 2139 18885 9423 7317 664 2019 14251 0 12712 998243863 1643 59 998243873 2766 2766 2609 1132 986 707 0 9901 3210 998233969 54154 9 0 26...

result:

wrong answer 11th numbers differ - expected: '349', found: '263'

Pretest #3:

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

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 233 80 39 212 229 41 190 1275 56 0 1252 713 118 0 1234 1293 0 1190 727 23 174 3389 903 136 688 1 0 0 688 13484 2454 5557 3391 6721 7281 477 0 0 8732 7147 8422 38 4074 39250 3638 436 13427 3779 7390 4576 0 1147 6971 0 1813 998241826 998240234 85 0 123 998239370 0 60 63 998244107 998237540 ...

result:

wrong answer 12th numbers differ - expected: '5094', found: '1275'

Pretest #4:

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

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 21 0 29 21 0 25 101 194 674 87 0 669 165 998244170 342 998244328 182 20 241 60 472 210 305 0 4091 158 4091 1968 998244349 998244349 1811 1 3749 1 2738 1 2511 0 998242884 2012 0 15722 4588 11109 163 2210 141 202 703 367 1580 2650 1176 214 1140 299 614 0 0 4375 998241407 1964...

result:

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

Pretest #5:

score: 0
Wrong Answer
time: 6ms
memory: 24076kb

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 34 5 34 3 35 79 243 1 0 173 305 5 67 158 123 67 153 0 67 147 31 0 281 998243922 35 0 29 103 217 0 147 0 0 111 0 71 859 3 68 98 998244257 998244117 998243834 3 0 998243789 1053 998244309 998244003 998243698 998244346 998243949 998243410 173 998242811 979 8 998243149 998244227 998244299 8 326...

result:

wrong answer 10th numbers differ - expected: '277', found: '79'

Pretest #6:

score: 5
Accepted
time: 362ms
memory: 39044kb

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: 354ms
memory: 40516kb

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: 5
Accepted
time: 330ms
memory: 39856kb

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 62 61 19 49 7 26 7 77 76 76 156 133 114 258 102 102 41 41 48 48 36 13 6 140 118 41 203 155 155 41 61 61 61 328 279 279 123 111 111 111 225 204 90 109 252 150 109 150 109 47 47 28 28 28 6 120 120 6 18 18 59 59 18 32 32 32 73 73 73 672 631 631 352 311 32 380 483 374 408 275 395 275 234 ...

result:

ok 399996 numbers

Pretest #9:

score: 5
Accepted
time: 336ms
memory: 40552kb

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 0 1 23 0 11 44 0 1 5 3 62 1 0 2 1 18 1 220 1 1 45 202 0 1 44 399 0 179 23 18 0 554 0 0 155 155 0 261 0 701 220 0 1214 971 23 417 269 155 148 0 779 0 85 40 62 756 62 554 1011 40 0 0 40 220 2426 18 0 0 0 2425 18 650 40 0 3399 502 2845 479 0 0 1631 62 0 62 18 1170 62 345 283 2428 646 1214 491 283 1...

result:

ok 399996 numbers

Pretest #10:

score: 5
Accepted
time: 411ms
memory: 39052kb

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: 400ms
memory: 39748kb

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 15721 46 998133904 3484 50 997231937 998156473 3443 998153026 997632988 998065188 44628521 3442 190889418 467507574 233806356 533043949 226445200 935113360 998153108 43018551 393883915 998153067 621486350 809865372 262559141 105730467 998133904 233783709 157993498 471442680 651490683 ...

result:

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

Pretest #12:

score: 0
Wrong Answer
time: 409ms
memory: 40500kb

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 129636 91611 997468903 350883 129636 989625679 980262594 988979865 293 139567831 322694847 45 121763008 569078898 121586072 309054746 989152309 131546885 129928 129636 775637942 92953025 133546037 5945530 175397324 5898275 838397543 224492010 5768595 393735354 966...

result:

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

Pretest #13:

score: 5
Accepted
time: 351ms
memory: 39688kb

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 55 26 109 25 246 162 79 24 1161 1052 1188 970 2125 699 480 1822 2880 993 4442 286 21 21 3699 298 9538 1352 622 189 189 1481 1505 15694 21512 834 834 5007 968 968 14494 725 23023 12855 17501 26963 26963 4370 55916 2673 2458 139790 114009 120206 117382 44163 44163 43673 53833 619 71600 8518 22800 2...

result:

ok 399996 numbers

Pretest #14:

score: 0
Wrong Answer
time: 356ms
memory: 40064kb

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 0 2 37 1 150 112 39 34 33 109 0 226 32 337 32 998244207 296 998244314 0 998244313 292 30 2 227 371 2 34 1882 416 255 1113 514 42 296 0 966 966 1780 206 3975 364 76 432 141 71 68 0 1085 0 1746 875 701 6427 2 5607 1 2183 174 39 24 1927 17017 998239904 24857 1524 337 0 17029 1751 1833 17487 1224 0 9...

result:

wrong answer 7th numbers differ - expected: '149', found: '112'

Pretest #15:

score: 0
Wrong Answer
time: 335ms
memory: 40628kb

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 0 2 69 1 63 327 139 1 8 70 46 256 0 37 69 2501 1 222 2104 9 142 0 141 7196 0 0 73 1 2355 4258 61 1703 398 2 1104 998243839 653 998243023 998244026 0 0 998242767 1429 39025 652 18709 998242868 4605 3153 0 16581 893 0 69 396 69 998241717 998232296 0 998228449 17164 2548 0 998228053 998242232 0 99...

result:

wrong answer 8th numbers differ - expected: '1791', found: '327'

Pretest #16:

score: 0
Wrong Answer
time: 346ms
memory: 40568kb

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 0 2 109 53 1 1 388 166 56 2 2 1654 441 1319 1213 607 1155 1760 4675 0 867 998244191 383 998244190 58 424 2091 165 2 998243746 0 260 0 0 53 179 43 1105 0 998243925 0 390 42 998243585 0 6712 658 4839 754 998243707 165 0 39 998243864 2 4717 998243799 7793 998239483 716 5153 1043 4643 998241205 9...

result:

wrong answer 10th numbers differ - expected: '2332', found: '388'

Pretest #17:

score: 0
Wrong Answer
time: 342ms
memory: 40556kb

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 49 59 0 105 1 57 60 3 51 198 59 52 0 998244300 1 44 998244312 260 1 256 7 176 102 155 1 2 2 1091 154 0 1178 360 998244279 312 154 564 4 161 998244306 1082 2 0 1 1026 998244304 998244304 1322 457 2687 111 1127 51 457 51 1016 998244160 403 0 613 4729 0 154 2269 0 4754 998243760 998244210...

result:

wrong answer 10th numbers differ - expected: '209', found: '105'

Pretest #18:

score: 0
Wrong Answer
time: 351ms
memory: 40960kb

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 1193 1 1132 3 3469 125 2211 1 61 1320 2023 5794 1442 2023 0 2022 0 2446 769 1253 777 1839 2451 5794 998239208 4 5794 646 646 0 3 0 1497 12051 998242804 15175 998243224 0 998238096 61 20463 998234009 10375 1254 2507 1611 0 358 2991 6619 2991 0 4234 1193 998242341 998239539 416 12170 0 1254 35...

result:

wrong answer 8th numbers differ - expected: '10615', found: '3469'

Pretest #19:

score: 0
Wrong Answer
time: 344ms
memory: 40488kb

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 37 873 5 1 37 84 834 181 39 91 720 1 9 998244088 1 1665 85 1664 712 1 3 675 3 947 637 415 1431 3 37 9032 674 3 6488 3239 4815 3387 1643 23797 31118 89 4257 23263 10145 998243342 1038 5837 445 3604 6270 1897 5793 40896 998240456 4055 1822 186 8181 6 998240781 0 5436 7911 9818 998237405 949 12201...

result:

wrong answer 8th numbers differ - expected: '18', found: '84'

Pretest #20:

score: 0
Wrong Answer
time: 358ms
memory: 40704kb

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 97 2068 97 155 1 309 200 45 157 2993 2043 157 311 49 935 204 1839 103 0 4034 0 18357 5882 2893 52 1810 3110 155 1994 2803 28781 10604 2665 103 41 1761 53 7263 105 155 41 3776 2227 502 443 402 998239529 362 998205129 105 457 1499 0 457 1499 998219076 998232957 998243713 7...

result:

wrong answer 14th numbers differ - expected: '262', found: '309'


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 22560kb

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 11 5 1 1
1 2 1 2 3
5 1 6 1 6
1 0 2 1 0

result:

ok 20 numbers

Test #2:

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

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 173 749 28 443 36 1 69 944 271 1 909 35 1 998244291 944 1208 969 444 735 305 35 998244323 104 0 193 3 1 4 1 388 0 0 1985 998241676 1243 89 998243217 69 270 1633 0 0 998244086 4048 1897 20 290 0 998244086 6554 575 264 478 998240780 305 3603 5731 271 998243886 998242024 1750 0 9...

result:

wrong answer 16th numbers differ - expected: '2124', found: '944'

Test #3:

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

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 447 129 26 274 929 1 16 0 78 1288 26 275 25 52 130 763 1 1951 3700 851 3253 825 274 548 3253 0 6382 10000 8518 697 823 1358 2067 9277 585 3885 6634 25106 2789 274 274 3639 998244207 0 998243356 0 2789 43736 0 27049 17175 6759 0 6759 10 998219772 4679 28007 106045 737 1875 998218484 998244185 ...

result:

wrong answer 17th numbers differ - expected: '17', found: '130'

Test #4:

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

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 33 33 2 3 82 33 998244195 998244277 42 998244260 998244239 0 0 998244308 998244322 99 998243555 324 998244317 108 998243515 40 435 998241799 0 998243737 998242719 141 998243678 0 998244335 105 998243643 998244318 0 0 998243520 998244318 998244161 998244318 998...

result:

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

Test #5:

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

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 0 6 65 0 5 1 4 32 42 35 7 0 200 0 199 97 998244348 164 95 35 93 65 1 822 1 26 55 442 229 595 998243604 132 595 822 998244001 24 562 132 24 633 998244056 0 24 576 577 0 198 392 869 133 194 998243801 34 578 259 998243951 998243801 180 941 0 998244090 279 998243805 0 668 998244069 998244061 90 67...

result:

wrong answer 11th numbers differ - expected: '14', found: '42'

Test #6:

score: 5
Accepted
time: 363ms
memory: 38776kb

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: 364ms
memory: 40876kb

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: 5
Accepted
time: 327ms
memory: 39800kb

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 5 18 5 4 25 24 29 33 29 24 24 73 48 24 50 50 37 89 89 60 125 36 23 23 68 39 39 35 23 23 52 52 45 38 14 9 9 9 9 9 9 9 42 9 67 44 9 2 11 2 2 106 106 106 106 174 167 99 92 126 97 145 165 158 90 239 189 180 143 143 114 90 90 279 90 203 322 313 261 237 223 134 90 90 233 90 90 90 90 163 154 131 94...

result:

ok 399996 numbers

Test #9:

score: 5
Accepted
time: 329ms
memory: 40280kb

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 0 13 57 0 1 42 27 0 39 13 11 114 83 57 0 26 26 26 0 0 26 26 14 52 26 26 26 0 11 15 0 11 68 11 11 78 26 11 11 0 230 0 0 203 203 0 0 203 189 0 39 189 137 0 52 241 0 0 252 199 188 26 188 52 0 110 26 110 110 95 0 57 22 27 11 11 27 166 11 155 0 344 0 138 39 0 116 115 22 0 314 115 198 115 198 ...

result:

ok 399996 numbers

Test #10:

score: 5
Accepted
time: 400ms
memory: 38704kb

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: 409ms
memory: 40220kb

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 640144236 39547474 650087292 272965389 148684245 932921248 118065928 798623338 153633989 221904090 211276710 913109625 605341742 7...

result:

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

Test #12:

score: 0
Wrong Answer
time: 407ms
memory: 40740kb

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 347723673 1285993 1278127 759893290 44466819 42346779 392689353 151735120 812087936 7866 81521011 388910169 163869220 236776498 196186208 347723673 41068652 387951218 300922093 618203692 787122301 908383678 7866 214509865 5...

result:

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

Test #13:

score: 5
Accepted
time: 360ms
memory: 39760kb

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 23 48 23 122 194 169 239 285 214 96 47 47 192 1948 2182 1132 385 216 455 47 1507 94 94 4391 21 779 13861 5938 14206 13992 4449 22496 12875 3304 3304 13811 13690 9811 3933 619 619 5401 13977 106342 3918 13555 35871 2821 276664 275227 172324 207717 203165 270061 269845 1838 68391 19507 19507 134...

result:

ok 399996 numbers

Test #14:

score: 0
Wrong Answer
time: 349ms
memory: 40792kb

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 0 3 1 1 69 67 1 136 66 271 0 64 0 0 67 64 0 0 2 1 71 531 334 0 0 547 62 2 2165 0 2037 6 61 263 991 1 998244286 459 61 0 406 206 0 194 0 136 998243173 928 204 4999 998244154 0 9801 135 9590 0 861 4924 9665 0 68 0 998244155 618 5336 5330 998244031 0 136 541 199 193 2229 5984 998239105 2 12...

result:

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

Test #15:

score: 0
Wrong Answer
time: 336ms
memory: 40688kb

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 50 44 13 225 47 3 92 7 135 0 2 2 355 40 4 40 1 11 1556 0 0 14 450 827 90 410 546 546 998244318 0 998244312 95 95 0 2409 998244056 998243797 998243607 498 498 998244082 4374 3288 2818 83 2442 163 79 1596 71 998244328 4 2438 3906 998241305 6153 1801 0 316 0 797 2549 108 108 95 2 998237448...

result:

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

Test #16:

score: 0
Wrong Answer
time: 350ms
memory: 40496kb

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 178 1 3 0 65 118 359 2 715 2 409 5 3 4 5 52 56 998244000 1 998244294 1109 757 1046 998244297 2455 3 196 0 60 1462 3499 133 220 151 48 3381 998243840 0 0 2615 998242034 998244289 998244056 0 998243763 188 864 2675 998242558 186 0 4227 998244123 998243485 998242613 262 998243608 311 6726 99...

result:

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

Test #17:

score: 0
Wrong Answer
time: 350ms
memory: 40516kb

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 54 1 998244250 0 0 50 0 48 166 998244204 102 998244195 248 0 998244195 48 118 264 1 62 212 55 157 998244316 0 7 564 107 669 274 3 717 998244218 4 0 180 153 614 23 778 166 507 200 116 998244303 54 998244296 44 998244303 998244130 0 998243895 1621 58 112 998243654 330...

result:

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

Test #18:

score: 0
Wrong Answer
time: 356ms
memory: 39812kb

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 0 40 3 1611 94 141 95 1737 48 94 1605 0 0 1557 0 4500 3 2657 3308 998242802 3348 4216 143 11141 4026 47 1914 14813 47 1782 3672 84 1651 3477 998242980 0 998242742 8266 1743 998244325 1743 1 998242748 998242450 15192 4900 1441 1 998242793 1394 95 35111 0 9707 144 36893 21484 36762 766...

result:

wrong answer 10th numbers differ - expected: '2679', found: '1611'

Test #19:

score: 0
Wrong Answer
time: 333ms
memory: 40460kb

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 0 155 199 1 1 107 1 998244311 998244241 564 6 302 258 998244243 60 998244108 156 156 998243790 998241458 354 302 998242769 313 308 73 375 44 2 998243812 917 198 1467 199 998244202 33 870 1 998244002 998240018 107 43 0 998242845 998243183 43 998243452 258 998243063 998243452 0 0 0 99823699...

result:

wrong answer 7th numbers differ - expected: '515', found: '155'

Test #20:

score: 0
Wrong Answer
time: 355ms
memory: 39824kb

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 42 1 41 172 85 87 0 41 998244313 475 2 170 474 88 217 0 87 0 0 306 998244311 388 1545 998243837 85 1806 475 341 46 1108 998244212 979 998243611 943 206 0 998244220 0 0 39 0 39 998243884 1764 39 0 998243100 172 39 998244268 998244266 0 998244271 998237945 14579 0 998243494 6273 0 0 210...

result:

wrong answer 15th numbers differ - expected: '172', found: '998244313'