QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390353#8547. Whose Land?hos_lyricAC ✓457ms45040kbC++147.6kb2024-04-15 12:55:172024-04-15 12:55:17

Judging History

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

  • [2024-04-15 12:55:17]
  • 评测
  • 测评结果:AC
  • 用时:457ms
  • 内存:45040kb
  • [2024-04-15 12:55:17]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


template <class T> void bAdd(vector<T> &bit, int pos, const T &val) {
  const int bitN = bit.size();
  for (int x = pos; x < bitN; x |= x + 1) bit[x] += val;
}
template <class T> T bSum(const vector<T> &bit, int pos) {
  T ret = 0;
  for (int x = pos; x > 0; x &= x - 1) ret += bit[x - 1];
  return ret;
}
template <class T> T bSum(const vector<T> &bit, int pos0, int pos1) {
  return bSum(bit, pos1) - bSum(bit, pos0);
}


struct Set {
  // max{ceil(log_64(n)), 1}
  int log64N, n;
  vector<unsigned long long> a[6];
  explicit Set(int n_ = 0) : n(n_) {
    assert(n >= 0);
    int m = n ? n : 1;
    for (int d = 0; ; ++d) {
      m = (m + 63) >> 6;
      a[d].assign(m, 0);
      if (m == 1) {
        log64N = d + 1;
        break;
      }
    }
  }
  bool empty() const {
    return !a[log64N - 1][0];
  }
  bool contains(int x) const {
    return (a[0][x >> 6] >> (x & 63)) & 1;
  }
  void insert(int x) {
    for (int d = 0; d < log64N; ++d) {
      const int q = x >> 6, r = x & 63;
      a[d][q] |= 1ULL << r;
      x = q;
    }
  }
  void erase(int x) {
    for (int d = 0; d < log64N; ++d) {
      const int q = x >> 6, r = x & 63;
      if ((a[d][q] &= ~(1ULL << r))) break;
      x = q;
    }
  }
  // max s.t. <= x (or -1)
  int prev(int x) const {
    if (x > n - 1) x = n - 1;
    for (int d = 0; d <= log64N; ++d) {
      if (x < 0) break;
      const int q = x >> 6, r = x & 63;
      const unsigned long long lower = a[d][q] << (63 - r);
      if (lower) {
        x -= __builtin_clzll(lower);
        for (int e = d; --e >= 0; ) x = x << 6 | (63 - __builtin_clzll(a[e][x]));
        return x;
      }
      x = q - 1;
    }
    return -1;
  }
  // min s.t. >= x (or n)
  int next(int x) const {
    if (x < 0) x = 0;
    for (int d = 0; d < log64N; ++d) {
      const int q = x >> 6, r = x & 63;
      if (static_cast<unsigned>(q) >= a[d].size()) break;
      const unsigned long long upper = a[d][q] >> r;
      if (upper) {
        x += __builtin_ctzll(upper);
        for (int e = d; --e >= 0; ) x = x << 6 | __builtin_ctzll(a[e][x]);
        return x;
      }
      x = q + 1;
    }
    return n;
  }
};

template <class T> struct Painter {
  int n;
  Set s;
  vector<T> ts;
  Painter() {}
  Painter(int n_, const T &t) : n(n_), s(n + 1), ts(n + 2, t) {}
  template <class F> void paint(int a, int b, const T &t, F f) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return;
    // auto it = this->lower_bound(a);
    int c = s.next(a);
    if (b < c) {
      f(a, b, ts[c]);
      s.insert(a); ts[a] = ts[c];
      s.insert(b); ts[b] = t;
    } else if (a < c) {
      const T ta = ts[c];
      int k = a;
      for (; c <= b; s.erase(c), c = s.next(c)) {
        f(k, c, ts[c]);
        k = c;
      }
      if (k < b) {
        f(k, b, ts[c]);
      }
      s.insert(a); ts[a] = ta;
      s.insert(b); ts[b] = t;
    } else {
      c = s.next(c + 1);
      int k = a;
      for (; c <= b; s.erase(c), c = s.next(c)) {
        f(k, c, ts[c]);
        k = c;
      }
      if (k < b) {
        f(k, b, ts[c]);
      }
      s.insert(b); ts[b] = t;
    }
  }
  void paint(int a, int b, const T &t) {
    paint(a, b, t, [&](int, int, const T &) -> void {});
  }
  T get(int k) const {
    assert(0 <= k); assert(k < n);
    return ts[s.next(k + 1)];
  }
};

////////////////////////////////////////////////////////////////////////////////


int N, K, Q;
vector<int> A, B;
vector<int> L, R;

vector<vector<int>> graph;
void ae(int u, int v) {
  graph[u].push_back(v);
  graph[v].push_back(u);
}

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d%d%d", &N, &K, &Q);
    A.resize(N - 1);
    B.resize(N - 1);
    for (int i = 0; i < N - 1; ++i) {
      scanf("%d%d", &A[i], &B[i]);
      --A[i];
      --B[i];
    }
    L.resize(Q);
    R.resize(Q);
    for (int q = 0; q < Q; ++q) {
      scanf("%d%d", &L[q], &R[q]);
      --L[q];
    }
    
    const int rt = N + K - 1;
    graph.assign(N + K, {});
    for (int k = 0; k < K; ++k) {
      ae(N + k - 1, N + k);
    }
    for (int i = 0; i < N - 1; ++i) {
      ae(A[i], B[i]);
    }
    
    queue<int> que;
    vector<int> dist(N + K, -1);
    vector<int> par(N + K, -1);
    dist[rt] = 0;
    que.push(rt);
    int zeit = 0;
    vector<int> su(N + K, -1);
    vector<int> us(N + K, -1);
    for (; que.size(); ) {
      const int u = que.front();
      que.pop();
      su[u] = zeit++;
      us[su[u]] = u;
      for (const int v : graph[u]) {
        if (!~dist[v]) {
          dist[v] = dist[u] + 1;
          par[v] = u;
          que.push(v);
        }
      }
    }
// cerr<<"us = "<<us<<endl;
    
    vector<vector<pair<int, int>>> f(N + K, vector<pair<int, int>>(K + 1));
    for (int j = N + K; --j >= 0; ) {
      const int u = us[j];
      f[u][0] = make_pair(j, j + 1);
      for (int k = 1; k <= K; ++k) {
        f[u][k] = make_pair(N + K, 0);
      }
      for (const int v : graph[u]) if (par[u] != v) {
        for (int k = 1; k <= K; ++k) {
          chmin(f[u][k].first , f[v][k - 1].first );
          chmax(f[u][k].second, f[v][k - 1].second);
        }
      }
// cerr<<"f["<<u<<"] = "<<f[u]<<endl;
    }
    
    vector<vector<int>> qss(N);
    for (int q = 0; q < Q; ++q) qss[L[q]].push_back(q);
    vector<int> ans(Q, 0);
    
    vector<int> bit(N + 1, 0);
    Painter<int> pa(N + K, N);
    bAdd(bit, N, N);
    for (int u = N; --u >= 0; ) {
      auto add = [&](const pair<int, int> &a) -> void {
        if (a.first < a.second) {
// cerr<<"[add] u = "<<u<<", a = "<<a<<endl;
          pa.paint(a.first, a.second, u, [&](int l, int r, int old) -> void {
            chmax(l, K);
            if (l < r) {
              bAdd(bit, old, -(r - l));
              bAdd(bit, u, +(r - l));
            }
          });
        }
      };
// cerr<<"pa = ";pv(pa.begin(),pa.end());
      for (int v = u, k = K; ; v = par[v]) {
        add(f[v][k]);
        if (k == 0) break;
        add(f[v][--k]);
      }
      for (const int q : qss[u]) {
        ans[q] = bSum(bit, R[q]);
      }
    }
    
    for (int q = 0; q < Q; ++q) {
      printf("%d\n", ans[q]);
    }
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3844kb

input:

2
5 1 2
1 2
1 3
2 4
2 5
2 2
2 3
8 2 3
1 2
1 3
2 4
2 5
4 6
5 7
7 8
2 2
2 5
3 4

output:

4
5
7
8
6

result:

ok 5 number(s): "4 5 7 8 6"

Test #2:

score: 0
Accepted
time: 205ms
memory: 3960kb

input:

1000
500 1 500
291 2
406 9
207 13
71 15
351 17
442 18
496 19
104 20
208 23
448 34
80 42
187 44
352 45
290 46
116 47
318 50
226 52
129 55
83 59
100 60
54 61
73 65
63 66
454 67
43 71
26 74
68 26
320 75
388 76
425 79
170 81
350 83
48 85
153 86
221 90
290 95
130 96
82 98
124 82
36 99
213 100
121 101
132...

output:

255
386
356
124
315
330
437
8
335
423
398
338
180
242
352
500
145
44
342
261
92
326
38
291
259
71
137
456
171
24
162
453
283
325
250
319
478
460
77
354
56
393
372
217
395
265
188
256
134
68
205
429
436
346
300
462
324
170
291
406
207
480
198
182
489
61
476
127
289
204
282
374
114
406
488
366
121
190...

result:

ok 500000 numbers

Test #3:

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

input:

1000
500 2 500
260 2
93 3
399 4
227 5
238 6
382 7
35 12
194 24
141 26
463 27
497 30
102 31
410 32
308 34
357 42
271 43
208 44
446 46
262 50
457 51
467 52
294 53
424 54
267 56
210 58
48 59
339 48
407 65
320 66
33 68
78 33
79 71
315 72
390 74
128 76
83 81
244 87
375 91
79 93
225 94
1 97
433 1
172 100
...

output:

496
471
423
489
270
388
451
329
495
104
453
321
500
357
24
429
409
496
491
454
469
119
495
460
432
450
496
494
459
435
211
298
426
260
371
490
498
259
490
494
492
477
336
412
425
431
235
445
482
422
296
495
361
407
465
492
497
500
394
222
500
500
500
498
470
470
152
414
337
412
325
387
89
492
313
45...

result:

ok 500000 numbers

Test #4:

score: 0
Accepted
time: 259ms
memory: 4220kb

input:

1000
500 3 500
333 1
268 2
183 3
394 5
420 7
322 12
87 14
285 21
178 23
82 36
106 38
28 49
364 28
30 56
110 57
211 58
486 62
456 66
337 67
222 68
175 76
15 81
489 82
79 91
376 79
274 93
417 94
302 96
457 98
142 102
486 103
13 104
186 111
128 114
35 115
184 117
167 118
156 119
429 120
414 122
84 126
...

output:

478
489
465
360
439
28
488
133
75
497
373
470
496
499
487
141
476
500
381
489
495
171
414
372
449
236
489
422
432
373
488
298
480
473
98
500
474
496
449
446
500
487
110
213
499
446
152
283
322
497
304
245
371
218
323
500
416
485
499
439
480
430
489
496
488
405
483
500
339
476
483
497
494
309
258
358...

result:

ok 500000 numbers

Test #5:

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

input:

1000
500 4 500
109 1
252 5
375 6
50 7
398 11
465 13
127 14
79 15
112 18
301 20
23 22
442 27
219 31
48 35
351 36
460 37
368 40
465 43
16 45
79 48
383 50
32 53
42 32
496 42
54 56
193 54
187 61
93 62
389 63
147 65
86 66
231 67
261 70
365 71
249 88
181 90
77 94
437 98
384 101
411 102
64 103
364 104
456 ...

output:

500
497
379
500
248
492
499
500
325
384
492
365
395
491
130
435
496
340
500
500
478
470
500
346
499
495
164
496
499
498
500
500
326
432
444
500
500
480
500
328
486
500
500
90
463
499
48
387
500
495
478
446
488
81
487
426
500
490
488
351
499
500
497
500
362
431
249
495
491
495
500
494
367
500
420
496...

result:

ok 500000 numbers

Test #6:

score: 0
Accepted
time: 219ms
memory: 5284kb

input:

100
5000 1 5000
4598 1
104 3
1813 7
3677 9
4212 10
739 14
4927 16
3896 17
2012 23
4512 25
1751 26
1487 29
2610 30
3912 31
733 33
4844 39
1179 40
5 43
174 45
4787 47
2500 48
3783 50
2905 54
1943 55
1296 56
4178 59
1021 63
4614 70
4221 71
4782 74
1802 75
4912 76
1839 80
4494 81
3403 82
2355 84
756 91
...

output:

4366
4531
4868
2824
4359
2428
880
3967
4469
3414
4891
1139
611
577
698
4669
1641
2897
520
3730
3629
3913
4701
2735
4626
3279
2037
4040
3401
4845
4911
3015
2878
1753
4669
1094
4319
725
1266
2479
4360
3242
4056
1078
1047
4924
3570
2632
4852
2234
2498
4150
3357
2454
4784
3937
1272
1416
4942
3514
1315
3...

result:

ok 500000 numbers

Test #7:

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

input:

100
5000 2 5000
2567 6
2087 9
801 12
2832 16
3395 23
1178 25
479 30
1690 32
4253 36
2131 37
4668 38
4210 41
4361 47
1930 48
3486 50
3592 52
3956 54
2514 61
1045 64
1348 68
2708 69
300 72
62 73
2064 74
1166 75
3404 77
1292 79
1905 80
358 81
1083 83
4914 86
4642 87
1914 88
4435 92
3514 97
352 100
1167...

output:

4949
4725
4640
4959
4301
1730
4557
4625
4988
2646
276
4021
3492
4707
703
4961
2898
90
4986
3757
4981
3492
3954
4901
4254
798
4972
1580
2928
3446
495
4314
4621
4460
4906
3313
4665
4832
3988
4604
3784
3932
4990
3989
4655
2270
525
4891
4989
4293
4296
4359
4033
4438
4939
4926
1197
4962
4011
4544
3909
15...

result:

ok 500000 numbers

Test #8:

score: 0
Accepted
time: 282ms
memory: 5032kb

input:

100
5000 3 5000
1343 1
3262 3
4789 7
1988 19
4873 24
1618 25
223 29
4077 36
2982 37
1646 38
2585 40
1532 50
4623 52
4948 54
431 57
45 59
1734 45
23 61
428 72
205 75
2916 84
4521 86
1819 88
1376 92
1036 93
334 96
4666 101
4 102
3790 104
895 105
1810 110
2075 114
4285 116
1673 117
1728 118
1453 120
42...

output:

1572
4742
2171
3564
4050
4970
5000
1152
3804
4896
4672
2800
2161
4889
4683
4293
3578
4921
4915
3966
3694
4590
4996
4772
4547
3956
5000
4865
2930
4919
4990
4998
4994
4995
4805
5000
4382
4201
4702
4612
4360
4919
4789
4027
4924
3265
855
4730
2721
4814
4927
4628
1307
3772
4238
3797
4912
4755
4854
2505
4...

result:

ok 500000 numbers

Test #9:

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

input:

100
5000 4 5000
2416 3
246 5
1481 10
1143 15
1759 18
4762 19
2262 26
4167 31
223 32
1969 34
4694 35
4255 36
1373 39
670 44
479 45
2985 48
3024 50
2533 52
2107 62
3254 64
1636 65
1038 66
1680 71
689 73
3202 74
3753 82
4937 84
2295 87
4926 89
3004 91
2218 92
4101 93
2064 98
3910 99
1839 102
1746 103
5...

output:

4254
4911
4148
3692
4971
4940
4114
4433
4950
4881
4998
4982
4715
4982
4701
4864
4746
4856
4988
4996
2562
2235
4878
5000
4931
4934
4738
2950
5000
3608
4759
3076
3608
4877
4996
4601
2379
4793
4973
4967
4865
4697
3813
4984
4991
4929
3808
3482
4992
4472
4960
4840
504
4974
4425
4494
3791
4903
5000
5000
4...

result:

ok 500000 numbers

Test #10:

score: 0
Accepted
time: 236ms
memory: 7692kb

input:

25
20000 1 20000
16985 7
9470 9
7497 10
12601 13
19428 19
17396 21
13606 27
1463 28
5720 30
6405 31
16086 38
15453 39
10225 41
19740 44
9398 47
18437 49
7152 50
15684 53
13034 55
12112 56
8888 57
6096 66
375 68
19456 78
13234 84
7828 85
5767 97
13148 99
2185 100
3817 101
8 102
14096 8
13295 103
1319...

output:

13854
10421
498
18438
1916
8252
18032
204
18543
18005
5196
13629
12160
15228
7004
6117
2367
14659
5032
17464
18124
10547
12996
16457
17785
3014
19175
9640
5413
15842
18032
1604
14411
9820
7143
5901
8433
7473
17041
15802
18371
12383
15085
18914
3416
2516
18654
5701
9060
10826
19761
6019
3797
7595
188...

result:

ok 500000 numbers

Test #11:

score: 0
Accepted
time: 264ms
memory: 7736kb

input:

25
20000 2 20000
7250 2
18350 5
4189 8
19461 9
3610 11
10539 13
13349 14
14257 18
12153 22
16728 27
899 30
7367 36
14679 40
17758 41
19047 46
14890 47
14929 49
3193 50
7417 52
18673 57
19096 60
7613 61
9428 62
9576 63
400 64
19758 65
4549 69
2735 70
18322 74
18630 76
14608 78
1529 86
10666 92
435 93...

output:

11555
19950
10702
18264
18983
17767
16022
17567
8482
17678
19659
18692
19822
9299
11016
3283
15127
2364
18320
19204
14616
19990
19817
18719
19639
19986
13080
2437
16101
9004
17041
9904
17431
19887
19350
16813
12983
13196
15307
12404
19576
18723
19312
19939
14506
17131
19337
16306
1184
18831
11189
11...

result:

ok 500000 numbers

Test #12:

score: 0
Accepted
time: 292ms
memory: 8352kb

input:

25
20000 3 20000
6027 3
10333 6
15473 11
6320 13
7792 18
10979 19
16197 20
14348 21
1690 22
18539 23
8816 24
15089 27
2238 29
8480 32
3288 36
11342 38
2707 39
6511 46
9096 48
5234 50
14712 53
1834 55
6993 57
11184 58
16078 59
18984 61
14820 67
834 68
1754 69
739 71
5016 75
16259 76
741 77
7672 78
17...

output:

19995
11051
12978
17914
19999
19713
12058
19593
19724
15828
11867
19669
11178
16495
16527
19229
19672
13102
19832
14098
8043
14132
18754
19962
19907
18253
8055
16458
19994
8083
17818
19669
16527
12600
19899
19835
19052
19205
20000
19163
12602
7820
19974
19415
19848
19932
12182
18623
19923
18872
1994...

result:

ok 500000 numbers

Test #13:

score: 0
Accepted
time: 332ms
memory: 7960kb

input:

25
20000 4 20000
4803 2
6508 3
16357 5
476 6
11975 9
7227 12
8645 15
14438 17
8124 19
1566 20
16733 24
2812 26
13988 29
19202 31
16041 35
19283 36
10485 44
14020 46
7672 47
3283 51
729 54
16055 56
19149 62
1305 66
15949 67
2402 73
8194 82
3125 84
17890 85
2847 87
15424 88
10989 89
3520 91
3422 93
15...

output:

17587
19806
15971
19999
19916
2339
19126
19669
19827
19855
18914
8252
18137
20000
6547
20000
19739
19347
18714
19997
15367
14785
19999
19806
19959
19749
19952
15761
19974
18783
19985
18745
19996
18967
19996
19986
13738
18954
19058
17559
2569
19978
19557
8258
13529
19449
19999
19971
5922
11608
19960
...

result:

ok 500000 numbers

Test #14:

score: 0
Accepted
time: 262ms
memory: 23536kb

input:

5
100000 1 100000
65452 1
39581 2
51138 3
77143 4
56934 5
11457 7
57146 9
21536 11
4708 12
57852 13
97500 22
76022 23
96583 27
36441 32
30948 35
53232 36
50629 37
79639 38
61377 43
78772 46
41320 47
2344 49
86775 52
63201 57
53901 59
59314 61
95358 62
94950 63
44230 66
99217 69
57344 70
92488 86
961...

output:

99907
37316
85362
3534
84069
55160
74579
5575
50463
67247
697
29352
5606
95882
66442
85534
40921
69176
19195
85386
20900
70472
89510
77618
77039
39606
14908
36890
26439
23200
87029
75059
74992
79899
85273
72156
7678
3593
47438
97802
33899
98258
98991
41669
32763
17643
59525
89407
85433
68525
97000
4...

result:

ok 500000 numbers

Test #15:

score: 0
Accepted
time: 282ms
memory: 23796kb

input:

5
100000 1 100000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59
...

output:

21130
36114
7444
10651
62296
52897
57960
18815
85327
24367
51801
99990
52822
9714
31264
26349
34748
22707
57437
37755
32365
37242
76963
55542
26580
65184
31304
33380
54513
23932
46606
15047
28922
9680
8618
37505
28082
15321
288
40093
29299
358
16183
43463
34415
77460
4058
45276
40816
46486
19831
716...

result:

ok 500000 numbers

Test #16:

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

input:

5
100000 2 100000
76932 1
78860 5
2422 6
76707 9
61116 15
80408 23
49594 27
54330 31
31141 32
60879 35
45417 37
23745 40
76845 44
67163 48
60597 49
49684 53
74215 56
19852 57
3056 59
49525 60
84232 62
96565 63
11636 65
77513 70
21067 80
78540 81
81436 82
80345 84
87662 88
34030 91
19240 93
27218 98
...

output:

76095
98899
9025
99567
99578
70068
11140
78199
89234
46003
78984
74240
98884
89176
92940
26610
90572
90839
99981
91884
95971
40037
96277
20283
99462
83734
98101
95386
99961
62674
90668
93128
82592
73459
63709
34540
93008
97732
88015
99995
99136
50241
7310
99977
39843
34712
70746
54982
79470
76423
81...

result:

ok 500000 numbers

Test #17:

score: 0
Accepted
time: 320ms
memory: 24068kb

input:

5
100000 2 100000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59
...

output:

28252
62610
31438
16964
6451
10376
8623
14823
45365
73013
71149
17372
15626
42256
14328
9700
55941
60538
77721
14033
15164
6035
26990
3331
88702
71743
36189
29586
40813
73544
11663
20653
34054
39889
25549
67837
66756
75188
26213
895
38693
41421
44040
11332
11981
24240
47568
55600
9924
23782
43083
11...

result:

ok 500000 numbers

Test #18:

score: 0
Accepted
time: 328ms
memory: 25276kb

input:

5
100000 3 100000
47197 1
83547 6
86410 7
10862 10
65298 16
40848 25
76634 28
54420 29
678 30
22690 42
93335 49
4171 50
48596 51
97885 53
646 54
13433 56
54697 57
27362 59
1632 60
63382 65
27145 66
58082 67
60689 68
67633 70
20938 75
89254 79
91707 81
22636 83
31095 84
36139 85
22353 89
61948 98
562...

output:

98939
97484
97443
99904
97552
99116
97764
99685
99741
61980
73380
25913
92250
88988
41383
81703
81770
83176
81850
93131
81253
78738
99979
99250
99333
99010
94702
69698
22850
89211
97117
95557
99999
15380
77615
81659
40331
61428
98290
99773
99512
98270
92960
97906
94609
91495
89053
91645
84264
100000...

result:

ok 500000 numbers

Test #19:

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

input:

5
100000 3 100000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59
...

output:

2517
12676
20408
57281
7595
42442
2448
82869
28402
88703
79345
49001
35480
65714
28344
31260
12386
10562
4254
14944
3934
72264
32611
31456
6868
48169
26843
25656
761
2727
4913
34782
39756
22594
34667
26604
71945
1557
15679
35523
70515
83572
46759
59314
23068
30338
10023
5431
49823
53109
22627
51338
...

result:

ok 500000 numbers

Test #20:

score: 0
Accepted
time: 368ms
memory: 25592kb

input:

5
100000 4 100000
25974 1
79723 5
3102 6
45017 16
36777 17
1288 20
12185 31
54510 33
59816 34
25717 37
41252 38
76086 45
28858 52
95904 54
64886 55
77181 58
2474 59
10679 62
43311 70
77239 74
37353 77
52303 78
85550 81
81946 83
20808 86
8481 87
77785 88
32223 90
50335 92
95143 100
84249 101
29381 10...

output:

99846
91739
81090
99991
99840
99983
100000
98356
89839
92229
83694
99993
75930
99794
85462
75257
85935
99996
99988
99835
99373
75538
99984
64381
95516
97643
48556
92269
96576
99263
42473
99999
99562
99941
95166
99846
96992
76520
99957
99890
27407
98364
75077
98943
97953
22998
64347
98053
41631
99999...

result:

ok 500000 numbers

Test #21:

score: 0
Accepted
time: 426ms
memory: 25256kb

input:

5
100000 4 100000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59
...

output:

18029
73730
28521
45218
40759
69068
71615
32980
14951
22129
40759
90245
32980
8129
79674
96189
62950
37071
32980
31979
62950
34544
27189
73730
34544
36177
10617
22129
61733
51039
44921
18029
59159
34544
34544
34544
49495
22129
90245
77188
38355
44217
99017
40759
49495
71615
51039
90245
18029
24585
3...

result:

ok 500000 numbers

Test #22:

score: 0
Accepted
time: 241ms
memory: 33232kb

input:

1
100000 6 500000
16295 6
87763 7
84391 9
85895 14
46464 17
77083 27
78531 31
37918 33
83051 35
72940 36
57210 39
9656 40
45218 43
907 44
21638 45
99499 48
72032 50
34752 52
10436 54
5812 71
83845 72
42746 74
77175 76
8657 78
14101 79
93672 83
38565 87
50244 88
17562 92
15777 93
1561 94
19671 95
507...

output:

90775
99468
72739
97365
64566
54898
82049
80121
99585
100000
100000
99797
99940
100000
30349
21656
99937
98178
100000
99858
98671
99995
24318
100000
99221
99998
100000
100000
89405
99277
99995
99996
6249
97665
99825
99848
94576
65223
99988
88898
100000
96190
98732
99930
99625
99997
98950
99231
90840...

result:

ok 500000 numbers

Test #23:

score: 0
Accepted
time: 280ms
memory: 34996kb

input:

1
100000 8 500000
98041 5
23218 6
76559 7
86910 8
54828 10
30667 13
41123 15
70802 20
79022 21
5074 22
9940 23
94701 29
97230 31
29647 33
91335 34
83892 36
43395 38
49771 40
50690 41
66230 42
80069 46
63892 50
26897 56
80385 60
24242 63
56317 65
2210 67
2123 68
37131 69
9595 78
66569 79
89130 83
782...

output:

99998
51828
99999
99875
99967
99959
100000
99271
96449
100000
96282
99998
99988
99532
99997
79928
99979
99990
99998
99956
79858
100000
99996
100000
98274
98806
100000
99990
96728
99168
99891
41409
99065
100000
35163
99974
100000
62441
100000
99836
100000
99942
100000
99990
100000
100000
99177
99875
...

result:

ok 500000 numbers

Test #24:

score: 0
Accepted
time: 297ms
memory: 36460kb

input:

1
100000 10 500000
49308 1
39041 8
48309 11
15042 17
77883 22
59175 26
5640 29
33277 30
84214 31
41805 33
44196 36
91869 37
58906 40
46325 44
68330 46
28901 50
63960 52
30341 53
75196 55
61053 61
82117 65
10823 68
19425 69
17427 70
17307 73
19562 74
77349 81
91605 84
11767 85
31327 89
11222 94
52056...

output:

100000
100000
100000
99119
100000
100000
99998
84657
100000
99928
99999
98752
100000
100000
94720
100000
99989
99989
100000
100000
99993
99454
100000
99966
99845
100000
100000
99976
99886
100000
100000
100000
100000
99866
61097
100000
100000
100000
98604
99981
100000
20637
100000
99996
100000
73159
...

result:

ok 500000 numbers

Test #25:

score: 0
Accepted
time: 343ms
memory: 39548kb

input:

1
100000 13 500000
77127 8
3375 16
32977 19
50213 21
90430 22
73198 28
60679 30
33548 31
49722 34
76966 36
12140 39
16124 40
25773 43
29979 45
2268 46
44338 51
83101 53
20165 55
65641 56
59520 57
21254 60
84975 66
18200 72
36172 74
84214 76
68728 80
83968 82
61582 85
7472 87
70357 88
46639 89
56245 ...

output:

100000
100000
100000
99999
100000
97713
99995
100000
100000
89384
99931
99999
100000
100000
88807
100000
99993
100000
99936
100000
100000
98903
99631
84141
99999
100000
100000
99997
99065
95704
99270
100000
67372
100000
52924
99978
100000
100000
99282
99996
99783
100000
98346
99987
100000
100000
956...

result:

ok 500000 numbers

Test #26:

score: 0
Accepted
time: 390ms
memory: 41212kb

input:

1
100000 16 500000
4945 5
76221 6
84941 9
85383 13
2977 14
54517 16
50310 22
42331 23
4829 24
79423 26
88595 27
48892 29
58047 32
56738 37
3503 38
92480 39
2242 44
51205 47
80279 49
66499 57
93095 58
67638 60
49679 61
22213 63
83825 68
7495 70
90587 71
98856 72
37769 77
33579 79
49351 83
93139 87
95...

output:

99651
100000
99494
100000
100000
100000
100000
100000
99997
99613
95196
100000
100000
100000
100000
96993
100000
100000
99990
82227
100000
100000
90940
100000
100000
22012
99986
100000
100000
100000
100000
100000
100000
100000
100000
99569
100000
99390
99999
100000
99986
99999
100000
99980
99626
951...

result:

ok 500000 numbers

Test #27:

score: 0
Accepted
time: 457ms
memory: 44472kb

input:

1
100000 20 500000
3301 2
62300 4
4045 9
43884 11
48489 12
90178 18
88604 22
37080 26
45315 29
45607 30
62702 34
41017 37
66354 38
60322 39
92220 40
27696 43
96520 44
80545 45
35732 46
45173 47
8623 50
28996 56
77335 59
53073 61
44034 63
24543 66
31066 67
23716 69
21135 73
84124 78
13577 80
75392 81...

output:

99995
100000
100000
100000
99999
99650
100000
100000
100000
100000
100000
100000
100000
94248
99980
100000
99561
100000
99868
99885
100000
100000
100000
100000
100000
100000
100000
99990
100000
96305
100000
100000
100000
99994
100000
100000
100000
100000
100000
99999
100000
100000
100000
100000
9999...

result:

ok 500000 numbers

Test #28:

score: 0
Accepted
time: 134ms
memory: 33824kb

input:

1
100000 6 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #29:

score: 0
Accepted
time: 134ms
memory: 35452kb

input:

1
100000 8 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #30:

score: 0
Accepted
time: 140ms
memory: 36928kb

input:

1
100000 10 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #31:

score: 0
Accepted
time: 153ms
memory: 40104kb

input:

1
100000 13 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #32:

score: 0
Accepted
time: 159ms
memory: 41684kb

input:

1
100000 16 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #33:

score: 0
Accepted
time: 161ms
memory: 44572kb

input:

1
100000 20 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #34:

score: 0
Accepted
time: 175ms
memory: 33436kb

input:

1
100000 6 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51...

output:

36913
67958
38063
16617
35478
18363
18788
34260
62406
3642
35484
43296
19227
70159
6490
48198
8067
24675
23608
32480
11191
47331
31471
10212
25426
1793
32664
37041
52112
2050
68662
10250
89271
36695
42106
6109
2309
35604
8718
32569
39062
18856
61857
51009
48032
61386
12280
4083
35215
90641
21015
639...

result:

ok 500000 numbers

Test #35:

score: 0
Accepted
time: 186ms
memory: 35012kb

input:

1
100000 8 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51...

output:

11295
40919
50582
29515
66615
50682
4515
11056
26674
52032
29224
12780
43706
6120
43597
54151
38992
32615
60160
33931
25755
88595
13662
65198
69983
14300
22712
62679
1971
8456
7314
46731
1722
37538
7542
13677
5901
73131
19460
39987
38466
3246
446
19915
17236
22977
79398
21374
21848
21886
56277
4120
...

result:

ok 500000 numbers

Test #36:

score: 0
Accepted
time: 199ms
memory: 36464kb

input:

1
100000 10 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

44855
35440
44002
72567
2376
53741
31615
24292
66073
14422
27448
23258
5064
8261
57993
33995
58915
20626
1422
66812
14501
16980
20068
29973
6607
21383
24955
5463
41152
8306
44182
4935
10525
74441
58157
734
2097
2169
31954
43064
47516
61606
28977
38381
12156
51914
2141
6295
30434
69106
75671
40424
55...

result:

ok 500000 numbers

Test #37:

score: 0
Accepted
time: 203ms
memory: 39632kb

input:

1
100000 13 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

220
47814
42532
94636
1917
2619
32734
2769
36762
77967
83422
13715
9948
4237
41833
43338
36941
19568
9834
13828
23307
17863
14517
6392
52430
1003
87256
6888
684
82573
19711
35496
19070
35161
56390
7585
7802
11059
22413
38537
13918
46703
7124
47803
78651
25778
77379
71860
14825
28747
1059
34911
70348...

result:

ok 500000 numbers

Test #38:

score: 0
Accepted
time: 239ms
memory: 41336kb

input:

1
100000 16 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

36742
6834
32551
8194
14681
41128
27217
44198
15963
5559
5815
6315
7853
40886
74322
44822
18926
35529
83656
36653
15088
89831
8965
81543
21345
31861
39157
23973
3319
37926
25016
43180
24432
9673
18771
42990
46211
24245
9441
41864
19746
11371
49386
328
36713
425
104
4721
33808
2367
26447
46476
79796
...

result:

ok 500000 numbers

Test #39:

score: 0
Accepted
time: 262ms
memory: 44316kb

input:

1
100000 20 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

10201
38162
16456
60260
7682
12718
42986
9377
49049
17735
59994
1016
14469
10866
25634
37225
12228
52684
16038
15533
6773
72662
15680
31916
11546
75020
19109
63439
6857
28260
52259
76924
18812
20521
27906
24125
64682
37191
4744
22554
9481
33730
3044
919
65748
3212
18012
2576
1603
4313
28392
48543
81...

result:

ok 500000 numbers

Test #40:

score: 0
Accepted
time: 187ms
memory: 33336kb

input:

1
100000 6 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

9036
42601
22726
32133
52639
17290
37600
73991
15176
94851
22873
13521
26805
73401
39132
9324
46864
12333
17279
32039
28319
21739
60803
44164
99161
35826
37512
5718
27956
63922
73880
77749
53430
27951
61448
68858
52557
17381
9752
38502
10607
69033
53049
41472
35289
13333
31237
64968
83885
48607
1230...

result:

ok 500000 numbers

Test #41:

score: 0
Accepted
time: 195ms
memory: 34904kb

input:

1
100000 8 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

7046
55148
46197
25810
83220
55808
43422
18571
8165
29051
26777
53559
12260
32468
5551
49226
9760
40272
41222
43454
47150
26950
8602
58240
38585
2692
12448
25818
33403
64099
11813
6317
8865
24900
44418
50808
79631
48409
57408
19631
3513
54783
12068
56351
77223
66220
81272
70353
5345
52858
32284
7627...

result:

ok 500000 numbers

Test #42:

score: 0
Accepted
time: 196ms
memory: 36460kb

input:

1
100000 10 500000
1 2
1 3
1 4
1 5
2 6
3 7
4 8
5 9
6 10
7 11
8 12
9 13
10 14
11 15
12 16
13 17
14 18
15 19
16 20
17 21
18 22
19 23
20 24
21 25
22 26
23 27
24 28
25 29
26 30
27 31
28 32
29 33
30 34
31 35
32 36
33 37
34 38
35 39
36 40
37 41
38 42
39 43
40 44
41 45
42 46
43 47
44 48
45 49
46 50
47 51
4...

output:

38789
59000
41293
42736
28918
3492
65319
32902
13339
32110
20796
16371
25586
59949
19132
15792
64603
38984
19355
12039
66984
3917
40629
37638
54746
22500
9610
12086
1473
19773
8911
20354
4969
37818
42970
90591
48874
3444
5377
36422
29128
79957
31861
57026
89104
6299
74878
25745
45191
26858
67631
221...

result:

ok 500000 numbers

Test #43:

score: 0
Accepted
time: 246ms
memory: 39556kb

input:

1
100000 13 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

8909
87758
3779
74131
92620
18631
29681
77098
9359
30278
10123
70791
37048
63464
14970
7961
22460
13174
17153
28677
38933
15417
13269
23759
53494
70593
29958
82721
6482
6633
39265
60059
100000
41160
28854
17618
29650
39068
16784
7373
65000
56516
34970
39094
21202
50714
32781
24162
45360
81235
80356
...

result:

ok 500000 numbers

Test #44:

score: 0
Accepted
time: 244ms
memory: 41300kb

input:

1
100000 16 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
2 51
3 52
4 53
5 54
6 55
7 56
8 57
9 58
10 5...

output:

59737
5736
33878
55864
23625
14477
50558
35494
12604
60770
16141
47011
7653
3557
64710
32455
28321
33482
66912
66962
10502
16137
66616
29916
77355
84985
82775
82097
92201
13745
9203
21018
17706
9196
22439
77787
31823
8307
1730
7523
22248
36771
15052
35859
25498
39889
31745
22592
68390
53779
42633
74...

result:

ok 500000 numbers

Test #45:

score: 0
Accepted
time: 261ms
memory: 44164kb

input:

1
100000 20 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
2 43
3 44
4 45
5 46
6 47
7 48
8 49
9 50
10 51
11 52
12 53
13 54
14 55
15 56
16 57
17...

output:

83680
86092
12390
1687
20212
37469
3192
67993
51311
23987
29174
43727
84295
8443
13353
12259
48175
48226
40473
14996
31012
28299
37669
13960
20321
39694
11840
69884
59711
5921
33551
19627
39351
23724
14934
47205
27390
29575
3693
22161
54686
58953
34032
3302
54175
10486
37226
8349
33288
22172
23062
5...

result:

ok 500000 numbers

Test #46:

score: 0
Accepted
time: 151ms
memory: 34040kb

input:

1
100000 6 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #47:

score: 0
Accepted
time: 146ms
memory: 35660kb

input:

1
100000 8 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #48:

score: 0
Accepted
time: 149ms
memory: 36880kb

input:

1
100000 10 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
2 58
2 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #49:

score: 0
Accepted
time: 169ms
memory: 40116kb

input:

1
100000 13 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #50:

score: 0
Accepted
time: 168ms
memory: 41832kb

input:

1
100000 16 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #51:

score: 0
Accepted
time: 179ms
memory: 45040kb

input:

1
100000 20 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #52:

score: 0
Accepted
time: 143ms
memory: 34092kb

input:

1
100000 6 500000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59
...

output:

34907
59165
94064
94064
59165
59165
59165
94064
94064
94064
94064
59165
59165
59165
94064
94064
94064
59165
94064
94064
59165
59165
65535
94064
65535
65535
94064
65535
94064
59165
100000
59165
34907
94064
94064
94064
94064
100000
94064
59165
94064
94064
94064
94064
59165
94064
94064
94064
94064
9406...

result:

ok 500000 numbers

Test #53:

score: 0
Accepted
time: 166ms
memory: 35652kb

input:

1
100000 8 500000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59
...

output:

65535
41025
65535
41025
65535
100000
100000
100000
100000
65535
100000
65535
65535
41025
100000
100000
100000
100000
65535
65535
65535
65535
100000
65535
100000
100000
100000
100000
100000
65535
65535
65535
65535
65535
100000
41025
100000
65535
100000
65535
100000
65535
100000
100000
65535
100000
65...

result:

ok 500000 numbers

Test #54:

score: 0
Accepted
time: 173ms
memory: 36908kb

input:

1
100000 10 500000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #55:

score: 0
Accepted
time: 179ms
memory: 40124kb

input:

1
100000 13 500000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #56:

score: 0
Accepted
time: 170ms
memory: 41756kb

input:

1
100000 16 500000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #57:

score: 0
Accepted
time: 192ms
memory: 44924kb

input:

1
100000 20 500000
1 2
1 3
2 4
2 5
2 6
2 7
2 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
4 16
4 17
4 18
4 19
4 20
4 21
4 22
4 23
4 24
5 25
5 26
5 27
5 28
5 29
5 30
5 31
5 32
5 33
5 34
5 35
6 36
6 37
6 38
6 39
6 40
6 41
6 42
6 43
6 44
6 45
6 46
6 47
6 48
7 49
7 50
7 51
7 52
7 53
7 54
7 55
7 56
7 57
7 58
7 59...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #58:

score: 0
Accepted
time: 230ms
memory: 33416kb

input:

1
100000 6 500000
1 2
2 3
2 4
1 5
2 6
2 7
3 8
6 9
3 10
10 11
9 12
2 13
8 14
12 15
6 16
10 17
17 18
11 19
4 20
8 21
9 22
18 23
22 24
20 25
1 26
24 27
11 28
26 29
28 30
13 31
12 32
13 33
20 34
14 35
29 36
28 37
8 38
8 39
34 40
23 41
12 42
40 43
19 44
26 45
31 46
46 47
32 48
18 49
43 50
1 51
26 52
34 5...

output:

98727
100000
99424
97862
99998
99996
99995
99977
99971
98890
99986
100000
100000
99588
99883
100000
96278
99975
99404
99992
99694
100000
99986
99572
99901
93210
36679
99955
80773
99841
99692
93064
84593
77454
83600
99993
100000
99548
100000
99920
99445
99956
99946
92205
92522
98382
99625
99354
10000...

result:

ok 500000 numbers

Test #59:

score: 0
Accepted
time: 257ms
memory: 35164kb

input:

1
100000 8 500000
1 2
2 3
1 4
4 5
2 6
6 7
2 8
3 9
9 10
8 11
7 12
11 13
6 14
6 15
1 16
3 17
1 18
12 19
2 20
2 21
9 22
20 23
11 24
21 25
13 26
6 27
5 28
24 29
2 30
3 31
28 32
1 33
15 34
27 35
20 36
13 37
10 38
38 39
34 40
17 41
37 42
21 43
9 44
2 45
26 46
4 47
11 48
13 49
24 50
39 51
4 52
8 53
44 54
2...

output:

99247
99996
98827
99988
99995
99998
99288
99540
99085
100000
99737
95948
99834
100000
72625
100000
85933
99971
100000
99610
99996
100000
79979
99998
99994
99929
100000
100000
100000
99954
99865
99876
99959
99998
99998
100000
100000
100000
97569
100000
100000
99966
99978
99985
100000
99995
99993
9980...

result:

ok 500000 numbers

Test #60:

score: 0
Accepted
time: 310ms
memory: 36756kb

input:

1
100000 10 500000
1 2
1 3
3 4
4 5
2 6
6 7
6 8
5 9
5 10
9 11
11 12
7 13
6 14
13 15
13 16
3 17
13 18
10 19
19 20
2 21
21 22
4 23
22 24
22 25
3 26
11 27
14 28
19 29
1 30
5 31
20 32
15 33
7 34
32 35
7 36
14 37
4 38
18 39
3 40
38 41
10 42
21 43
10 44
28 45
22 46
42 47
2 48
38 49
30 50
10 51
32 52
11 53
...

output:

100000
100000
100000
100000
100000
99995
100000
100000
99253
100000
99992
97771
92703
99746
99999
100000
90840
100000
99990
100000
68083
99992
100000
99925
100000
99999
100000
100000
99996
100000
99999
100000
99997
100000
99870
99995
100000
100000
99999
100000
100000
100000
100000
100000
99986
10000...

result:

ok 500000 numbers

Test #61:

score: 0
Accepted
time: 347ms
memory: 40172kb

input:

1
100000 13 500000
1 2
1 3
3 4
3 5
3 6
5 7
5 8
4 9
4 10
10 11
11 12
6 13
7 14
13 15
5 16
1 17
7 18
2 19
4 20
13 21
9 22
21 23
2 24
7 25
18 26
4 27
4 28
12 29
29 30
21 31
16 32
12 33
16 34
1 35
29 36
8 37
8 38
19 39
39 40
37 41
15 42
39 43
30 44
42 45
11 46
37 47
32 48
38 49
25 50
44 51
1 52
8 53
18 ...

output:

98957
100000
100000
99678
100000
100000
99996
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
99990
100000
100000
99919
99971
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
10000...

result:

ok 500000 numbers

Test #62:

score: 0
Accepted
time: 346ms
memory: 41228kb

input:

1
100000 16 500000
1 2
1 3
3 4
1 5
5 6
6 7
5 8
3 9
2 10
7 11
4 12
1 13
8 14
9 15
15 16
14 17
17 18
2 19
1 20
8 21
2 22
7 23
5 24
16 25
21 26
22 27
22 28
1 29
25 30
23 31
7 32
9 33
29 34
30 35
16 36
6 37
4 38
2 39
28 40
11 41
20 42
32 43
23 44
12 45
8 46
24 47
10 48
38 49
20 50
24 51
45 52
48 53
25 5...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #63:

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

input:

1
100000 20 500000
1 2
2 3
2 4
2 5
5 6
3 7
6 8
1 9
2 10
10 11
8 12
3 13
8 14
14 15
2 16
15 17
8 18
6 19
6 20
5 21
10 22
2 23
14 24
4 25
1 26
9 27
3 28
10 29
1 30
22 31
22 32
22 33
31 34
15 35
4 36
16 37
17 38
36 39
29 40
10 41
31 42
37 43
35 44
7 45
4 46
18 47
35 48
3 49
41 50
14 51
30 52
31 53
24 5...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #64:

score: 0
Accepted
time: 228ms
memory: 33692kb

input:

1
100000 6 500000
1 2
2 3
2 4
1 5
3 6
6 7
5 8
8 9
7 10
7 11
11 12
12 13
1 14
14 15
15 16
12 17
17 18
13 19
19 20
16 21
21 22
22 23
23 24
12 25
25 26
7 27
27 28
28 29
17 30
30 31
31 32
32 33
33 34
34 35
3 36
34 37
15 38
8 39
39 40
16 41
41 42
28 43
43 44
1 45
8 46
46 47
18 48
9 49
43 50
50 51
16 52
5...

output:

99836
98595
96321
64516
96414
96135
90138
71191
97279
98488
99300
93554
90641
88519
98916
98489
96145
63758
98777
58866
99916
97946
99145
89186
2632
89674
41891
83304
99864
98355
99070
99993
88169
45452
95536
99778
98536
48706
89291
90239
96956
96393
46134
91367
99629
97653
46378
77772
99868
98986
9...

result:

ok 500000 numbers

Test #65:

score: 0
Accepted
time: 228ms
memory: 34848kb

input:

1
100000 8 500000
1 2
1 3
3 4
4 5
2 6
6 7
3 8
8 9
9 10
10 11
11 12
12 13
13 14
1 15
2 16
16 17
17 18
10 19
19 20
17 21
13 22
6 23
6 24
11 25
3 26
9 27
27 28
24 29
23 30
30 31
3 32
28 33
33 34
23 35
35 36
20 37
5 38
38 39
39 40
26 41
5 42
11 43
8 44
5 45
2 46
14 47
47 48
37 49
38 50
22 51
1 52
52 53
...

output:

99278
87891
99949
88470
99785
60457
96364
98755
77519
86713
98282
98645
97144
93652
98802
98829
89466
92082
95524
82544
99448
99858
95043
97976
99069
99325
99339
79047
99782
99951
99451
92041
99953
97969
99923
99247
99324
96972
91502
99785
94780
99792
74873
76077
78038
99492
96638
88208
94875
91303
...

result:

ok 500000 numbers

Test #66:

score: 0
Accepted
time: 270ms
memory: 36516kb

input:

1
100000 10 500000
1 2
2 3
3 4
3 5
5 6
6 7
7 8
8 9
9 10
10 11
6 12
1 13
9 14
9 15
15 16
2 17
17 18
5 19
14 20
17 21
8 22
22 23
23 24
1 25
25 26
25 27
27 28
27 29
14 30
30 31
6 32
3 33
33 34
34 35
35 36
29 37
36 38
38 39
38 40
8 41
41 42
34 43
35 44
23 45
45 46
23 47
47 48
48 49
49 50
50 51
22 52
52 ...

output:

99977
93063
89844
94522
70705
99899
73754
99864
96318
89466
99882
99927
99714
98812
98910
99895
98087
99593
71765
93617
96144
98628
98067
95699
99315
90273
99968
96572
70914
99863
98688
99942
99606
5213
99990
98846
99954
99830
99961
99842
98205
99994
99659
96945
99962
69191
99941
99709
92623
69823
9...

result:

ok 500000 numbers

Test #67:

score: 0
Accepted
time: 322ms
memory: 39776kb

input:

1
100000 13 500000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
2 9
9 10
10 11
3 12
12 13
13 14
14 15
15 16
13 17
17 18
4 19
19 20
18 21
7 22
22 23
5 24
24 25
25 26
26 27
27 28
15 29
29 30
30 31
31 32
32 33
33 34
16 35
35 36
36 37
37 38
38 39
37 40
31 41
41 42
42 43
10 44
2 45
45 46
46 47
47 48
48 49
28 50
50 51
26 ...

output:

99958
99045
98986
99918
49774
96826
99385
99434
99981
99980
99763
99997
97241
100000
99942
99784
93131
100000
98028
99919
99964
93849
98383
99934
93336
94917
99710
98614
99823
99851
99921
95499
99533
99444
99979
99376
99997
99449
93990
99924
80037
99959
99785
99796
99982
99963
99730
99996
74040
9956...

result:

ok 500000 numbers

Test #68:

score: 0
Accepted
time: 363ms
memory: 41364kb

input:

1
100000 16 500000
1 2
1 3
3 4
1 5
3 6
2 7
2 8
8 9
9 10
8 11
11 12
12 13
12 14
14 15
15 16
8 17
17 18
10 19
8 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
7 28
17 29
20 30
12 31
31 32
32 33
33 34
5 35
29 36
36 37
37 38
11 39
39 40
16 41
35 42
42 43
25 44
44 45
45 46
46 47
47 48
31 49
49 50
3 51
41 5...

output:

100000
99957
99987
100000
99997
99623
99786
98090
99993
100000
100000
100000
99999
99954
99918
99004
100000
99937
99878
99967
99661
99944
99990
99221
99943
99892
99997
99610
98497
98980
99981
99997
100000
100000
99941
99881
99757
98629
99988
100000
99940
94993
100000
99915
99999
100000
99940
99169
9...

result:

ok 500000 numbers

Test #69:

score: 0
Accepted
time: 406ms
memory: 44404kb

input:

1
100000 20 500000
1 2
2 3
1 4
4 5
3 6
3 7
2 8
3 9
4 10
10 11
10 12
12 13
8 14
14 15
15 16
1 17
6 18
18 19
19 20
20 21
13 22
1 23
5 24
24 25
16 26
26 27
27 28
2 29
5 30
30 31
9 32
32 33
28 34
34 35
35 36
36 37
37 38
38 39
15 40
9 41
41 42
21 43
30 44
44 45
45 46
21 47
31 48
3 49
9 50
50 51
50 52
19 ...

output:

100000
99999
99993
100000
98927
100000
99959
100000
99397
99263
99997
99993
99996
99997
87553
100000
99823
100000
100000
99997
99996
99498
99988
99992
99962
100000
100000
99999
99826
99742
99972
99999
99995
99999
99997
99995
99998
99997
89190
100000
99979
99997
98584
100000
99918
100000
100000
99913...

result:

ok 500000 numbers

Test #70:

score: 0
Accepted
time: 181ms
memory: 33880kb

input:

1
100000 6 500000
1 2
1 3
3 4
1 5
1 6
1 7
1 8
6 9
6 10
1 11
10 12
1 13
5 14
4 15
15 16
10 17
9 18
14 19
11 20
1 21
1 22
14 23
1 24
1 25
1 26
1 27
23 28
13 29
1 30
30 31
1 32
1 33
1 34
24 35
22 36
1 37
1 38
9 39
1 40
31 41
1 42
1 43
36 44
40 45
2 46
1 47
1 48
1 49
1 50
33 51
48 52
31 53
18 54
6 55
1 ...

output:

99849
99994
99920
99936
99985
100000
99081
99999
100000
99965
100000
97663
99919
97127
100000
100000
99667
98760
100000
99966
99894
100000
99373
98826
99952
100000
99996
99652
97633
99998
99955
99877
98823
99994
99999
99994
99154
99982
99822
97509
99923
100000
100000
99983
98941
99995
99716
99996
99...

result:

ok 500000 numbers

Test #71:

score: 0
Accepted
time: 189ms
memory: 35332kb

input:

1
100000 8 500000
1 2
1 3
2 4
3 5
2 6
4 7
1 8
7 9
3 10
5 11
1 12
6 13
11 14
1 15
15 16
1 17
9 18
1 19
1 20
4 21
12 22
14 23
14 24
1 25
1 26
1 27
11 28
18 29
13 30
1 31
1 32
1 33
1 34
1 35
1 36
31 37
1 38
1 39
1 40
15 41
36 42
1 43
1 44
1 45
1 46
1 47
40 48
42 49
17 50
1 51
8 52
1 53
48 54
1 55
38 56...

output:

99981
99992
99999
100000
99541
99991
99996
100000
99979
99946
99990
99996
99950
100000
100000
99812
99994
100000
99928
100000
99699
100000
100000
99894
100000
100000
99965
99912
99970
99994
100000
99984
99993
100000
99759
99901
100000
100000
99999
100000
99980
99949
100000
100000
100000
99955
99987
...

result:

ok 500000 numbers

Test #72:

score: 0
Accepted
time: 188ms
memory: 36748kb

input:

1
100000 10 500000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
10 12
8 13
11 14
10 15
12 16
1 17
11 18
1 19
1 20
1 21
12 22
1 23
1 24
23 25
1 26
4 27
6 28
1 29
1 30
7 31
1 32
27 33
1 34
21 35
18 36
35 37
1 38
1 39
1 40
28 41
40 42
1 43
1 44
11 45
1 46
9 47
1 48
36 49
1 50
1 51
10 52
1 53
46 54
1 55
1 ...

output:

100000
100000
100000
99985
100000
100000
100000
100000
99998
99986
100000
100000
100000
100000
100000
100000
100000
99998
100000
100000
100000
100000
100000
99980
100000
100000
99996
99996
99982
100000
100000
100000
99997
100000
100000
99989
100000
100000
99998
99997
100000
100000
99989
100000
10000...

result:

ok 500000 numbers

Test #73:

score: 0
Accepted
time: 220ms
memory: 39804kb

input:

1
100000 13 500000
1 2
2 3
1 4
1 5
1 6
2 7
1 8
7 9
7 10
1 11
6 12
1 13
1 14
2 15
4 16
1 17
12 18
3 19
1 20
18 21
1 22
6 23
1 24
10 25
1 26
12 27
14 28
1 29
1 30
1 31
1 32
1 33
17 34
14 35
1 36
30 37
15 38
1 39
1 40
1 41
9 42
1 43
32 44
1 45
1 46
27 47
1 48
31 49
1 50
34 51
13 52
30 53
1 54
51 55
1 5...

output:

100000
100000
99999
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
99999
100000
100000
100000
100000
100000
100000
100000
100000
100000
1...

result:

ok 500000 numbers

Test #74:

score: 0
Accepted
time: 215ms
memory: 41392kb

input:

1
100000 16 500000
1 2
2 3
2 4
1 5
3 6
4 7
4 8
1 9
1 10
1 11
1 12
3 13
1 14
9 15
7 16
15 17
1 18
1 19
1 20
1 21
17 22
1 23
1 24
1 25
1 26
1 27
19 28
9 29
1 30
2 31
1 32
5 33
22 34
13 35
15 36
1 37
1 38
20 39
1 40
1 41
1 42
7 43
31 44
36 45
24 46
30 47
3 48
1 49
1 50
1 51
24 52
1 53
1 54
41 55
1 56
1...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #75:

score: 0
Accepted
time: 242ms
memory: 44428kb

input:

1
100000 20 500000
1 2
1 3
3 4
3 5
3 6
5 7
1 8
1 9
1 10
1 11
4 12
4 13
2 14
1 15
5 16
1 17
9 18
4 19
1 20
1 21
3 22
1 23
1 24
21 25
1 26
5 27
1 28
1 29
1 30
30 31
1 32
24 33
31 34
9 35
1 36
1 37
36 38
1 39
1 40
33 41
27 42
34 43
33 44
1 45
1 46
12 47
4 48
34 49
32 50
1 51
1 52
30 53
23 54
5 55
12 56...

output:

100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000...

result:

ok 500000 numbers

Test #76:

score: 0
Accepted
time: 169ms
memory: 33312kb

input:

1
100000 6 500000
1 2
2 3
2 4
4 5
5 6
4 7
7 8
8 9
9 10
7 11
11 12
12 13
13 14
14 15
11 16
16 17
17 18
18 19
19 20
20 21
16 22
22 23
23 24
24 25
25 26
26 27
27 28
22 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
29 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
37 46
46 47
47 48
48 49
49 50
50 51
...

output:

27516
93490
8832
5202
56666
41584
76079
6823
28593
5443
62747
23545
25898
58180
75460
68219
44598
3760
1466
18900
74937
663
18333
31747
1759
54988
60854
26435
49226
7223
95956
45817
41131
39054
88488
32414
78299
20260
4558
45410
9681
39275
52291
5902
78166
20177
14826
16073
41787
53986
48554
35354
2...

result:

ok 500000 numbers

Test #77:

score: 0
Accepted
time: 192ms
memory: 34800kb

input:

1
100000 8 500000
1 2
2 3
2 4
4 5
5 6
4 7
7 8
8 9
9 10
7 11
11 12
12 13
13 14
14 15
11 16
16 17
17 18
18 19
19 20
20 21
16 22
22 23
23 24
24 25
25 26
26 27
27 28
22 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
29 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
37 46
46 47
47 48
48 49
49 50
50 51
...

output:

8433
26549
78797
41043
25567
42008
33496
8017
4987
6353
3268
13368
30325
21027
49742
5408
32709
30611
46449
57967
27711
9253
36708
75292
14136
230
38140
8611
60207
33557
32800
2801
7099
15728
31603
20190
78409
50110
67402
42163
9087
21063
6087
33622
44266
35872
42375
57597
25516
14267
46035
14503
54...

result:

ok 500000 numbers

Test #78:

score: 0
Accepted
time: 200ms
memory: 36396kb

input:

1
100000 10 500000
1 2
2 3
2 4
4 5
5 6
4 7
7 8
8 9
9 10
7 11
11 12
12 13
13 14
14 15
11 16
16 17
17 18
18 19
19 20
20 21
16 22
22 23
23 24
24 25
25 26
26 27
27 28
22 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
29 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
37 46
46 47
47 48
48 49
49 50
50 51...

output:

76590
26086
59581
45539
18901
13724
12733
56873
78332
9416
68826
1608
35985
63621
72688
66827
21345
7894
46634
16621
61250
63795
3146
38266
25305
1044
5938
9461
42531
25227
26335
30707
5103
52677
21497
25682
3178
42187
18856
2295
14764
29313
15006
16344
40957
6989
47859
17981
20905
13776
2485
41211
...

result:

ok 500000 numbers

Test #79:

score: 0
Accepted
time: 225ms
memory: 39624kb

input:

1
100000 13 500000
1 2
2 3
2 4
4 5
5 6
4 7
7 8
8 9
9 10
7 11
11 12
12 13
13 14
14 15
11 16
16 17
17 18
18 19
19 20
20 21
16 22
22 23
23 24
24 25
25 26
26 27
27 28
22 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
29 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
37 46
46 47
47 48
48 49
49 50
50 51...

output:

36040
9376
28430
16066
73539
33304
19203
18576
35782
31286
42336
14408
12013
8852
27430
40548
58995
76492
12025
35096
71483
32051
40770
58441
1303
13374
19530
64532
41387
2676
18656
53443
43239
37660
27934
33685
64830
55379
92692
17703
15741
11596
41784
31476
26081
9016
33872
73697
29642
16048
31740...

result:

ok 500000 numbers

Test #80:

score: 0
Accepted
time: 231ms
memory: 41360kb

input:

1
100000 16 500000
1 2
2 3
2 4
4 5
5 6
4 7
7 8
8 9
9 10
7 11
11 12
12 13
13 14
14 15
11 16
16 17
17 18
18 19
19 20
20 21
16 22
22 23
23 24
24 25
25 26
26 27
27 28
22 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
29 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
37 46
46 47
47 48
48 49
49 50
50 51...

output:

19426
92624
30002
27792
2094
1280
75717
71765
15086
9953
20551
51441
18560
12887
60009
6464
39092
27929
44721
12429
38609
24513
59501
22220
5630
61068
163
72476
29053
71615
30725
37322
40180
45136
9825
50891
41343
56065
12266
80562
16737
36992
12680
22156
8294
35209
89209
57784
22548
23488
43391
178...

result:

ok 500000 numbers

Test #81:

score: 0
Accepted
time: 265ms
memory: 44400kb

input:

1
100000 20 500000
1 2
2 3
2 4
4 5
5 6
4 7
7 8
8 9
9 10
7 11
11 12
12 13
13 14
14 15
11 16
16 17
17 18
18 19
19 20
20 21
16 22
22 23
23 24
24 25
25 26
26 27
27 28
22 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
29 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
37 46
46 47
47 48
48 49
49 50
50 51...

output:

1728
23713
89050
49222
43809
48825
62716
49614
17914
9139
66536
32713
16854
6852
40624
12331
92545
84837
14450
34522
7664
81085
10894
8988
40244
11333
12136
33176
887
43667
58116
43387
33509
66361
44332
25923
13345
40192
76262
10469
15131
41413
46278
85938
4774
28140
36883
9500
54638
27470
69746
432...

result:

ok 500000 numbers

Extra Test:

score: 0
Extra Test Passed