QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#315119#2210. Hamilton PathelimvaAC ✓1331ms125920kbC++206.8kb2024-01-26 23:51:172024-01-26 23:51:18

Judging History

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

  • [2024-01-26 23:51:18]
  • 评测
  • 测评结果:AC
  • 用时:1331ms
  • 内存:125920kb
  • [2024-01-26 23:51:17]
  • 提交

answer

#include <bits/stdc++.h>

using int64 = long long;

const int N = 5e5 + 10;
const int mod = 1e9 + 7;

std::vector<int> edges[N], pred[N];
std::map<int, int> from[N];
int dsu[N], head[N], tail[N], next[N];
int deg[N], prev[N];
;
int64 pw[N];
int n, m;

int get(int x) {
  if (dsu[x] != x) dsu[x] = get(dsu[x]);
  return dsu[x];
}

bool check(const std::vector<int> &path) {
  std::vector<int> idx(n);
  for (int i = 0; i < n; ++i) idx.at(path[i]) = i;
  for (int u = 0; u < n; ++u) {
    for (auto &v : edges[u]) {
      int i = idx[u], j = idx[v];
      if (i < j && i + 1 != j) return false;
    }
  }
  return true;
};

int process(const std::vector<int> &forbid, std::vector<std::pair<int, int>> &extra) {
  for (int i = 0; i < n; ++i) {
    head[i] = tail[i] = dsu[i] = i;
    prev[i] = next[i] = -1;
    deg[i] = 0;
    from[i].clear();
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) if (!forbid[i]) {
    ++cnt;
    for (auto &v : edges[i]) if (!forbid[v]) {
      deg[i]++; from[v][i]++;
    }
  }
  std::vector<int> queue;
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 1 && !forbid[i]) queue.push_back(i);
  }
  for (size_t i = 0; i < queue.size(); ++i) {
    int ru = get(queue[i]);
    int u = tail[get(queue[i])];
    if (deg[u] != 1) continue;
    int go = -1;
    for (auto &v : edges[u]) if (!forbid[v]) {
      if (get(v) != ru) go = v;
    }
    assert(go != -1);
    int rg = get(go), v = tail[rg];
    if (head[rg] == go) {
      next[u] = go; prev[go] = u;
      dsu[rg] = ru; tail[ru] = v;
      if (from[ru].size() < from[rg].size()) {
        std::swap(from[ru], from[rg]);
      }
      cnt -= 1;
      for (auto &e : from[rg]) from[ru][e.first] += e.second;
      auto it = from[ru].find(v);
      if (it != from[ru].end()) {
        deg[v] -= it->second;
        from[ru].erase(it);
        if (deg[v] == 1) queue.push_back(v);
      }
    } else {
      extra.emplace_back(u, go);
    }
  }
  return cnt;
}

int main() {
  // int T, type;
  // scanf("%d%d", &type, &T);
  int T;
  scanf("%d", &T);
  for (int cas = 1; cas <= T; ++cas) {
    scanf("%d%d", &n, &m);
    pw[0] = 1;
    for (int i = 1; i <= n; ++i) {
      pw[i] = pw[i - 1] * 10 % mod;
    }
    for (int i = 0; i < n; ++i) {
      pred[i].clear();
      edges[i].clear();
    }
    for (int i = 0; i < m; ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      edges[u - 1].push_back(v - 1);
      if (cas == 11660)
        fprintf(stderr, "%d %d\n", u, v);
    }
    for (int i = 0; i < n; ++i) {
      std::sort(edges[i].begin(), edges[i].end());
      edges[i].erase(std::unique(edges[i].begin(), edges[i].end()), edges[i].end());
    }
    std::vector<int> forbid(n);
    for (int i = 0; i < n; ++i) pred[i].clear();
    for (int i = 0; i < n; ++i) {
      for (auto &v : edges[i]) pred[v].push_back(i);
    }

    std::vector<std::pair<int, int>> extra;
    int cnt = process(forbid, extra);

    auto get_sum = [&](const std::vector<int> &path) {
      int64 sum = 0;
      for (int i = 0; i < n; ++i) {
        sum = (sum + (path[i] + 1) * pw[n - 1 - i]) % mod;
      }
      return sum;
    };

    std::vector<std::pair<int, int64>> ret;

    auto brute = [&](int s) {
      std::vector<int> path = {s};
      std::vector<bool> mark(n);
      mark[s] = true;
      for (int i = 1; i < n; ++i) {
        int go = -1, cnt = 0;
        for (auto &x : pred[s]) if (!mark[x]) {
          go = x;
          cnt++;
        }
        if (cnt != 1) break;
        path.push_back(s = go);
        mark[s] = true;
      }
      if (path.size() != n) return;
      std::reverse(path.begin(), path.end());
      if (check(path)) ret.emplace_back(path[0], get_sum(path));
    };

    if (cnt == 1) {
      int u = head[get(0)], v = tail[get(0)];
      std::vector<int> path, idx(n);
      for (int x = u; x != -1; x = next[x]) {
        idx[x] = path.size();
        path.push_back(x);
      }
      int64 sum = get_sum(path);
      std::vector<int> mark(n + 1);
      std::vector<bool> visited(n);
      for (int i = 0; i + 1 < n; ++i) {
        for (auto &v : edges[path[i]]) if (v != path[i + 1]) {
          mark[idx[v] + 1]++;
          mark[i + 1]--;
        }
      }
      for (int i = 1; i <= n; ++i) mark[i] += mark[i - 1];
      int best = -1;
      for (auto &x : edges[v]) {
        visited[idx[x]] = true;
        if (idx[x] != 0 && (best == -1 || best > idx[x]))
          best = idx[x];
      }
      if (best != -1) {
        for (int i = best + 1; i < n; ++i) mark[i]++;
      }
      if (visited[0]) {
        for (int i = 0; i < n; ++i) {
          if (!mark[i]) ret.emplace_back(path[i], sum);
          sum = sum - (path[i] + 1) * pw[n - 1] % mod;
          sum = (sum + mod) % mod;
          sum = (sum * 10 + path[i] + 1) % mod;
        }
      } else {
        ret = {{path[0], sum}};
        int middle = -1;
        for (int i = 0; i < n; ++i) {
          bool found = false;
          for (auto &x : edges[path[i]]) {
            if (idx[x] == 0) found = true;
          }
          if (found) middle = i;
        }
        if (middle != -1) {
          int end = -1;
          for (int i = 1; i <= middle; ++i) {
            for (auto &x: pred[path[i]]) if (idx[x] > middle) {
              end = i;
            }
          }
          if (end != -1) brute(path[end - 1]);
        }
      }
    } else {
      std::vector<std::pair<int, int>> bad;
      for (auto &e : extra) {
        int u = get(e.first), v = get(e.second);
        if (u != v && tail[u] == e.first) bad.push_back(e);
      }
      if (bad.size() >= 1) {
        for (size_t i = 0; i < bad.size() && i < 2; ++i) {
          int u = bad[i].first, v = bad[i].second;
          brute(u);
          std::vector<int> path, idx(n, -1), bad(n + 1);
          for (u = head[get(v)]; u != v; u = next[u]) path.push_back(u);
          for (size_t i = 0; i < path.size(); ++i) idx[path[i]] = i;
          for (size_t i = 1; i < path.size(); ++i) {
            for (auto &x: edges[path[i]]) if (idx[x] != -1 && idx[x] < i) {
              if (idx[x] != 0) bad[idx[x]]++, bad[i]--;
            }
          }
          for (int i = 1; i <= n; ++i) bad[i] += bad[i - 1];
          int end = path[0];
          for (size_t i = 1; i < path.size(); ++i) {
            int found = 0;
            for (auto &x: pred[path[i]]) found |= idx[x] == -1;
            if (found) break;
            if (!bad[i]) end = path[i];
          }
          brute(end);
        }
      }
    }
    std::sort(ret.begin(), ret.end());
    ret.erase(std::unique(ret.begin(), ret.end()), ret.end());
    printf("%d\n", (int)ret.size());
    for (size_t i = 0; i < ret.size(); ++i) {
      printf("%lld", ret[i].second);
      putchar(" \n"[i + 1 == ret.size()]);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
13425 34251

result:

ok 3 number(s): "2 13425 34251"

Test #2:

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

input:

67777
9 32
6 3
5 2
7 3
7 8
5 2
5 2
7 8
8 2
7 3
8 9
4 3
2 3
4 3
3 1
1 3
8 3
9 8
3 2
5 6
4 5
9 4
6 7
2 8
5 4
5 3
7 8
5 1
6 9
8 3
6 9
7 8
4 1
5 12
3 5
2 3
4 5
2 5
5 3
1 4
3 2
2 4
1 4
4 1
2 5
4 5
2 10
1 2
1 2
1 2
2 1
1 2
1 2
1 2
1 2
1 2
1 2
10 28
1 9
5 9
6 1
10 5
8 7
1 4
7 10
7 5
6 8
9 4
2 9
6 4
2 6
1 1...

output:

1
132894567
2
14532 53241
2
12 21
1
594731198
1
74123568
2
12 21
1
6241735
1
1
1
513264
1
7241356
2
213 312
1
247381965
1
123
1
31524
2
12 21
1
1
1
12
2
132 231
1
41268753
1
245378846
1
526134
1
413652
1
12345
1
31542
2
12 21
1
5624713
1
4675213
3
202947333 852029431 520294680
1
312
1
427915798
2
21...

result:

ok 148279 numbers

Test #3:

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

input:

90961
2 4
2 1
2 1
2 1
2 1
4 8
4 3
2 1
4 3
1 2
4 1
1 4
1 2
4 2
5 22
1 3
5 2
3 1
3 4
3 4
2 3
2 4
3 2
5 4
5 3
4 3
2 1
1 4
1 2
1 3
2 1
4 5
4 3
1 5
5 3
2 3
4 5
8 22
1 4
3 8
8 6
5 7
5 6
1 3
1 2
8 5
8 3
5 2
6 5
2 5
6 1
6 7
5 4
2 4
4 1
6 3
4 3
8 1
6 5
7 6
10 7
10 8
9 3
10 5
4 6
10 7
10 3
3 1
8 28
7 8
8 5
6 ...

output:

1
21
1
2143
0
0
0
0
1
1
2
12 21
0
0
0
0
2
12 21
1
1
0
0
1
1
0
0
0
0
0
1
1
0
0
1
213
0
0
0
1
1
0
0
0
2
123 231
2
12 21
0
0
1
2413
0
0
0
1
1
1
1
2
12 21
0
0
0
0
1
213
0
0
1
132
0
2
12 21
0
0
1
1
1
1
0
0
0
0
1
21
0
2
12 21
1
34152
0
0
1
1
0
0
1
1
0
1
1
0
0
0
0
0
1
1
0
0
0
0
2
12 21
0
0
1
1
0
1
123
0
0
...

result:

ok 124496 numbers

Test #4:

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

input:

64460
7 24
6 7
1 3
2 1
5 6
7 5
2 5
4 2
3 1
3 4
1 5
7 6
1 7
1 6
7 2
2 7
4 5
4 3
6 5
7 6
3 1
7 5
2 7
1 7
1 2
7 18
6 2
7 5
3 4
4 5
2 1
6 2
7 6
7 6
5 7
7 6
3 2
1 2
7 2
5 2
1 6
5 1
3 6
3 6
2 4
2 1
2 1
1 2
2 1
5 26
5 1
3 1
5 2
1 4
3 5
2 1
3 4
3 5
1 4
3 4
2 1
2 3
1 4
2 1
1 4
2 4
1 2
3 1
5 2
2 1
4 1
3 4
3 1...

output:

1
5672134
0
2
12 21
1
41235
1
15324
2
1764352 7643521
1
1234
1
374219658
1
264531
1
812937456
1
132
1
1
2
12 21
1
6174235
1
134800596
1
273591684
1
321
0
2
12 21
1
625143
1
1
1
213
1
872632014
1
612345
1
65384172
1
193248657
1
786034249
1
85462731
1
231
1
31542
1
574618392
1
376952184
1
3467512
1
42...

result:

ok 132329 numbers

Test #5:

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

input:

67484
4 19
1 3
4 3
2 3
2 3
4 3
2 3
3 4
4 1
4 1
2 4
2 3
2 1
4 1
4 1
4 3
4 2
4 1
2 1
3 1
10 23
8 4
6 4
6 5
3 2
10 9
5 4
9 5
7 10
8 1
2 6
5 4
2 9
8 4
6 2
5 7
6 3
2 4
9 4
7 1
10 1
4 8
5 2
1 7
2 10
2 1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 0
8 22
5 4
5 4
6 2
3 2
6 1
8 5
2 3
5 3
7 4
2 6
2 3
5 4
5 6
5 3
1 ...

output:

1
1342
1
818095235
2
12 21
1
1
1
32617485
1
3142
2
12 21
1
3214567
1
218350734
1
824796351
1
5173264
1
1
1
123
1
623918456
2
12 21
1
2613475
1
491303652
1
983561724
1
123
3
652314987 765231498 876523149
1
1
1
68451732
1
34125876
1
1
2
231 312
2
123 312
1
81457263
1
3214
1
1
2
12 21
1
520462889
1
715...

result:

ok 147424 numbers

Test #6:

score: 0
Accepted
time: 185ms
memory: 27284kb

input:

90788
3 3
2 1
2 3
1 3
5 18
3 2
5 4
4 3
4 3
5 3
3 5
3 4
2 1
2 1
3 2
5 3
4 5
3 5
1 5
3 2
5 2
1 4
2 5
7 4
1 2
5 1
6 7
7 6
8 11
5 4
7 8
4 6
2 3
6 3
2 5
2 6
3 1
7 4
4 7
6 3
8 2
6 8
1 4
5 4
2 5
2 4
1 4
1 3
10 18
5 6
8 5
9 4
4 1
4 8
4 9
6 5
10 8
2 7
2 3
5 10
4 10
8 4
2 1
2 8
2 4
2 3
5 8
8 17
4 6
4 1
2 5
8 ...

output:

0
0
0
0
0
0
0
0
0
0
1
21
0
0
0
0
1
1
0
0
1
213
0
2
12 21
0
0
0
0
1
1432
0
0
0
2
213 321
0
0
0
2
12 21
0
2
12 21
0
0
1
52143
2
12 21
0
2
12 21
1
321
1
1
1
1
0
0
0
0
0
0
1
1
1
321
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
321
0
2
12 21
2
12 21
0
0
0
1
321456
0
1
132
1
213
2
12 21
0
0
0
0
0
0
1
1
0
0
0
0
1
1
0
0...

result:

ok 124312 numbers

Test #7:

score: 0
Accepted
time: 212ms
memory: 27276kb

input:

64767
2 2
1 2
1 2
6 22
4 6
4 2
2 6
1 2
2 6
1 3
5 2
5 3
5 6
1 4
2 1
4 2
2 6
6 3
3 6
5 3
6 3
2 3
6 3
5 6
4 2
6 5
8 14
5 8
7 1
8 3
3 5
1 3
5 7
1 6
2 5
6 4
8 2
3 7
2 1
6 5
4 3
5 10
3 4
4 5
2 4
2 3
2 3
5 1
1 3
3 2
2 5
2 1
8 16
2 3
6 8
2 4
5 8
7 4
3 4
2 1
1 5
1 2
4 5
2 4
8 6
6 3
7 2
7 2
2 7
3 19
1 3
1 2
3...

output:

1
12
1
365214
0
1
45132
0
1
231
1
3742516
1
1
7
1437625 2514376 3762514 4376251 5143762 6251437 7625143
1
6271354
1
789165432
1
354612
1
45123
0
1
618432975
1
891270509
1
6521374
0
1
213
1
1243
2
12 21
0
1
351462
1
4356127
1
1324
1
231
1
3412
1
942367815
1
123
1
213
1
45321
1
261435
1
803869097
1
32...

result:

ok 132887 numbers

Test #8:

score: 0
Accepted
time: 221ms
memory: 27276kb

input:

67812
6 32
2 3
4 6
1 2
2 4
2 6
3 4
1 4
4 5
1 5
3 6
1 6
6 3
3 6
2 6
4 5
5 6
2 3
1 3
2 6
1 2
2 4
2 1
1 2
4 6
1 2
2 6
3 6
1 4
2 6
2 3
4 3
4 2
7 31
6 3
4 7
1 4
6 4
3 2
6 2
2 5
3 4
2 3
6 2
5 7
7 4
6 2
1 4
1 6
1 3
4 3
4 7
6 1
1 2
5 3
3 4
3 4
5 1
1 4
5 4
2 7
4 7
1 5
5 4
6 1
7 19
1 2
1 4
3 5
1 6
1 4
2 5
1 7...

output:

1
563421
1
7432516
1
7532416
1
4257316
2
12 21
1
5463721
1
1
1
51672348
1
38174562
1
183005348
1
51463278
1
2314
1
428691705
1
2314
1
209642804
1
23514
1
1
1
613524
2
419682357 682357194
2
12 21
1
625341
1
1
1
3245671
2
132 231
1
21
1
6152347
2
12 21
1
781704274
1
86432157
1
24135
1
47316852
1
54836...

result:

ok 148213 numbers

Test #9:

score: 0
Accepted
time: 184ms
memory: 27260kb

input:

91345
2 12
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 2
2 1
2 1
1 2
2 1
2 2
2 1
1 2
7 24
1 2
4 6
5 2
7 1
2 4
3 6
6 4
7 4
4 3
2 4
6 1
6 1
3 7
4 3
7 1
2 7
1 3
7 1
7 4
5 1
5 7
6 7
6 7
1 4
3 4
1 3
1 3
1 2
1 3
7 22
7 5
4 1
5 1
2 1
7 2
3 5
6 7
4 2
4 7
1 4
1 6
5 4
1 6
2 7
1 3
6 3
7 2
1 4
4 2
1 2
6 3
3 5
5 17
1 5
2 5
4 ...

output:

2
12 21
2
12 21
0
0
0
1
34521
0
1
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
2
12 21
0
0
2
12 21
2
12 21
0
0
1
12
1
1
1
2143
2
12 21
0
2
12 21
0
0
0
2
12 21
0
0
2
12 21
0
0
0
0
2
12 21
0
0
0
0
1
4312
2
12 21
0
0
0
0
0
2
12 21
1
1
1
123
0
0
0
0
0
0
2
12 21
0
0
1
31254
0
0
0
0
0
0
0
0
0
0
2
12 21
1
1
0
1
3476521
0...

result:

ok 125201 numbers

Test #10:

score: 0
Accepted
time: 217ms
memory: 27552kb

input:

64447
3 4
1 2
2 3
3 1
3 2
6 21
4 3
4 6
6 3
3 5
4 6
6 2
1 5
2 5
1 5
3 4
5 2
3 1
3 1
1 6
1 5
4 1
5 1
4 2
4 6
3 6
6 5
6 13
3 2
4 1
6 5
3 5
2 5
5 2
5 3
3 4
6 3
6 5
1 6
4 3
3 2
8 32
7 3
4 2
1 4
7 4
5 4
7 1
4 3
5 6
1 4
3 4
4 2
5 7
1 7
1 7
7 8
1 4
5 1
8 6
3 8
2 8
3 7
3 4
5 4
1 7
3 6
7 6
1 3
1 5
3 2
3 6
6 4...

output:

2
123 231
1
251634
1
253416
1
28643715
1
231
3
35124 43512 51243
1
15234
1
312
1
5237461
1
15432
0
1
37645812
2
12 21
0
1
718392465
2
12 21
1
3124
0
1
312
1
684297513
1
41682735
1
42178356
1
231
2
21436875 36875142
1
532896471
1
261453
1
542631
1
1473526
1
24513
1
12
1
590917604
2
12 21
3
425736819 ...

result:

ok 132279 numbers

Test #11:

score: 0
Accepted
time: 226ms
memory: 27540kb

input:

67818
6 23
2 6
2 5
3 5
4 5
2 1
2 3
3 5
2 4
3 4
5 4
4 6
1 2
2 4
3 6
2 5
6 5
1 6
3 1
6 3
2 6
6 5
4 5
1 5
9 11
8 7
3 2
8 3
6 7
4 3
1 5
5 8
8 9
6 3
7 1
2 6
9 26
8 5
6 5
4 3
3 9
5 1
2 4
4 2
6 3
6 8
2 3
8 1
2 3
4 6
4 1
7 5
8 4
5 9
1 3
7 9
9 7
1 6
8 9
5 9
8 5
2 8
2 3
6 9
1 3
3 4
1 6
5 6
2 1
4 6
4 2
4 1
6 2...

output:

1
546312
1
432671589
1
397516842
1
562134
1
321
3
132 213 321
1
652978480
1
7426315
1
1675342
2
317289456 894562173
1
231
1
681429753
1
13654827
1
123
1
132
1
321645
1
7132654
1
81492334
1
431526
1
4321
1
437295681
1
24786315
1
562143
1
4231
1
7154362
1
83271456
1
132
1
1
1
520678921
1
4261753
1
185...

result:

ok 148279 numbers

Test #12:

score: 0
Accepted
time: 184ms
memory: 27280kb

input:

91112
1 0
9 19
2 7
7 9
2 8
6 5
4 5
2 4
8 1
1 9
1 8
4 2
2 8
7 4
9 3
9 3
8 1
8 5
1 7
6 8
3 5
1 0
4 17
1 2
4 3
3 4
1 2
1 3
1 3
3 4
1 4
2 3
4 2
2 1
3 4
1 4
1 3
1 2
2 4
3 1
3 5
2 1
1 2
3 1
3 2
3 1
4 5
2 1
3 1
1 3
3 4
3 2
3 22
3 2
2 3
2 3
3 2
1 2
1 3
2 1
2 1
3 2
1 2
1 2
3 1
3 2
3 2
2 3
1 2
2 1
1 3
2 1
3 2...

output:

1
1
0
1
1
0
0
1
2134
0
2
12 21
1
1
0
0
0
0
0
1
1
0
0
1
1
0
2
12 21
1
21
0
0
0
0
0
0
0
0
0
1
2431
0
0
0
0
2
12 21
1
1
0
0
0
0
0
2
12 21
0
0
0
0
0
0
2
12 21
0
2
12 21
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
2
12 21
1
1
0
0
1
4213
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1342
0
0
0
1
123
0
0
2
12 21
0...

result:

ok 124751 numbers

Test #13:

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

input:

64942
5 15
5 2
5 3
1 4
2 3
2 3
2 3
2 1
2 3
4 3
5 1
5 3
2 5
1 3
3 1
4 5
9 24
6 2
2 6
2 1
6 8
7 2
6 5
7 4
4 2
5 7
1 2
3 9
3 2
8 1
9 4
4 6
7 2
9 6
7 8
4 5
7 2
9 6
9 8
3 5
4 3
8 29
8 7
7 1
7 8
3 7
2 6
1 2
3 8
5 7
6 4
5 1
6 1
5 6
3 4
6 2
3 7
1 4
6 2
8 5
3 5
5 1
5 7
1 4
8 1
7 1
3 1
3 5
5 2
6 7
5 3
1 0
9 3...

output:

1
31452
1
812657439
0
1
1
1
739415826
1
12
1
3142
1
321
1
24513
1
698741532
2
12 21
0
1
859461723
1
25134
1
359174676
2
123 321
1
38267514
1
81753264
1
3214
1
1342
1
35214
1
5314627
1
87634512
1
35612487
1
7314265
1
213
1
123645
1
1
1
314256
1
98674518
1
51734826
1
1
1
749518356
1
312
1
16327854
1
2...

result:

ok 133220 numbers

Test #14:

score: 0
Accepted
time: 222ms
memory: 27232kb

input:

67710
3 11
3 2
3 2
1 2
1 3
3 1
3 2
1 3
3 2
1 2
1 2
2 3
2 13
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
1 2
2 1
8 16
2 7
2 8
3 8
2 1
7 3
2 5
8 4
8 3
5 3
2 7
4 6
7 1
6 7
1 2
7 8
6 8
1 0
9 15
3 1
8 2
4 9
7 9
3 8
2 4
2 8
6 4
9 3
5 1
6 9
6 7
1 5
3 9
5 6
8 25
1 4
6 1
3 2
1 3
1 2
6 5
8 6
6 2
8 1
6 5
1 7
8...

output:

1
231
2
12 21
2
38467125 53846712
1
1
1
824931567
1
32714568
1
387195264
1
2431
1
21453
1
34251
2
12 21
1
572136498
1
154362
1
67482531
1
231
1
25134
1
496021846
2
236154 542361
1
130853701
1
487915193
1
73684512
1
148395726
1
631524
1
83526147
1
123
1
1
2
12 21
1
126534
1
1
1
1
1
21354
2
12 21
1
19...

result:

ok 148022 numbers

Test #15:

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

input:

91134
5 12
5 4
2 3
5 3
3 5
3 4
3 1
3 4
1 3
1 4
1 5
1 5
4 5
2 5
1 2
2 1
1 2
1 2
2 1
4 13
2 4
2 3
2 1
1 3
1 4
4 2
2 4
1 4
2 4
1 3
2 4
3 1
1 4
8 5
3 8
7 4
1 8
6 8
3 8
1 0
3 2
2 1
2 3
3 3
1 2
3 2
2 1
9 9
8 9
6 4
7 4
3 4
4 3
4 7
3 7
7 6
6 1
1 0
7 19
2 4
2 5
6 4
6 2
6 3
2 3
4 2
4 3
4 5
7 4
6 3
5 6
1 7
4 5...

output:

0
2
12 21
1
3142
0
1
1
0
1
321
0
1
1
0
0
2
12 21
1
21
0
2
12 21
0
1
312
2
12 21
0
0
1
132
0
0
0
0
0
0
0
0
0
1
231
0
0
0
0
2
12 21
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
2
12 21
0
0
0
0
1
1
0
0
2
12345 34521
0
0
1
1
0
0
0
0
0
0
0
1
1
0
0
2
12 21
0
0
0
0
0
0
0
0
0
2
12 21
0
0
1
1
0
0
0
0
1
21
0
0
0
0
1
1
0
0...

result:

ok 124996 numbers

Test #16:

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

input:

64745
1 0
6 29
6 1
4 6
2 1
6 2
2 4
2 6
5 1
2 4
2 5
4 3
2 6
6 1
2 6
2 5
1 3
2 5
2 5
2 3
5 4
5 3
3 5
6 3
2 1
2 6
2 6
4 1
2 1
6 3
2 6
3 15
2 3
2 1
3 1
2 1
1 2
2 1
1 3
2 3
2 3
2 3
2 3
1 3
2 3
2 1
1 3
8 28
2 1
2 5
6 8
7 4
3 8
5 1
5 1
3 4
1 7
4 5
5 3
8 3
2 7
2 4
8 5
8 4
6 7
2 8
8 7
8 3
8 5
2 4
2 8
8 6
3 5...

output:

1
1
1
135462
1
312
0
1
1
1
6417325
1
21435
1
153624
2
341526 634152
1
213
1
4123
1
3412
1
7134256
1
13245
1
1374652
1
32145
1
806432103
1
83526714
1
32451
1
814329565
1
165423
1
24531
1
521880892
1
81367452
2
12 21
1
31542
2
12 21
1
132
1
127835467
4
218937465 465218937 521893746 652189374
1
213
1
1...

result:

ok 132955 numbers

Test #17:

score: 0
Accepted
time: 227ms
memory: 27292kb

input:

67788
6 16
1 6
3 5
3 5
5 2
5 4
3 5
5 6
5 3
4 1
1 6
4 5
6 1
3 6
1 2
2 4
3 6
1 0
6 18
1 2
3 2
5 3
5 1
3 6
5 4
2 1
4 3
3 1
3 2
3 1
6 2
5 1
4 5
4 2
3 5
1 3
4 2
2 10
2 1
2 1
2 1
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 0
2 7
2 1
2 1
2 1
1 2
2 1
2 1
2 1
3 8
1 3
3 2
1 2
3 2
2 1
3 2
1 2
3 2
10 15
3 6
3 5
9 8
4 3
5 10
...

output:

1
612453
1
1
1
621354
2
12 21
1
1
2
12 21
2
213 321
1
607198422
2
1432 3241
1
87645231
2
3412 4123
2
12 21
1
163245
2
3241 4123
2
12 21
2
213 321
1
1
2
12 21
3
482513976 648251397 764825139
1
51342
1
123
1
192574638
2
12 21
1
75418632
1
808163259
1
842965371
2
12 21
1
412365
1
146235
1
45321
1
2134
...

result:

ok 148473 numbers

Test #18:

score: 0
Accepted
time: 174ms
memory: 27276kb

input:

90788
5 17
3 5
5 3
4 5
3 1
5 4
1 5
5 2
2 5
1 5
3 4
5 2
4 5
1 3
4 1
2 5
2 4
2 3
3 9
2 3
2 3
2 1
3 2
2 3
2 1
3 1
3 1
2 1
4 22
4 3
2 1
4 1
2 3
1 4
3 2
4 1
3 2
2 3
3 1
4 3
3 4
1 4
3 2
3 1
4 2
4 3
4 3
1 2
1 3
3 1
4 2
10 12
2 5
10 2
10 7
10 3
2 5
9 10
10 6
5 4
3 10
3 10
1 2
3 10
3 6
1 2
3 1
3 1
3 1
2 3
1 ...

output:

0
0
0
0
3
123 231 312
0
0
0
0
0
0
0
0
0
2
12 21
0
0
0
0
0
1
132
2
12 21
0
0
0
0
1
1
0
0
1
321
0
0
1
1
2
12 21
0
2
12 21
0
0
0
0
0
0
1
123
1
12
0
1
1
1
1
0
0
1
1
0
0
0
0
0
2
12 21
0
0
0
0
0
0
0
0
0
3
132 213 321
0
1
321
0
1
67254138
0
0
0
1
1
0
1
1
0
0
0
0
2
12 21
0
0
0
0
1
1
1
1
0
0
0
0
0
1
123
0
1
...

result:

ok 123950 numbers

Test #19:

score: 0
Accepted
time: 217ms
memory: 27268kb

input:

64720
3 4
1 3
1 2
1 3
3 1
9 24
9 3
2 3
4 7
1 9
7 2
1 3
8 5
8 4
9 1
4 3
4 5
9 3
1 7
5 6
9 8
6 1
4 3
3 4
1 4
8 6
5 7
3 7
8 7
1 3
2 14
1 2
1 2
1 2
1 2
1 2
1 2
2 1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
7 28
4 2
5 4
4 3
6 2
5 4
6 2
4 3
7 1
4 7
6 2
3 2
6 1
4 6
4 6
2 1
7 5
5 2
5 7
2 3
6 4
5 6
1 6
5 4
7 6
6 3
7 2
5 4...

output:

1
312
1
723456198
2
12 21
1
3216475
0
3
2537614 3761425 5376142
1
31842567
2
12 21
1
132
0
1
25431
1
5143627
0
0
1
12
1
36812754
1
217940400
1
123
1
231
0
1
13425
1
273148596
1
312
2
12 21
1
312
1
632145
1
1456327
1
52178364
1
1
2
24135 35124
1
3421
2
12 21
1
352750555
1
264409659
2
12 21
2
12 21
1
...

result:

ok 133219 numbers

Test #20:

score: 0
Accepted
time: 233ms
memory: 27348kb

input:

67944
9 29
5 4
3 1
7 3
7 5
8 4
7 4
8 1
4 1
1 2
5 3
1 6
9 6
9 4
7 5
6 9
8 1
3 5
7 5
5 6
5 7
5 1
7 9
4 6
3 2
5 8
4 9
8 2
2 8
8 3
5 16
4 3
5 4
1 4
5 3
5 1
1 3
5 1
3 4
5 2
5 1
1 5
2 4
4 2
1 3
3 1
5 1
9 33
6 5
3 8
6 7
8 9
2 4
4 8
4 5
2 3
4 3
7 8
7 9
7 1
6 1
7 9
4 3
6 2
1 3
6 9
4 6
6 9
1 7
4 5
4 2
5 7
6 8...

output:

1
694128357
1
24315
1
938715246
1
563412
1
132
1
329546781
1
43512
2
12 21
1
32145
2
123 231
1
782543169
1
213
1
541326
1
123
1
26573481
1
5741263
1
3526174
1
3756412
1
968740500
1
5461237
1
231
1
257198308
1
3214
1
568024263
1
1
1
4312
1
4723615
2
34125 41253
1
321
1
639814527
2
12 21
1
213
1
42156...

result:

ok 148525 numbers

Test #21:

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

input:

90784
2 2
1 2
1 2
10 9
2 10
5 3
4 1
7 9
6 1
10 5
5 2
10 3
10 5
3 10
2 1
3 2
2 3
2 1
1 2
3 2
3 1
1 2
3 2
2 3
7 4
2 1
3 1
6 3
7 5
10 3
2 6
3 10
2 7
9 4
1 7
2 6
2 8
2 4
5 9
5 4
5 2
2 4
5 4
4 5
1 3
3 4
1 4
3 1
8 25
4 3
2 4
6 4
1 7
7 6
3 6
8 4
2 8
3 6
4 6
6 5
7 8
6 5
8 3
4 7
3 1
6 5
4 2
4 1
4 5
4 8
5 6
6...

output:

1
12
0
1
123
0
0
0
0
0
0
0
1
321
0
0
0
0
0
2
12 21
0
0
2
12 21
1
1
0
0
0
2
12 21
2
12 21
0
2
12 21
0
0
0
0
2
12 21
0
1
1
1
1
0
0
1
1
0
0
2
12 21
1
12
0
0
0
2
12 21
0
0
1
1
0
0
1
312
0
0
2
12 21
0
0
0
0
0
1
1
0
0
1
1
2
12 21
0
0
1
1
0
0
0
1
1
0
2
12 21
2
12 21
0
0
0
2
12 21
0
0
1
1
0
0
0
0
1
321
0
0
...

result:

ok 124129 numbers

Test #22:

score: 0
Accepted
time: 213ms
memory: 27280kb

input:

64718
1 0
7 19
3 7
5 7
5 6
7 5
3 6
1 3
1 4
6 7
4 5
1 6
1 3
6 3
4 3
2 1
4 1
4 7
1 3
3 2
3 6
7 11
5 6
6 2
3 7
7 1
2 5
2 3
6 4
6 4
1 6
6 4
4 3
9 17
3 9
6 1
5 4
4 6
1 2
4 6
7 6
1 6
2 7
4 3
8 3
2 8
7 2
8 2
3 8
1 5
9 3
2 16
2 1
2 1
2 1
1 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
3 7
3 1
2 1
3 2
2 ...

output:

1
1
1
7563214
1
4371625
1
938276154
2
12 21
2
132 213
1
24531
1
391286754
1
21543
1
341972498
1
1
1
1253467
0
2
785392416 853924167
1
42531
1
64135287
0
1
452916738
1
619375428
2
1243 2431
0
1
460072575
2
12 21
0
1
321
1
836752419
1
34152
1
2431
1
23541
2
3412 4123
0
2
12 21
2
12 21
1
2134
1
632541
...

result:

ok 133061 numbers

Test #23:

score: 0
Accepted
time: 224ms
memory: 27556kb

input:

67838
5 15
4 2
1 4
3 4
2 1
2 5
5 1
3 2
2 4
4 1
4 1
2 1
2 3
3 4
1 5
4 1
7 25
6 4
1 2
6 3
5 4
6 7
3 7
3 4
6 3
5 6
2 5
5 1
6 7
6 7
7 3
5 4
6 5
6 2
5 4
5 3
2 1
2 4
4 3
4 1
5 2
4 3
10 32
2 1
7 6
10 7
9 7
5 8
4 10
3 9
5 9
5 6
4 2
9 6
9 8
4 3
5 2
3 7
5 6
3 5
10 1
6 2
9 10
3 5
4 7
9 2
4 1
9 6
10 4
1 8
8 7
5...

output:

1
51423
1
7341256
1
762159987
1
34612578
1
5364721
1
690035420
3
1756234 4175623 7562341
1
971260441
1
312
1
3412
1
493562178
1
1
1
1
1
312456
1
231
1
679905391
6
164532 216453 321645 453216 532164 645321
1
132
1
4231
1
43521
1
1243
1
52341
1
17458236
1
748195263
1
1
2
14735268 68273514
1
903421753
...

result:

ok 148527 numbers

Test #24:

score: 0
Accepted
time: 178ms
memory: 27552kb

input:

91081
10 26
5 8
3 8
7 1
2 4
1 2
10 9
4 1
9 6
1 7
5 3
8 4
7 5
1 3
10 1
8 2
10 8
8 7
2 5
2 4
1 2
10 7
3 4
5 1
2 8
9 2
6 8
10 2
7 9
1 7
5 17
1 5
5 2
4 1
2 3
5 4
2 4
2 4
4 3
1 3
4 1
4 2
3 2
3 4
4 1
1 2
4 1
4 5
1 0
6 12
3 1
6 5
5 4
5 6
3 4
6 1
4 3
2 5
1 6
1 4
3 4
1 4
8 14
5 7
5 7
2 3
3 6
1 2
7 6
7 4
5 7
...

output:

0
0
0
1
1
0
0
1
1
1
1
0
0
0
0
1
1
0
1
1
0
0
0
0
2
12 21
1
21
0
0
0
0
0
1
321
0
0
0
0
1
1
0
0
2
12 21
0
0
0
0
0
2
12 21
0
0
0
0
0
1
1
0
1
1
0
0
0
0
0
0
0
1
3421
0
2
12 21
0
0
0
1
1
0
0
0
0
0
0
2
231 312
0
2
12 21
0
0
0
0
2
12 21
0
1
1
0
0
0
0
2
12 21
2
12 21
0
2
123 321
0
1
1
2
12 21
1
1
0
1
1
0
0
0
...

result:

ok 124817 numbers

Test #25:

score: 0
Accepted
time: 211ms
memory: 27292kb

input:

64614
7 21
1 4
1 5
6 1
6 7
1 6
1 3
6 1
6 3
6 5
5 3
7 2
6 3
4 7
2 5
3 4
7 5
6 7
4 2
1 2
1 7
7 1
10 28
5 9
3 2
9 6
4 1
9 3
5 8
7 6
5 8
7 1
10 9
6 4
5 2
9 6
10 4
6 8
2 7
2 4
5 10
10 7
8 7
3 9
5 6
10 9
10 1
1 8
3 8
2 5
6 9
10 30
7 4
3 1
4 5
7 2
8 4
7 10
4 1
8 3
1 4
2 6
1 2
7 5
6 10
3 2
7 5
3 2
10 7
1 2
...

output:

1
2534716
1
187693232
0
1
825619783
2
152364 523641
1
4231
1
213
1
462351
1
1
1
132
0
0
1
594376821
0
1
650053133
1
326154
1
1362745
1
4123
1
1
1
859732146
1
792814365
1
27534618
1
87265134
1
745628139
1
4123
1
5673241
1
1
1
45231
2
12 21
1
1
1
65713842
1
645803749
1
3657421
1
296458731
2
15423 3215...

result:

ok 132652 numbers

Test #26:

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

input:

67618
3 10
3 2
3 1
3 1
2 3
3 1
3 1
1 2
2 1
3 2
3 1
10 9
3 4
5 9
9 7
2 10
8 5
10 3
7 6
6 1
1 2
10 28
2 4
7 4
4 2
1 8
4 6
4 8
5 2
6 2
3 5
8 2
9 5
6 1
1 4
1 9
7 8
9 8
10 7
7 5
10 8
2 8
4 2
3 5
5 3
5 8
5 8
9 8
5 2
3 10
5 25
4 2
4 3
5 1
4 1
4 2
2 1
5 2
3 1
2 3
3 1
3 4
3 2
1 5
2 5
2 1
3 2
5 1
5 1
2 1
4 5
...

output:

1
123
1
597612978
1
246195351
1
15234
1
2351746
1
1
1
961374852
1
4213
2
12 21
2
2761453 6145327
1
7341256
1
2465317
1
279864531
2
213 312
1
21543
2
12 21
1
25341
2
12 21
1
876954312
1
76541328
2
451263 634512
1
1
1
4726315
1
132
1
380914827
1
51423
1
21
1
4312
1
42615873
1
1672354
1
1
1
1
1
8194723...

result:

ok 147867 numbers

Test #27:

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

input:

91041
4 15
4 2
3 2
1 3
4 3
1 4
4 1
3 4
4 2
1 4
4 2
3 1
1 4
4 3
2 4
2 1
2 4
1 2
1 2
2 1
1 2
2 5
1 2
2 1
2 1
2 1
2 1
8 7
1 7
1 8
1 7
7 6
8 5
5 2
3 7
2 4
1 2
1 2
1 2
2 1
5 11
4 1
1 5
1 5
5 3
5 1
5 2
1 5
3 2
3 2
4 1
1 5
9 6
9 8
9 8
6 3
4 7
9 6
4 8
4 11
3 1
3 1
3 4
3 2
3 1
2 3
4 3
3 1
2 1
4 1
3 2
9 18
6 ...

output:

0
2
12 21
2
12 21
0
2
12 21
0
0
0
0
0
0
0
1
1
2
12 21
0
0
0
0
0
0
0
0
0
0
0
0
1
1423
0
1
1
1
1
0
0
0
0
1
4312
0
0
0
0
0
0
1
312
0
0
1
1
1
3421
0
0
1
21
0
0
1
12
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
2
12 21
0
0
0
0
0
0
0
2
12 21
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1324
1
231
0
0
0
0
1
1
1
21...

result:

ok 124640 numbers

Test #28:

score: 0
Accepted
time: 211ms
memory: 27340kb

input:

64643
10 14
9 10
9 7
8 6
3 8
6 2
4 9
5 4
2 3
10 5
2 7
1 3
7 1
8 4
4 8
3 25
3 2
1 3
3 1
1 2
3 2
1 2
3 2
3 1
3 1
3 2
1 2
3 2
3 2
1 2
1 2
1 2
3 2
3 2
2 1
1 2
3 1
3 2
3 2
1 2
1 2
10 18
1 10
3 4
10 7
3 9
9 1
9 4
2 10
1 5
6 4
4 7
2 6
9 2
4 8
6 3
8 2
7 5
9 6
5 4
8 28
8 5
3 5
4 8
4 6
1 6
5 6
6 5
4 8
3 6
1 7...

output:

0
1
213
1
754826321
1
71658234
2
1574263 5742631
1
643125
1
1
2
12 21
1
4312
1
202378631
1
682075903
1
76821383
0
2
123 321
1
1
2
132 321
1
3142
1
534216
2
12 21
0
1
678426086
2
42538176 64253817
1
4732156
1
46173528
2
345291786 634529178
1
24135
1
13425
1
15287364
1
16435872
1
15723864
1
1
1
346172...

result:

ok 132863 numbers

Test #29:

score: 0
Accepted
time: 229ms
memory: 27276kb

input:

67901
9 16
7 8
8 3
4 5
1 6
9 2
3 9
5 1
7 4
6 7
8 4
8 4
7 1
9 8
6 4
2 7
3 6
3 12
3 2
2 3
2 1
1 2
3 2
3 2
3 2
2 1
3 2
3 1
3 1
3 2
4 8
1 3
4 3
2 4
4 2
3 4
2 1
4 1
2 3
3 3
1 3
3 2
2 1
7 16
5 3
5 1
1 3
6 7
3 6
3 5
4 7
1 4
3 6
7 3
7 2
5 6
2 6
5 3
1 6
4 7
4 3
1 2
3 1
4 3
3 10
3 1
1 2
2 3
3 1
3 1
3 1
3 2
2 ...

output:

1
451678392
1
123
1
1342
3
132 213 321
1
2673514
1
4312
1
123
1
31452
1
12354
1
36815436
2
12 21
2
12 21
1
753004361
1
1
1
83214765
1
5264731
1
364152
1
62457813
1
25143
1
1
1
27184563
1
4132
1
3124
1
634521
1
132
1
649783152
2
12 21
1
321
1
75438126
1
12345
2
12 21
1
452697183
1
123
1
123475869
1
4...

result:

ok 148469 numbers

Test #30:

score: 0
Accepted
time: 197ms
memory: 27540kb

input:

90746
9 9
3 6
6 3
1 4
9 6
7 6
6 7
4 1
5 4
3 9
6 24
5 4
1 4
3 5
6 4
2 3
4 1
3 2
5 3
2 4
2 6
2 6
6 3
4 3
3 5
1 3
6 3
3 2
6 3
2 6
6 2
1 5
6 2
4 5
5 3
4 12
4 2
3 1
2 4
1 4
4 2
2 3
2 3
3 1
3 1
4 1
3 1
3 4
7 3
3 6
2 7
6 7
8 14
3 2
2 6
4 3
5 3
3 4
3 6
2 7
1 7
1 2
3 2
4 6
3 5
7 8
3 8
6 17
4 3
5 2
5 3
1 2
1 ...

output:

0
0
1
1423
0
0
1
361245
0
1
4231
2
12 21
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
2
132 321
0
0
1
1
1
312
1
1
0
0
0
1
1
1
132
1
12
0
0
1
32514
2
12 21
0
0
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
0
0
2
12 21
0
0
2
12 21
0
0
0
1
123
0
2
213 321
0
0
0
1
12
0
0
0
0
0
0
2
12 21
0
0
0
0
0
0
0
1
312
0
1...

result:

ok 124350 numbers

Test #31:

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

input:

64449
9 18
6 2
8 5
6 5
3 6
8 9
3 6
5 7
9 6
4 5
8 7
8 5
1 3
2 1
3 5
2 6
3 1
7 8
6 9
9 13
6 9
5 7
8 1
6 8
1 3
5 8
7 5
9 2
7 1
3 9
2 6
8 5
4 1
6 13
4 5
1 4
4 2
6 2
6 1
6 1
2 4
6 1
2 6
6 3
5 1
6 5
3 6
6 23
1 6
2 4
2 5
1 6
5 4
3 4
5 4
6 2
1 2
5 4
2 4
2 3
5 6
2 1
2 3
4 5
1 2
6 5
4 3
2 6
1 4
6 3
2 6
3 8
2 ...

output:

1
457896213
1
413926857
1
514263
1
345621
2
123 321
1
23145
0
1
5134672
1
1
1
1
1
2341
1
1
1
1
1
562413
1
1
1
51324
1
251463
1
1
1
1
1
5432167
2
12 21
1
469258371
1
354621
1
52431
1
41352
1
26178435
1
53241
1
27613485
2
12 21
1
2143
1
562341
1
4312
1
1
0
1
4213
0
3
47621358 62135847 76213584
0
1
651...

result:

ok 132077 numbers

Test #32:

score: 0
Accepted
time: 4ms
memory: 27252kb

input:

1
1 0

output:

1
1

result:

ok 2 number(s): "1 1"

Test #33:

score: 0
Accepted
time: 260ms
memory: 27580kb

input:

6940
26 139
16 2
17 12
22 10
19 18
26 15
1 25
11 4
16 21
20 2
2 16
6 2
14 22
19 16
26 21
14 9
6 19
16 8
24 8
2 11
20 5
7 24
5 7
13 25
14 23
19 1
14 9
8 23
9 1
6 14
12 23
20 10
3 14
18 26
15 1
7 5
26 2
13 11
22 11
17 25
6 23
5 10
12 8
15 12
23 10
9 14
12 23
10 22
21 8
26 5
8 13
15 1
26 22
3 10
21 17
...

output:

1
803039395
1
679703927
1
11572817
1
321
1
263139408
1
708258723
1
502336119
1
971692203
1
63736713
1
761840921
1
749807540
1
562280948
1
386746264
1
611363905
1
1
1
18500621
1
555755517
1
11166572
1
914077790
1
247021350
1
642331762
1
436089852
1
9147086
1
68132479
1
632921663
1
585825604
1
8990907...

result:

ok 14007 numbers

Test #34:

score: 0
Accepted
time: 254ms
memory: 27424kb

input:

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

output:

1
388507692
0
0
0
1
156020537
1
284536366
0
1
727118253
1
388820796
1
736200787
1
161284473
1
313096436
1
542983761
1
962253439
1
168218591
1
75679272
1
890016350
0
1
214216675
1
927708107
1
481359317
0
0
1
362777158
1
371762968
1
947135918
1
632415
1
893571038
1
463536214
1
228054368
0
1
890474339
...

result:

ok 12537 numbers

Test #35:

score: 0
Accepted
time: 273ms
memory: 27360kb

input:

7003
88 182
13 88
47 35
19 52
67 10
11 40
64 65
74 42
85 68
77 83
67 35
80 14
7 34
75 62
23 71
15 52
80 81
81 77
41 58
44 76
24 88
32 48
70 33
79 59
28 2
5 31
41 18
22 17
71 64
60 87
48 39
14 76
25 45
39 43
49 15
61 55
56 64
50 2
53 81
1 28
49 45
22 31
41 49
30 36
86 6
7 28
6 53
8 38
45 28
87 78
9 5...

output:

1
451227539
1
131855669
1
41532
1
713022243
1
92175039
1
312
1
256902889
1
413670047
1
4123
1
657690484
1
934115646
1
764219351
1
331455716
1
325882276
1
607023112
1
912156566
1
630092241
1
512736498
1
501177006
1
957284644
1
712963882
1
16852593
1
158131925
1
1546327
1
445767822
1
733731896
1
88487...

result:

ok 14168 numbers

Test #36:

score: 0
Accepted
time: 238ms
memory: 27312kb

input:

6938
45 47
13 38
41 34
39 44
6 8
23 2
5 18
17 36
29 31
15 28
14 12
31 23
21 7
38 25
38 29
27 3
26 33
32 2
35 30
30 16
11 26
44 45
1 22
24 16
42 10
36 5
34 13
9 37
25 21
3 25
43 11
40 27
2 41
20 15
24 43
18 32
12 1
37 14
4 42
8 40
45 19
22 35
7 24
19 6
33 17
28 9
16 39
23 4
77 235
28 68
66 52
52 70
2...

output:

1
497890422
1
413170815
1
119378997
1
1432
1
222636575
2
12 21
0
1
587631343
0
1
6573241
0
1
384690319
1
976808357
0
1
642475800
1
338951218
0
1
190599764
1
499299789
1
203371564
1
626616407
1
89573008
0
0
1
596729601
1
269581249
1
362486781
1
352259823
1
823046738
1
182174505
1
777477772
0
1
330856...

result:

ok 12702 numbers

Test #37:

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

input:

6948
88 187
86 34
80 13
41 83
23 46
66 38
45 11
26 41
86 42
66 20
13 40
30 78
72 47
58 71
60 77
39 34
3 9
8 60
14 35
18 62
41 77
48 74
34 74
20 16
55 67
57 24
20 9
81 19
52 36
23 31
33 45
43 30
42 33
23 56
64 66
10 57
1 80
61 14
64 4
57 3
38 16
15 49
37 60
87 70
74 65
68 48
67 13
27 58
76 37
48 24
6...

output:

1
401212610
1
356165523
1
732947595
1
199079125
1
447152043
1
162522825
1
13665319
1
442051664
1
184752936
1
729047645
1
34910122
1
627216143
1
369949441
1
795876247
1
1
1
140895523
1
316737166
1
654902144
1
971765679
1
452138860
1
586826781
1
399662798
1
7423615
1
76246669
1
896004239
1
695619045
1...

result:

ok 14038 numbers

Test #38:

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

input:

6890
93 234
51 12
19 32
26 45
44 4
47 20
22 10
66 58
76 48
10 40
45 40
59 52
76 53
1 5
84 9
33 13
21 68
5 14
35 5
14 6
19 93
45 52
68 78
27 43
5 85
6 46
4 29
9 58
50 42
50 78
19 25
22 48
8 23
31 45
73 81
60 88
31 2
23 22
69 26
45 38
73 34
92 52
61 47
34 84
7 1
84 2
14 59
39 48
35 37
35 48
49 16
8 55...

output:

1
485236895
1
974600791
1
125042643
1
865704398
1
978965606
0
1
158603509
1
92035595
1
1752436
1
622147275
0
1
212851437
1
170135681
1
47835162
0
1
615839673
0
1
824551671
1
1635274
1
776475342
1
429537995
1
276306888
1
193324560
0
1
155880424
1
705887130
1
505040505
1
576955357
1
304300586
1
631542...

result:

ok 12667 numbers

Test #39:

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

input:

6900
67 121
62 29
32 34
55 22
50 32
13 31
47 37
11 45
51 30
9 46
2 6
64 47
46 33
37 7
18 42
8 3
54 56
63 64
10 27
29 4
23 12
45 17
22 47
19 17
62 48
42 66
28 2
10 13
31 45
12 37
59 62
58 33
27 35
67 39
35 36
24 59
27 1
30 25
21 38
44 23
31 36
25 52
12 34
35 61
39 26
23 37
17 41
61 24
45 41
40 11
44 ...

output:

1
496320022
1
977403196
1
169652565
1
947340828
1
892495025
1
472785294
1
613004675
1
429877516
1
582223548
1
72228082
1
80301878
1
722218452
1
729370452
1
752194532
1
921478357
1
710350409
1
76451778
1
430312054
1
852975341
1
1
1
503156510
1
200197215
1
978521959
1
288344877
1
64733906
1
422116210
...

result:

ok 13920 numbers

Test #40:

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

input:

6862
76 257
45 59
11 69
31 23
66 64
55 16
64 27
39 69
31 9
35 76
62 73
31 53
47 51
5 53
28 76
4 30
31 55
30 18
43 73
1 69
73 15
2 34
49 33
62 7
50 3
30 21
2 4
15 60
21 40
35 18
1 20
24 17
59 13
34 9
14 66
18 32
27 13
22 47
28 41
11 18
53 64
27 63
43 40
12 26
6 68
45 5
51 40
38 40
9 55
75 66
17 44
1 ...

output:

1
22943897
1
341509455
0
1
972454968
1
311612880
1
910867812
1
1
0
1
454252677
1
566468766
1
516205411
1
337875927
1
307260979
0
1
739019713
0
1
232083397
1
20067691
1
800363339
1
139042106
1
801224705
1
524136
0
1
791674534
1
231
0
0
1
1423
1
341303469
1
965303101
1
809306997
1
305246567
0
1
403175...

result:

ok 12516 numbers

Test #41:

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

input:

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

output:

1
169353088
1
333805780
2
12 21
1
545566944
1
367828843
1
313683340
1
243805889
1
750201723
1
274127649
1
665996923
1
494913767
1
803297657
1
862046582
1
174330274
1
260214252
1
313873857
1
228124726
1
231
1
149783592
1
146265513
1
565902017
1
910328595
1
617238033
1
807723011
1
560437580
1
34298497...

result:

ok 14026 numbers

Test #42:

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

input:

6924
96 134
58 79
16 66
47 78
23 70
15 93
55 94
11 8
14 22
76 30
80 84
95 35
17 48
77 14
43 89
30 18
37 12
37 73
51 63
67 39
31 91
57 29
55 2
85 4
43 24
34 78
71 64
71 88
88 44
50 40
38 72
11 44
45 95
39 45
49 34
45 83
89 68
90 52
1 67
68 20
78 15
44 34
20 95
9 2
96 80
70 19
92 12
48 9
86 50
43 60
4...

output:

1
603332242
1
595767421
1
862472115
1
364292733
0
1
708695053
1
328891809
0
1
813337090
1
123
1
659995401
1
209623436
1
840756701
0
0
1
914704904
0
1
232576593
1
925468756
1
434706327
0
1
513865543
1
463606787
1
112319403
1
565819967
1
926357629
0
1
780795368
1
211765277
1
5342716
1
398366068
0
0
1
...

result:

ok 12679 numbers

Test #43:

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

input:

662
293 1513
137 170
221 230
24 5
270 96
241 139
182 35
246 50
218 19
94 9
110 251
150 249
282 288
103 64
211 51
136 255
7 102
291 95
117 189
35 207
137 266
267 38
281 80
203 285
179 204
269 225
141 192
159 108
205 66
160 277
187 218
166 206
217 206
280 45
50 277
105 272
66 167
263 191
205 174
272 1...

output:

1
181059484
1
973989468
1
190554490
1
3125476
1
90434053
1
546449599
1
766763267
1
898279070
1
91398660
1
96367749
1
490557476
1
805710236
1
969586974
1
18085359
1
15327684
1
389893138
1
349291242
1
781265581
1
962053930
1
538995493
1
523960706
1
532998841
1
267097996
1
653515262
1
371678830
1
28012...

result:

ok 1324 numbers

Test #44:

score: 0
Accepted
time: 321ms
memory: 28244kb

input:

664
616 636
394 310
540 13
146 292
580 570
119 77
588 408
235 427
498 513
140 41
599 346
24 504
34 272
549 62
578 576
277 226
493 163
301 517
309 404
244 447
154 512
381 436
206 477
606 460
158 554
457 86
431 413
561 28
406 212
61 497
465 78
53 241
152 420
386 433
361 47
587 540
99 231
84 357
577 36...

output:

1
607899049
1
552086229
0
1
159458666
1
155416062
1
122655178
0
1
936737201
1
25710828
1
889491795
1
111329478
1
617193217
1
303021676
1
437878428
1
583734713
1
567060643
1
570928855
1
395631489
1
830200402
1
714998229
1
871271554
1
219127143
1
176778278
1
393084108
1
999414712
1
839921
1
179120645
...

result:

ok 1210 numbers

Test #45:

score: 0
Accepted
time: 323ms
memory: 27964kb

input:

661
279 1780
8 117
124 154
96 268
246 172
148 216
17 261
277 254
217 72
186 118
126 108
21 274
16 137
47 195
199 29
249 28
69 108
239 200
55 117
209 89
7 212
194 166
91 176
164 143
210 137
212 103
257 64
39 183
215 198
65 222
112 252
39 132
41 235
41 234
191 192
101 145
92 45
204 193
189 133
165 259...

output:

1
186441506
1
736726884
1
642987525
1
990299401
1
157634630
1
267527648
1
405759120
1
483243140
1
278710947
1
486468248
1
643438893
1
351654068
1
356088632
1
987056462
1
634794448
1
313747891
1
125413567
1
280179346
1
883236183
1
262837096
1
286095133
1
690442814
1
402073952
1
426964558
1
316196687
...

result:

ok 1323 numbers

Test #46:

score: 0
Accepted
time: 318ms
memory: 27980kb

input:

672
915 1561
833 607
261 462
646 35
869 520
356 197
567 642
546 826
181 497
512 177
370 696
598 112
204 678
295 667
374 461
813 745
491 753
431 42
883 820
701 546
459 487
186 164
266 108
514 329
549 647
302 232
514 427
546 111
535 436
779 455
453 249
521 615
242 125
597 104
644 169
365 716
379 302
8...

output:

1
478466136
1
556229992
1
858646559
1
27497148
1
116021313
1
364502512
1
769753897
1
315256505
1
794988912
1
308148972
1
283043483
0
1
161744604
1
526350336
1
984519307
1
967395425
1
819709662
1
303325881
1
446472793
1
101479984
1
907508921
1
50327843
1
795816947
1
127365677
1
35748194
1
329136198
1...

result:

ok 1211 numbers

Test #47:

score: 0
Accepted
time: 329ms
memory: 27960kb

input:

667
976 1890
684 253
83 540
547 380
69 50
289 628
290 395
465 933
116 964
968 638
194 445
555 624
602 491
122 89
170 613
713 777
389 291
330 70
302 16
849 570
829 716
364 613
698 11
449 714
620 912
22 69
315 155
689 426
527 318
931 814
559 312
956 58
194 606
558 564
819 258
676 909
65 301
223 865
30...

output:

1
147885323
1
763146998
1
485843444
1
407002767
1
155481760
1
187826259
1
746778590
1
810668677
1
630150503
1
530154162
1
247805558
1
929882930
1
394262719
1
758751045
1
974805557
1
820754412
1
313897223
1
335536948
1
586166508
1
595867798
1
839898354
1
873596757
1
235231725
1
637225466
1
624729193
...

result:

ok 1334 numbers

Test #48:

score: 0
Accepted
time: 311ms
memory: 28048kb

input:

664
983 2507
50 866
154 677
498 337
267 889
950 702
484 174
83 550
329 761
458 435
83 733
750 237
361 456
248 335
817 352
227 317
179 979
678 570
466 603
971 745
795 424
261 173
404 773
6 763
657 331
162 429
547 54
165 905
880 9
586 761
272 459
906 881
881 703
931 452
474 235
464 520
170 140
983 527...

output:

1
306503252
1
881308607
1
810455706
1
750634051
1
299467002
1
437718528
1
396252044
1
670578492
1
537094618
1
407739296
0
1
937661981
1
497772135
1
956582507
1
633776951
1
716277341
0
1
230411693
0
1
290740318
0
0
1
645237641
1
8870827
1
543086052
0
1
128738153
1
177361950
1
321
1
774564208
1
628769...

result:

ok 1199 numbers

Test #49:

score: 0
Accepted
time: 327ms
memory: 28040kb

input:

658
605 1502
256 350
102 453
405 528
327 36
279 183
301 411
151 383
140 166
187 372
102 40
366 477
428 598
257 142
339 75
483 551
596 221
92 468
373 280
3 189
325 309
310 330
52 371
58 107
109 27
470 51
109 355
521 461
393 294
506 379
135 293
475 195
363 427
213 449
265 278
314 532
604 282
522 321
5...

output:

1
694373305
1
704401004
1
64672955
1
628382945
1
654219082
1
874680069
1
692540540
1
590026642
1
463510138
1
950237338
1
869667412
1
504960425
1
389539797
1
950198961
1
927069292
1
186392365
1
534221627
1
600181810
1
698603830
1
602941752
1
10734852
1
568851613
1
448318872
1
618437820
1
475353843
1
...

result:

ok 1316 numbers

Test #50:

score: 0
Accepted
time: 314ms
memory: 28220kb

input:

685
318 874
318 83
67 243
7 51
294 51
212 304
143 160
187 91
117 205
32 100
291 172
298 166
78 295
242 273
284 166
121 26
72 281
263 299
10 17
97 3
105 308
79 76
8 153
74 83
257 281
204 196
167 115
234 216
242 230
28 6
188 90
96 193
185 77
147 102
78 165
122 217
270 136
135 190
70 246
260 9
257 95
5...

output:

1
149568141
1
108311773
0
0
1
222303294
1
126483282
1
916803136
1
6725143
1
61987326
1
108370698
1
235475114
1
989798625
1
379914449
1
594546546
1
834382431
1
436802570
0
1
655406207
1
73379656
1
973100024
0
0
1
597482727
1
656135001
1
563256688
1
123
0
1
299799483
1
430519868
1
574280106
1
49136980...

result:

ok 1221 numbers

Test #51:

score: 0
Accepted
time: 330ms
memory: 28004kb

input:

664
996 1573
235 930
876 289
954 905
551 38
736 191
287 890
231 120
915 934
432 846
762 42
937 196
391 333
12 618
681 351
885 471
188 233
470 614
166 112
500 843
525 361
468 420
303 872
39 799
665 457
721 456
883 770
139 905
478 443
803 248
487 655
697 839
582 39
145 913
444 863
827 180
344 519
595 ...

output:

1
182640664
1
330559594
1
330781557
1
59122909
1
485840724
1
704566951
1
905490204
1
503796328
1
196101531
1
293895476
1
697154237
1
711381994
1
726351918
1
847005659
1
679404671
1
536629987
1
761550149
1
479486460
1
977776212
1
84490640
1
972862595
1
732190660
1
278996861
1
159975991
1
243440177
1
...

result:

ok 1330 numbers

Test #52:

score: 0
Accepted
time: 311ms
memory: 27972kb

input:

663
565 2423
250 205
449 563
125 372
272 410
188 228
167 160
237 175
242 262
278 480
252 59
221 360
433 175
319 82
84 28
225 530
534 457
54 526
464 314
242 163
530 122
495 13
535 291
326 502
435 291
530 285
420 307
234 367
100 189
531 219
273 492
281 349
192 11
419 526
532 342
504 358
260 281
410 54...

output:

0
1
496937675
0
0
1
410986631
1
397058154
1
427157446
1
137465239
1
41161052
1
674085312
1
849055944
1
432925350
1
511700440
1
458042793
1
994875144
1
365466127
1
913347510
1
509686315
1
162013570
0
1
969896047
0
1
686019701
1
596574458
1
658364933
1
4586670
0
1
536521052
1
739171231
1
8280353
1
900...

result:

ok 1191 numbers

Test #53:

score: 0
Accepted
time: 474ms
memory: 32980kb

input:

63
2677 2754
1197 2566
2610 824
1414 843
2217 1173
2564 432
9 926
2435 2468
2567 874
733 1455
2334 1104
2342 1779
125 2668
1265 2231
293 761
1792 1588
1208 1773
1847 331
1984 339
2403 1361
532 2658
1257 2604
1545 877
700 1237
1969 1952
2620 790
2265 186
2259 2475
835 1552
517 756
1595 470
448 702
13...

output:

1
235973941
1
553576965
1
557412870
1
972365467
1
702386867
1
525359996
1
223169878
1
935244540
1
874031747
1
365225770
1
91857388
1
563501532
1
396685995
1
241370007
1
666835886
1
385963076
1
411444134
1
342630155
1
517456469
1
195285068
1
749664278
1
491045488
1
639795059
1
919304487
1
51782485
1
...

result:

ok 126 numbers

Test #54:

score: 0
Accepted
time: 468ms
memory: 33472kb

input:

62
7913 24223
4139 7174
4829 4044
7176 2350
6023 2473
1792 4540
1065 700
738 4701
597 1566
3427 6024
4752 1251
4397 6284
3220 3090
5397 5532
2179 4902
5692 2351
3661 1749
4304 3382
836 2615
6611 3530
5859 1496
2542 7907
1770 833
7469 122
2930 7699
1001 539
4329 1292
3662 6782
5825 91
4566 196
6758 3...

output:

1
871975606
1
724919956
1
933967825
1
330851524
0
1
64713963
1
774317332
1
752794235
0
0
1
509952099
1
834587901
1
889738719
1
634465788
1
742309555
1
950315102
1
64482131
1
581865268
1
71228343
1
186886606
1
220385272
0
1
404897201
1
491101085
1
799414160
0
0
1
40063471
0
1
527156756
1
573411959
1
...

result:

ok 108 numbers

Test #55:

score: 0
Accepted
time: 468ms
memory: 32692kb

input:

66
4613 23099
1045 4489
473 1604
2959 361
120 773
323 2719
3242 2235
3034 4538
841 1717
2590 2585
4056 3784
2412 275
1718 3509
749 390
2786 1287
3594 4517
4352 4444
813 1598
2011 1901
2126 4258
2864 342
2346 3425
205 3934
3026 4112
84 3453
4303 3275
4245 2205
1057 552
4013 800
2816 1922
383 3582
156...

output:

1
135830770
1
198550031
1
913030677
1
630459844
1
52895823
1
517546085
1
707218629
1
296608390
1
632938668
1
77055165
1
221146140
1
544090446
1
788986050
1
963168961
1
988155906
1
401091200
1
539600858
1
804116936
1
38872988
1
339011012
1
993785769
1
305195893
1
953500187
1
752278726
1
560637853
1
9...

result:

ok 132 numbers

Test #56:

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

input:

69
9250 12888
7772 8562
1855 5823
28 289
3677 2708
7490 5941
5559 9017
1427 7612
9242 1295
8943 2789
3529 3917
2850 577
1535 8151
6027 9020
3118 5958
2817 1647
1463 2167
5649 4060
4242 8018
4223 5525
7172 965
2652 1921
2415 6972
2195 8936
1730 2393
5279 2997
6006 1685
4460 5503
3093 8608
1199 8888
2...

output:

1
530757421
1
624641123
1
768184123
1
51939164
1
264026386
1
360697261
1
788831548
0
1
977281226
1
502917641
1
474311829
1
784429914
1
654463509
1
97885749
1
336252525
0
0
1
544128912
1
213915845
0
1
12490729
0
1
138763417
1
413477176
1
58353605
1
336541830
1
131197300
0
1
364248266
1
274111791
1
40...

result:

ok 124 numbers

Test #57:

score: 0
Accepted
time: 465ms
memory: 32836kb

input:

71
8051 8780
1719 3289
3159 5107
1521 3624
3284 1065
1999 6606
5557 220
2337 5842
1564 2105
7093 4661
7021 3248
3542 2861
46 3837
4757 4353
5619 5385
5101 2987
2810 6663
1782 7014
2074 4624
2851 2041
4857 779
7078 4795
3317 4469
7389 4075
7516 3937
6369 959
5400 6572
1328 5247
6138 3273
5290 1669
16...

output:

1
634684453
1
406765255
1
628989759
1
294014984
1
938764507
1
386577589
1
715681614
1
172295904
1
817546159
1
868306845
1
685377526
1
451768225
1
729714951
1
868674141
1
890078132
1
827179632
1
457116423
1
931859929
1
601579110
1
166376242
1
206944899
1
118336619
1
66119523
1
508084828
1
769221480
1...

result:

ok 142 numbers

Test #58:

score: 0
Accepted
time: 427ms
memory: 32624kb

input:

70
348 8993
198 279
224 283
326 299
66 308
221 174
7 14
204 176
118 195
142 156
1 48
196 13
135 160
107 160
122 80
80 329
343 250
241 309
107 97
2 63
12 113
128 99
228 334
288 235
155 312
312 30
211 247
9 14
117 43
337 156
199 41
66 10
69 132
314 310
279 229
98 167
20 109
45 291
223 333
345 109
90 7...

output:

1
253698303
1
408473513
1
412429805
0
0
1
445960951
1
10459489
0
1
1901863
1
305696103
0
1
400940510
1
996536447
1
179949735
1
910913051
1
246593605
1
857908408
1
732969471
1
833745919
1
680205097
1
370782775
1
696262714
0
1
974827852
1
273029853
1
37076770
0
0
0
1
80144808
1
816206987
0
1
902607876...

result:

ok 124 numbers

Test #59:

score: 0
Accepted
time: 462ms
memory: 32732kb

input:

71
981 6750
808 432
452 447
330 384
326 761
371 235
711 149
275 640
421 716
841 637
513 325
914 144
946 792
31 131
295 140
244 612
721 26
57 487
146 733
262 782
208 136
808 806
911 350
253 233
674 202
251 837
753 346
912 308
195 779
485 200
69 305
977 819
252 353
283 14
799 618
495 896
506 717
44 15...

output:

1
637999634
1
471368864
1
109622535
1
249560453
1
224258733
1
548968902
1
174554935
1
283733495
1
286114865
1
992489502
1
343964575
1
708708995
1
357310420
1
154591146
1
239574974
1
557155512
1
374603048
1
264079287
1
995674320
1
21518983
1
81235123
1
765570446
1
469782730
1
959378771
1
174494466
1
...

result:

ok 142 numbers

Test #60:

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

input:

67
3549 14773
3145 408
936 1643
1782 3333
2606 244
1470 1529
2940 1764
2586 466
428 875
3351 2117
398 498
3431 3441
493 3215
217 633
3115 2530
1565 1379
2652 1043
1073 1440
3451 2327
324 2984
218 3342
3485 1303
3179 88
874 860
2213 1572
804 122
3167 2307
964 1812
1296 3410
2898 2649
1248 962
1045 40...

output:

1
949828419
1
625190053
0
1
792739050
1
169057093
0
0
1
823153949
1
40191129
1
525117389
1
191280312
1
221798665
1
941200741
1
240269737
1
778471162
0
0
0
0
1
577041976
1
35639021
1
436461239
1
363900320
1
349959243
1
167334415
1
739385810
1
538878695
1
805366097
1
233134287
1
35638174
1
956142225
1...

result:

ok 120 numbers

Test #61:

score: 0
Accepted
time: 481ms
memory: 32240kb

input:

63
5617 20424
5001 4990
4802 1836
924 3405
1426 1439
1263 3896
4066 1020
5166 4315
401 89
1548 1158
5065 2656
3831 610
3346 4785
952 2457
1072 2988
5319 1314
2313 4426
3377 5173
226 1888
575 1732
5466 3443
4987 1215
5177 5073
4644 2952
2162 3815
4862 4263
4716 3313
954 5343
2468 4031
4604 738
1182 1...

output:

1
607140508
1
230815116
1
494635283
1
631597170
1
267986791
1
257525332
1
156870541
1
148636670
1
677420110
1
87693454
1
492105038
1
268515856
1
84234960
1
47482977
1
523329407
1
142773743
1
378300993
1
668822931
1
80520187
1
640101499
1
730628758
1
477488296
1
882877805
1
359039171
1
342375956
1
78...

result:

ok 126 numbers

Test #62:

score: 0
Accepted
time: 476ms
memory: 32708kb

input:

73
7423 19443
4484 5521
6497 2155
2118 3951
5892 2389
1500 1275
1908 2630
3419 5212
367 3482
3470 6824
1046 2108
543 5742
2924 3940
6489 3653
2920 6115
658 4036
748 3039
1842 2432
5237 1330
4638 4405
4597 2041
2660 764
20 601
6752 6394
690 3525
3230 6100
6713 2889
6094 3762
1188 7245
1740 1898
6132 ...

output:

1
91127391
1
47588902
1
386320714
1
351034561
1
362937023
1
831964107
1
851291829
1
77696681
1
98910905
0
0
1
169879280
1
308171317
1
397235260
1
292963932
1
98543600
1
569327608
1
392804279
1
858903137
1
666337899
1
899821481
1
565144169
1
309169815
1
299838172
0
1
435351820
1
718060176
1
527405461...

result:

ok 138 numbers

Test #63:

score: 0
Accepted
time: 941ms
memory: 64044kb

input:

6
82541 233545
32809 47652
29466 50404
28655 6662
73745 67621
55118 18402
35296 31854
52702 72985
36571 71863
31511 15493
56903 27007
62753 43167
10773 27940
77158 47857
30942 33449
79630 35998
76306 28312
70440 45671
82159 77052
8576 9094
11691 55283
33212 15336
39542 14946
51209 9522
41754 57924
2...

output:

1
685294145
1
353166867
1
661533084
1
632860729
1
201527735
1
429445684

result:

ok 12 numbers

Test #64:

score: 0
Accepted
time: 960ms
memory: 68668kb

input:

5
42750 234189
13449 42171
40060 5366
37280 2068
17696 7802
27881 32280
38383 23422
39032 21802
26364 29707
27985 39376
39908 6958
13389 20655
16176 35267
37196 3809
37668 25211
1240 42295
32085 9048
9379 35072
3103 25910
35179 10576
5110 261
25119 10875
29564 21752
28927 31813
32385 33146
39237 359...

output:

1
993982375
1
759680841
1
401960171
1
136505676
0

result:

ok 9 numbers

Test #65:

score: 0
Accepted
time: 916ms
memory: 60532kb

input:

5
54697 245912
6297 35686
18015 23972
1349 19943
46787 16325
24158 25400
5314 13848
37671 1599
24324 10574
48526 16226
51296 27990
19433 16806
38836 46655
18410 3208
52711 20567
29293 53723
2156 38966
48907 49172
49518 53299
19157 22048
19434 29948
45996 16964
21831 37608
18366 631
7535 39927
37205 ...

output:

1
339651626
1
176676996
1
108796883
1
838031810
1
24035333

result:

ok 10 numbers

Test #66:

score: 0
Accepted
time: 967ms
memory: 67388kb

input:

6
81188 247285
24223 13981
61393 77972
26145 13356
75512 45021
13290 70947
8961 76805
56810 21517
59507 53065
60269 22879
43412 18814
34582 75287
40356 34404
17747 12037
32659 20086
71655 22136
44076 14365
28550 77600
9514 40601
23141 44527
44593 55282
35886 67360
26031 7480
81117 15087
28824 57198
...

output:

1
468348822
1
658392545
1
90199838
1
857836949
1
467869629
1
124310818

result:

ok 12 numbers

Test #67:

score: 0
Accepted
time: 745ms
memory: 69200kb

input:

6
10748 166144
9171 10647
9052 4177
10273 4076
79 5001
9667 9992
2645 4787
779 6462
1114 9425
6564 1230
7102 9316
1094 5789
7061 8993
4806 5872
9597 5005
5498 764
545 7832
7568 7248
7505 6339
9711 5923
5630 7280
4600 10711
3263 2898
2518 3020
3261 2862
111 5912
9416 1784
4545 3618
1568 8781
5739 238...

output:

1
950268118
1
805894697
1
225427875
1
287914795
1
414761269
1
730361185

result:

ok 12 numbers

Test #68:

score: 0
Accepted
time: 892ms
memory: 67396kb

input:

7
25237 204105
4759 7957
22288 6078
14983 429
1183 13816
11405 1971
4427 6425
10647 10280
3934 10049
19013 10425
12309 714
7407 16610
23605 13528
11517 12391
16706 19626
10587 23997
20981 5141
21405 12965
23140 11980
13811 15921
24534 10891
8864 6373
9011 12668
22756 6777
19841 8970
9573 6121
24762 ...

output:

0
1
723936464
1
224916881
1
890969037
0
1
843506451
0

result:

ok 11 numbers

Test #69:

score: 0
Accepted
time: 1014ms
memory: 66564kb

input:

6
29722 179691
10560 23014
3268 24924
7062 17622
16767 14078
26680 3665
8939 20351
6384 3348
12878 8384
13173 802
11278 7237
607 25088
142 7103
360 10581
14165 27063
26959 25076
16193 12401
5725 11967
26459 25952
3757 12416
23485 12308
18255 9516
16233 10123
1594 23026
1511 29391
29027 5586
1876 170...

output:

1
839074727
1
771592073
1
13291894
1
242989399
1
481935239
1
193440699

result:

ok 12 numbers

Test #70:

score: 0
Accepted
time: 891ms
memory: 64932kb

input:

6
65629 131112
7497 26069
31111 8284
7725 49271
7273 49115
38312 46106
16996 33129
38593 20955
15089 8013
60062 62241
35437 1557
384 36076
41552 11000
64072 28427
10672 30243
47618 43471
52523 63176
4757 48672
45939 22769
59697 42445
63082 16556
55678 9373
43999 47849
38409 1736
13935 58460
20175 21...

output:

1
840702333
1
235187106
0
0
1
704791721
1
985561060

result:

ok 10 numbers

Test #71:

score: 0
Accepted
time: 932ms
memory: 62848kb

input:

8
39217 119763
13317 26557
35563 9340
13032 23478
23449 27355
13300 15314
5640 25826
15319 31324
298 30514
26521 38673
13086 30663
11376 10144
11763 7339
14314 37439
14483 27033
17155 8302
16455 16690
28622 38328
24754 25986
36236 18590
30253 1244
26778 10806
25301 33741
15586 30965
9432 20576
19152...

output:

1
96205121
1
443049783
1
97553905
1
7737858
1
659762246
1
96248897
1
307765761
1
869779740

result:

ok 16 numbers

Test #72:

score: 0
Accepted
time: 833ms
memory: 67300kb

input:

5
73635 271002
31695 70887
1098 51335
50208 6121
55865 32448
15186 46961
58200 56326
15261 64779
64177 41719
47691 33512
56776 61953
60141 73534
57095 62040
9701 47922
56327 12979
42527 28081
43835 44327
27474 38189
45826 17524
18547 21582
14607 57056
5395 24805
61837 46305
7580 40687
32320 29223
27...

output:

1
632285348
1
986861373
1
944412753
1
967702687
1
505563595

result:

ok 10 numbers

Test #73:

score: 0
Accepted
time: 305ms
memory: 27676kb

input:

4923
84 170
8 47
33 50
76 20
79 44
12 13
58 38
80 58
39 66
58 60
19 67
64 68
72 68
51 74
52 24
79 44
39 15
12 49
26 81
48 57
70 10
65 37
10 59
58 75
48 27
52 17
35 14
11 35
40 9
23 63
75 5
14 35
73 33
30 37
44 79
75 80
4 36
76 32
67 38
32 63
72 64
76 63
11 41
58 5
28 61
79 10
51 77
75 5
69 72
40 5
2...

output:

17
726689173 125761870 183073188 410450460 760780655 951194036 974105123 691204368 87886393 94367742 516426988 237459099 420868046 751012469 958411536 256472958 814536518
24
748817382 949093425 299866428 413562856 666294885 494972575 314295752 525600118 973336312 924693029 478109316 877427007 959328...

result:

ok 167193 numbers

Test #74:

score: 0
Accepted
time: 293ms
memory: 27532kb

input:

4243
71 257
56 28
39 58
15 69
66 24
23 8
29 48
5 58
48 70
9 65
67 71
47 67
56 2
17 20
64 62
51 1
7 17
49 37
64 51
6 40
16 66
70 25
47 12
23 26
48 21
53 26
12 1
13 35
47 57
68 8
30 5
58 39
52 43
27 44
41 14
16 43
69 13
32 4
63 65
63 40
29 25
61 53
2 57
9 44
70 16
2 45
15 20
29 20
27 18
59 41
42 8
20 ...

output:

1
963529399
11
159920012 242249248 175932735 527286756 71358805 487693024 5360063 794532287 668174822 557760256 86208430
3
291105523 723336183 353896636
1
260819813
4
631096356 488830321 2156936 58282043
33
687424143 25749543 953905208 194806823 215247875 422729900 237207417 385174124 902762818 9878...

result:

ok 42249 numbers

Test #75:

score: 0
Accepted
time: 299ms
memory: 27472kb

input:

4533
149 363
60 58
64 18
62 133
78 26
54 24
6 63
65 116
6 63
93 70
112 28
107 100
137 31
104 18
147 63
61 81
136 127
58 79
56 28
117 115
122 132
122 132
54 30
104 50
74 31
32 16
113 39
144 30
26 37
132 122
104 134
98 29
75 92
1 87
65 57
60 58
87 42
132 142
11 67
75 38
34 18
145 47
17 33
3 143
123 43...

output:

14
654132311 680319525 876298501 734492574 279566491 294731277 243979488 687132984 509201516 298285280 549094847 624557184 348746061 774785853
128
243469497 941676738 254294951 121879382 362433544 944740806 924936908 796222657 295867358 307631279 963009184 953404003 421646155 541014421 130050781 206...

result:

ok 99528 numbers

Test #76:

score: 0
Accepted
time: 309ms
memory: 27452kb

input:

4913
151 295
31 23
61 21
9 37
103 88
117 62
129 1
102 13
75 15
54 121
57 134
83 97
11 5
102 13
130 136
98 68
77 104
121 129
118 7
116 32
20 87
23 46
132 34
12 126
14 70
113 64
11 5
17 50
89 71
138 38
22 34
78 144
93 72
108 116
121 18
120 31
122 43
23 96
41 71
90 127
96 50
102 13
41 144
10 78
53 111
...

output:

23
516991759 357217758 423674149 66437812 559901588 895450555 190448184 641890502 396895082 89847454 191363359 422729226 879922564 325541386 570177367 316773576 391810639 216000202 701714468 526068570 452723512 559889028 374538301
51
316921851 302147811 46428619 126960850 449727861 940169407 3397081...

result:

ok 167707 numbers

Test #77:

score: 0
Accepted
time: 435ms
memory: 28752kb

input:

472
276 1122
205 112
5 192
268 265
137 82
248 254
75 112
196 67
117 98
122 194
19 15
105 124
95 137
142 74
97 218
113 157
73 177
73 164
265 30
79 221
57 214
269 237
170 159
17 87
265 30
22 149
125 86
265 252
105 124
64 219
64 116
115 163
215 183
12 104
36 116
199 253
113 52
80 252
135 99
5 8
71 195
...

output:

28
595329373 324060565 854598601 497929508 933087553 294063990 432886813 888155070 499534791 751915861 46586656 807955511 45950434 282181114 614160027 565501647 836860052 329252189 460780094 902762982 670983838 81850654 742865844 413146017 182202019 980525723 525635312 21428523
451
934603459 5551761...

result:

ok 105264 numbers

Test #78:

score: 0
Accepted
time: 443ms
memory: 28408kb

input:

482
373 456
260 371
263 82
79 304
96 89
67 356
174 238
299 8
195 339
197 333
123 359
120 97
156 11
322 123
113 324
215 51
5 46
96 29
306 219
179 185
3 73
245 248
274 226
369 296
336 139
233 350
124 155
164 107
35 366
245 117
199 28
234 61
252 265
301 30
196 332
78 365
308 144
326 203
52 353
364 101
...

output:

230
614883966 690555527 526535709 519995906 116338109 328775956 276757088 991034741 712088804 362892548 561654564 701159837 178809467 272370898 383766052 928841397 319398755 186337692 841433361 217194707 342861533 846070015 384965044 887002346 991358476 302032084 446069789 767494348 43602989 6219655...

result:

ok 188443 numbers

Test #79:

score: 0
Accepted
time: 417ms
memory: 28456kb

input:

459
1532 3712
1370 740
44 435
493 587
1062 933
1396 893
1516 1402
682 132
1200 162
994 1289
912 282
958 744
912 107
83 1094
182 225
1018 499
250 459
786 119
29 845
1039 1481
791 1017
176 62
812 245
831 347
1201 104
528 484
48 1246
1260 1462
704 668
517 554
154 228
510 1019
1406 876
210 411
214 1244
...

output:

207
675042387 254835630 649635582 955169011 674955682 85732873 81061594 710618893 191539167 833564799 566448123 629832321 671183898 347612259 949437349 982472698 426127811 921060631 484583217 208310712 253663487 949263335 40993414 633939221 907483435 559615633 70099768 760205884 835682594 647356042 ...

result:

ok 124514 numbers

Test #80:

score: 0
Accepted
time: 454ms
memory: 28492kb

input:

457
1931 3194
1916 1398
849 1558
236 1502
1772 1532
317 238
1517 1292
1795 1095
857 1821
1058 1016
1068 156
93 1543
1386 1049
890 603
1465 1814
1100 217
1702 1655
1095 1602
1658 746
574 405
533 1456
464 516
877 1239
841 329
207 447
135 1310
256 1638
286 346
254 906
18 145
1281 1930
1209 1245
772 807...

output:

285
928256209 768294421 405443280 475157183 323835738 739380735 906726268 622175638 145070986 469213040 295423652 519425253 353950615 955432724 887569042 469060921 991454410 465669687 851739994 695991363 771205002 680450149 727924612 793119025 253095274 951761820 287589548 872426442 939413967 894965...

result:

ok 116807 numbers

Test #81:

score: 0
Accepted
time: 654ms
memory: 38156kb

input:

50
16388 24464
7061 5394
5954 7575
2135 1048
15810 1217
11708 2444
12114 9217
12258 16200
1609 7675
4106 15397
13798 7072
2103 2691
15090 9560
5749 5379
4800 14526
9839 14988
15994 4895
6687 15052
5795 13380
13203 4714
4893 4183
2533 7675
8512 3715
6362 11598
6396 984
524 8071
8346 8173
15653 4984
4...

output:

4401
66443481 27844386 176626733 653797304 930457124 267466265 651479396 999834662 949425135 553436452 384156147 817847150 519636226 631871534 363996113 545318335 635046476 802838116 354472877 77930449 360964153 574295079 480149155 74570258 773205540 840152670 20148747 706691681 215757619 912123739 ...

result:

ok 118331 numbers

Test #82:

score: 0
Accepted
time: 674ms
memory: 37372kb

input:

42
12542 14064
770 12539
5071 9863
8032 5558
7183 10740
2649 9533
4016 1028
12171 4722
859 10720
3398 12187
12054 1118
205 8227
9855 5854
5891 5694
504 9704
1081 6182
8945 4686
7587 5127
10654 7032
1754 2123
3810 11984
6009 4859
11386 10965
2485 12062
4428 2544
8304 472
7814 9759
3440 4949
4708 3606...

output:

5724
416896881 697970284 974104627 213493368 836340221 401069765 48013464 356621786 545784363 147060301 602043316 521561018 655785061 716269688 648879218 479496317 35696152 574528373 466048118 842688860 883313347 349407731 38461577 972206296 913219021 343472847 475873770 334261146 185149316 83647050...

result:

ok 57740 numbers

Test #83:

score: 0
Accepted
time: 668ms
memory: 37348kb

input:

46
9260 17441
6741 5412
361 1882
5703 1786
5290 2232
1520 3892
4959 9122
5619 8560
2904 7396
173 3814
4754 4464
3206 5654
2145 6694
9163 4205
8289 5525
7690 7814
4295 5390
6155 4137
711 7185
6013 4634
7001 1221
7057 1281
2871 5639
7490 6044
7520 1137
4306 2202
9108 784
2354 8547
6224 5169
1332 8988
...

output:

1387
387772050 53381961 223528923 314866420 915971247 778802222 276750804 536559028 407405719 254044919 617961222 118519869 424763459 867549948 917662862 858212067 234318100 944797241 728068511 536681001 236876444 235374225 709104117 419059115 977567225 211973062 452339866 101994772 356878109 711675...

result:

ok 99549 numbers

Test #84:

score: 0
Accepted
time: 653ms
memory: 37684kb

input:

40
2340 21295
499 1728
822 1438
148 2057
675 475
1734 1222
849 1884
1012 1824
1652 226
93 1553
1078 1578
518 2097
716 471
1844 1918
1347 1294
1339 1553
102 1729
1274 99
1918 1223
737 658
1387 2053
119 402
1033 1794
1881 517
2247 1259
674 2285
552 253
10 747
1131 280
348 1418
1447 1529
622 1576
1308 ...

output:

28
257660974 776571128 356202624 631121635 727760452 624567443 25970747 830586172 586089311 130764114 477828475 881650360 411514870 430494709 690157211 836087374 97349457 745151804 193808793 501331545 480302261 407182434 105012901 895815164 405215936 521441661 359187462 65859293
265
384109605 420587...

result:

ok 18639 numbers

Test #85:

score: 0
Accepted
time: 810ms
memory: 70792kb

input:

7
24098 104542
10495 4169
16373 4181
14396 14373
23884 21930
9794 12983
8515 17372
11099 21933
13620 15157
2033 15865
1632 13372
15033 18475
22802 12458
10080 13532
17889 6999
14598 18045
16473 19481
7445 12365
13343 17482
1207 23984
20440 5798
7614 23463
16414 2095
1401 2562
14268 20363
5922 16593
...

output:

2916
575476819 200903034 125855553 941960988 129278699 397108284 633050187 925879751 743136402 421006072 129805786 416345979 445174907 268944958 949570130 768593810 217890675 420898854 974849039 20829579 302798627 597071121 382241729 548703775 730473946 732370385 867663498 164187794 878297037 530435...

result:

ok 47167 numbers

Test #86:

score: 0
Accepted
time: 630ms
memory: 65980kb

input:

7
48705 144791
28350 9711
14272 31760
31474 1999
534 35414
7742 32192
28941 13172
19679 30685
45650 24833
42251 35111
38309 8869
31878 7516
34014 46277
7860 18676
31860 493
5950 13902
39621 10473
37947 16323
32816 11566
27033 31851
13662 1819
23062 5023
4294 21551
7462 25029
26132 19697
34024 481
35...

output:

3114
2617391 705635886 451138190 269787046 971902658 104832850 717839369 954111780 91851574 311793856 301419240 868698767 456737350 998609812 969182395 569176270 888010405 784506745 290446185 782685708 340294461 936185413 155693006 838176212 218667339 670893404 964817351 444536022 678237546 56707006...

result:

ok 23849 numbers

Test #87:

score: 0
Accepted
time: 709ms
memory: 95136kb

input:

4
110717 270009
60804 91391
99934 73804
64349 52744
28142 6412
110275 87613
517 77345
17833 24584
56478 67894
54022 57962
35768 103805
90927 16878
82912 52677
33788 106529
88778 12774
98489 9494
78090 47527
68520 104393
52390 36969
53193 18455
18141 87581
89893 67605
81844 69611
554 17428
40621 6216...

output:

13655
487014065 978463425 137659670 317845255 289042449 710945168 18635205 228115824 550628854 144722563 342877511 901710613 937675641 568734124 1072895 270167910 707016692 389581813 357274607 835020526 294835969 741321013 454838690 894940845 146457753 436143419 681959809 577759016 236266024 6007756...

result:

ok 92013 numbers

Test #88:

score: 0
Accepted
time: 882ms
memory: 101204kb

input:

3
91975 350257
75827 48551
7156 81713
61844 40053
79395 79594
21432 34754
86926 54912
39816 86483
55959 44805
60206 32295
50497 3804
83262 74161
80070 3400
8927 35456
58209 78322
20754 86681
23666 74604
73782 23247
38404 34506
69384 80119
79474 57041
79931 45310
45658 74655
8130 40185
40867 15759
40...

output:

1542
229026791 971838201 253792442 370084553 613964518 376680474 835769758 375496042 89515148 370910460 906733909 936235183 964399489 770270811 532489384 529383171 296049119 719964520 629043384 435328697 706438787 25267702 570998365 564384685 529175244 932862086 28163796 232766917 331558424 21216250...

result:

ok 7235 numbers

Test #89:

score: 0
Accepted
time: 293ms
memory: 27456kb

input:

4045
18 245
18 12
18 9
11 8
17 15
16 7
9 4
17 16
14 12
16 5
10 15
6 8
16 14
1 3
8 14
6 11
1 4
17 9
1 4
10 1
10 8
17 13
17 16
13 5
15 3
6 3
10 3
6 5
17 5
17 5
9 4
17 6
16 9
8 10
7 10
17 11
9 4
10 9
18 15
6 2
15 4
17 4
14 13
5 15
14 4
9 13
6 10
7 5
11 9
11 14
12 1
6 1
13 2
7 3
1 13
9 15
13 15
8 3
11 7...

output:

1
599925780
1
597221894
1
910672519
3
679928025 577792966 290638658
1
14536872
1
424528100
1
282424562
1
132317239
1
899484484
5
107806521 488912153 467931657 257490413 767549561
2
611255257 334825314
2
570554519 121365225
4
522176134 224991044 222443105 222181311
2
34114970 229658152
11
70561121 18...

result:

ok 15079 numbers

Test #90:

score: 0
Accepted
time: 291ms
memory: 27476kb

input:

4114
127 244
102 67
120 5
33 66
91 86
98 121
69 32
21 74
48 76
41 59
29 44
70 65
98 37
84 69
59 24
53 80
50 57
48 14
33 20
82 104
87 78
13 105
50 80
113 17
88 43
38 123
79 2
38 45
95 54
35 29
98 35
111 81
94 105
62 31
116 6
46 21
1 89
74 3
53 31
119 115
107 67
68 118
51 10
63 27
45 13
65 63
36 58
62...

output:

3
962752557 926253950 990160563
9
528052371 541617974 165349616 254361599 317101757 212262212 816293850 703786396 17890975
4
548315992 868531427 355824036 127998375
1
822953861
3
456642101 506770860 3775385
3
424480275 947596705 6229928
38
386704615 55499734 545745987 683524878 651624480 539025358 5...

result:

ok 27064 numbers

Test #91:

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

input:

4047
169 359
111 158
133 130
134 165
121 20
147 95
61 143
122 36
7 31
153 55
152 4
19 21
125 55
139 97
152 93
18 117
75 81
144 152
25 104
81 144
114 132
135 35
92 1
32 73
156 37
165 61
133 99
129 116
24 126
161 115
11 160
8 67
108 114
36 55
86 163
88 3
1 138
18 94
35 43
47 27
167 128
100 148
64 164
...

output:

1
966711468
1
321
2
742387750 838875569
3
962229087 531538215 417436008
1
230611883
1
124407214
1
100725269
1
743056103
27
769721530 93884345 15060581 152702267 552311944 800391229 320828754 635190729 459538928 803806969 389316230 964911466 851100963 415351490 1513143 737403994 336543503 286043758 1...

result:

ok 15603 numbers

Test #92:

score: 0
Accepted
time: 288ms
memory: 27468kb

input:

4102
146 232
79 24
83 96
77 1
21 25
24 145
32 120
59 143
137 21
92 63
30 105
126 112
3 7
81 100
18 55
86 15
144 124
131 95
50 108
142 124
82 41
137 13
66 98
88 128
33 48
124 24
58 32
76 8
62 96
67 136
61 21
96 140
118 74
101 29
78 61
94 58
24 96
145 128
86 38
58 28
14 103
30 128
29 27
93 20
9 71
144...

output:

5
622185323 767706469 908189139 19670900 928095372
5
460602808 311495678 528912797 374102082 770040823
1
33942299
1
548492174
3
953640586 679616647 636468551
1
348265709
1
573286707
7
159116560 777937431 320849072 152917930 823296417 728076557 291861127
3
295828603 214767195 66895715
2
877985366 180...

result:

ok 20089 numbers

Test #93:

score: 0
Accepted
time: 398ms
memory: 28572kb

input:

408
9 29
1 5
1 4
5 3
4 9
9 4
3 7
8 5
4 1
6 2
2 9
3 5
5 7
8 1
8 5
2 1
7 9
2 9
8 6
3 5
5 4
8 4
2 1
1 4
2 4
2 7
3 5
3 8
2 6
2 1
690 3362
427 325
562 233
585 130
24 689
636 501
178 271
122 96
204 609
260 92
22 354
469 672
312 631
374 396
339 358
409 372
127 582
115 562
435 253
47 227
139 574
514 410
143...

output:

1
794153862
1
343952477
1
877577542
1
851864687
328
811229528 261505621 628286640 833572166 141642343 28313073 858010609 51342033 662663522 601409007 96658549 804389670 635106600 834498548 579543685 308315697 440088121 577144967 305689436 932530518 91273048 664139937 727446441 647557767 218695859 21...

result:

ok 6896 numbers

Test #94:

score: 0
Accepted
time: 393ms
memory: 28836kb

input:

402
159 2348
129 150
78 23
20 137
155 36
79 35
20 18
158 104
40 70
138 112
23 12
63 3
89 39
118 106
42 67
131 11
75 45
20 124
43 70
110 34
68 137
106 7
15 119
40 10
88 128
11 50
86 80
14 61
85 132
29 45
107 10
113 98
58 136
53 135
129 13
29 142
62 121
9 136
101 45
115 126
19 46
106 57
83 74
111 150
...

output:

1
178553355
3
845813142 62092750 65236931
3
309784074 638347850 159826703
3
242667299 220232731 460646967
26
999823311 470533299 504064573 535706730 979010164 332915090 416270099 908975593 570071626 952303994 831184054 360585892 770029614 74258638 537395954 22393323 400499638 924600774 693387202 732...

result:

ok 4603 numbers

Test #95:

score: 0
Accepted
time: 395ms
memory: 28624kb

input:

391
723 2972
375 607
6 597
211 406
90 288
40 138
662 33
484 2
273 137
272 607
348 593
20 389
142 383
274 306
629 482
235 331
42 364
512 410
703 624
459 481
180 537
312 537
269 58
404 695
46 246
626 250
466 623
387 470
222 686
104 713
289 661
172 20
604 357
133 396
603 532
55 641
575 213
13 22
90 364...

output:

1
259560857
5
894386912 791170517 857006616 155412099 701950841
25
572491057 716071287 527376980 127265037 53974892 514260031 241845007 376326083 30139570 894816321 862730122 504156116 736492987 594545999 45479978 377298528 312848203 104427272 600281176 526077397 969824470 800247122 840366609 683627...

result:

ok 6449 numbers

Test #96:

score: 0
Accepted
time: 412ms
memory: 28600kb

input:

420
1736 2677
1300 235
204 325
757 949
1317 324
403 720
96 1601
162 343
1302 1124
201 1239
534 1129
129 122
1314 239
589 919
1296 1036
1642 1420
1471 1145
1599 1119
19 961
1483 1435
666 55
1445 896
330 1692
1161 395
1385 665
848 731
708 740
174 808
158 957
577 394
662 210
1569 1199
433 592
1164 320
...

output:

52
290637248 931102397 856969958 576432057 430694781 601882911 730784050 489109318 859717626 287901418 646701388 62421368 668664456 648745767 177378349 678932246 100192948 946259333 729153095 133242254 601952138 400655938 702576955 903440512 493833791 536339369 386412371 59661095 897320251 792304858...

result:

ok 27680 numbers

Test #97:

score: 0
Accepted
time: 654ms
memory: 38340kb

input:

37
7095 25224
5587 1468
2146 3505
1435 5842
2763 5685
6969 3303
946 196
1013 5350
3178 4855
4610 3499
3703 3056
3715 5986
730 6401
1110 3794
96 3983
4877 2867
4221 3060
6974 4836
6313 2230
3148 6407
2181 2701
5539 6407
534 3384
2698 2603
5077 5085
4978 5196
4517 336
4666 2696
4635 2731
2578 775
6774...

output:

66
838959398 815380589 183118629 193731179 33636096 992364014 514519904 803852819 982308824 670232100 986357835 780205282 289273774 567673282 840886336 89433657 319343636 72502533 370094402 319782072 244476709 629770072 462768111 910714290 759031641 274503220 481322108 859634897 860320879 67814517 8...

result:

ok 13335 numbers

Test #98:

score: 0
Accepted
time: 666ms
memory: 37148kb

input:

45
12954 16350
12077 10658
2417 8979
7756 11732
10237 2769
10818 10649
1989 5795
3829 4498
8521 6046
7179 5333
5431 156
8033 6024
12715 11832
11083 8221
1047 12383
27 7039
2463 1636
2364 12165
10105 11884
3568 8729
9984 7505
11752 7743
10871 7813
9906 739
126 10238
6147 8443
4192 10494
9216 3213
310...

output:

354
62780524 346210444 863338825 13960435 538461365 538018865 463863210 548883797 497972074 507846073 562176498 525540871 395493228 642798091 778289970 520379302 192595989 641136926 469850244 310846930 418201720 13942918 130154673 43731025 866533567 769117998 927389130 554083722 231460145 768964553 ...

result:

ok 6636 numbers

Test #99:

score: 0
Accepted
time: 603ms
memory: 37708kb

input:

38
7217 30318
2896 5613
1769 3367
6283 2237
4366 110
1055 6178
1360 3779
755 3676
728 220
1701 1637
3372 685
6404 3583
1395 5304
3766 1287
7096 5982
1573 4232
2964 6360
24 7067
5915 7005
2053 6183
751 4725
6203 954
7061 1423
1473 3629
1592 3717
6209 1846
5080 6708
2337 5137
6158 6916
5102 5888
5657 ...

output:

48
84370993 628064413 902436815 923656194 899539255 174858649 80420720 405699639 354579653 739733821 870886684 10652209 991412040 831832772 781979553 773849184 494544958 353125790 889987191 87242751 325488329 922066775 582293046 22585899 237940337 307103615 911826259 810924269 894671891 465185930 79...

result:

ok 4113 numbers

Test #100:

score: 0
Accepted
time: 697ms
memory: 38364kb

input:

42
513 11470
337 355
119 76
359 393
283 253
313 390
430 77
453 439
198 395
443 488
305 431
85 285
93 104
134 194
84 227
398 100
90 11
511 81
124 71
392 270
22 245
477 450
153 238
402 194
371 389
176 456
226 501
83 269
343 200
78 435
258 139
310 362
272 269
154 347
97 252
407 210
328 214
255 485
170 ...

output:

1
988247052
50
43351516 317700090 356444051 30688490 4681115 941482916 776717405 613825644 819328653 466501232 840493538 374343411 575169643 658284615 740863428 89306813 30125907 472278748 84611808 378053446 879993928 317938021 179029281 472784595 6498173 914057498 57248160 874913485 281690327 74059...

result:

ok 14480 numbers

Test #101:

score: 0
Accepted
time: 866ms
memory: 80868kb

input:

6
96593 185864
78748 14452
65112 11752
24719 91056
39849 2595
7967 9560
93165 40666
60150 14591
24333 37209
71518 70831
35785 92519
64632 35112
70139 33314
88131 15704
31722 29936
25664 59964
21197 77156
17934 22242
35269 38879
41657 26592
95305 44565
26458 81592
86119 83777
74255 48897
22966 57816
...

output:

1192
312324398 275928046 609991355 416320150 936585694 282757617 105360269 115679903 985903378 510619057 653311268 266534104 877186360 449368270 42514903 778690127 757191872 553830137 551861513 109470971 824333707 259366407 473681547 75541059 289696766 143826425 116811953 509044943 359841046 3094307...

result:

ok 2869 numbers

Test #102:

score: 0
Accepted
time: 849ms
memory: 70848kb

input:

7
41040 207266
4702 30404
8249 2905
19586 21097
14292 38954
5511 31986
2045 36427
24362 21509
3796 6628
10489 34279
9345 6671
13511 30663
2440 13906
32403 38866
23120 33295
34221 2405
23022 39986
28651 27946
32326 39734
12152 15507
31947 16705
21258 11824
35604 15225
4037 4341
19040 7064
34156 7579
...

output:

339
505492377 575967698 371669095 563995225 470903264 320012203 632953386 350419746 772082974 468473811 812343059 223722842 310804352 556285269 881606638 239076771 260521949 689437258 663686403 375419879 525561313 605099774 812680371 184652914 94625021 783353651 326698690 656156297 71952152 76031889...

result:

ok 10147 numbers

Test #103:

score: 0
Accepted
time: 782ms
memory: 84264kb

input:

2
82340 356457
10182 15357
65620 25069
79901 61649
68973 79338
21955 60984
75735 47017
60177 78889
11754 70829
63389 24071
71073 22884
42107 57426
49884 58778
50990 18059
37958 59555
19355 40221
77763 32491
43413 35542
14540 3733
73920 68317
6012 38391
34338 49771
30391 36017
27845 23036
36822 44543...

output:

513
986731126 116169145 428574960 541464277 630394344 441156617 705063932 431916173 738852343 654358767 102097987 497761457 855857470 159968176 273449817 74481583 41646087 93131746 419652650 466328566 181720475 451126692 988218890 387042937 718244143 434464498 531812724 614685073 194803951 585237967...

result:

ok 1101 numbers

Test #104:

score: 0
Accepted
time: 1178ms
memory: 103016kb

input:

4
40680 317833
14211 6411
12026 20331
24353 8311
28196 25772
18027 5960
13767 10593
20363 28724
22256 4631
11185 6830
10931 20069
33404 20113
12059 26178
30133 20055
27709 26549
36611 35110
14666 1145
34749 19176
37508 30029
27242 20977
22133 24481
13042 9357
36385 10100
33271 21249
37297 11139
3381...

output:

244
504259747 445422790 126962101 254284270 182485318 874987230 977579958 275813762 475795271 593288884 408832971 837535460 371431870 799566778 510192861 303088259 185751610 830259645 863257584 831727590 546739741 892607542 170098714 8609411 556503531 209029489 899061142 488111612 977393052 81547484...

result:

ok 18345 numbers

Test #105:

score: 0
Accepted
time: 283ms
memory: 27408kb

input:

4858
101 300
95 3
14 38
60 49
25 75
99 43
21 78
86 80
18 58
9 81
35 67
52 51
3 75
1 5
66 87
11 15
97 50
66 87
42 33
22 54
82 16
44 67
93 38
1 86
51 69
48 53
39 1
26 86
44 57
49 56
51 39
99 43
18 13
95 28
14 29
38 55
57 19
58 18
99 43
69 5
97 50
66 50
17 45
22 23
91 31
31 71
25 3
66 87
81 69
32 70
85...

output:

1
307938530
0
2
416239578 623957841
1
864157239
1
698087100
164
632122185 781601272 222423393 475610024 255555885 607401348 683549546 293479979 789793795 829642524 612091434 747482485 494953354 1460833 715405842 484863000 274541217 651448788 857796342 801505388 930445483 815221802 404314845 28919834...

result:

ok 57780 numbers

Test #106:

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

input:

4982
15 53
11 4
14 4
12 10
5 12
11 2
1 5
1 12
6 9
5 2
11 3
8 5
1 8
15 4
5 4
12 13
7 3
6 2
10 3
2 7
6 4
12 4
11 14
11 14
9 2
13 1
8 15
14 7
11 10
12 11
14 8
3 15
4 15
4 11
7 10
5 7
6 14
15 9
15 9
5 7
3 7
7 2
12 15
13 12
4 7
5 3
12 2
1 9
13 2
4 10
1 6
10 7
13 2
13 15
133 166
10 86
123 8
131 99
106 36
...

output:

0
0
3
373309203 137335481 559625480
10
977483360 601882973 200778206 694725479 945257001 836548617 667781558 237317813 135431348 142710327
18
598325183 745527961 107644069 227205747 116732507 600762654 9604311 749460287 305267333 930538014 615910428 893953460 263469267 796997423 809581809 760451898 ...

result:

ok 68692 numbers

Test #107:

score: 0
Accepted
time: 267ms
memory: 27412kb

input:

4689
62 114
31 59
59 12
3 14
24 51
21 57
38 33
4 22
55 25
54 37
11 46
56 26
58 60
55 44
24 45
55 25
5 35
62 36
53 60
6 17
27 62
48 49
3 9
16 15
43 34
22 40
20 49
49 62
12 59
1 9
35 17
55 44
31 12
1 51
7 46
11 60
24 1
48 46
62 58
32 13
49 20
27 48
3 26
8 28
30 59
12 30
33 23
44 25
20 27
27 11
26 19
2...

output:

11
946781858 480473137 667983229 288617816 751179209 425191244 110099241 941638707 680655801 981401143 924747328
1
848751552
0
0
0
0
0
0
2
641598360 416028161
0
4
168288272 699082480 603509818 365172414
0
31
882571535 77647351 619067522 727472459 281842132 451905319 855888914 662088242 393127739 187...

result:

ok 50241 numbers

Test #108:

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

input:

4373
191 217
147 191
11 73
28 81
43 11
111 190
137 74
101 38
156 149
89 12
161 141
7 161
33 124
103 158
85 86
142 111
146 109
121 109
180 24
60 59
82 125
58 46
10 35
85 27
41 36
160 123
113 91
178 30
107 183
6 155
31 96
73 56
120 175
83 32
168 147
80 150
102 3
179 2
29 70
72 61
185 106
175 152
34 14...

output:

3
63792248 751017200 761712383
1
98551826
0
6
556154748 877116968 98254580 336259705 388313576 524748853
0
0
1
13547862
1
687281357
0
7
722582534 446286170 393609923 722345502 853713117 265949651 346594189
17
781642487 153868189 804059692 241402288 631117497 876625091 522747394 425462996 141687796 3...

result:

ok 26121 numbers

Test #109:

score: 0
Accepted
time: 410ms
memory: 28648kb

input:

481
820 2770
676 520
222 238
221 157
392 366
43 459
321 416
354 656
684 794
364 485
77 673
315 519
456 141
238 665
298 16
654 678
652 419
369 346
40 80
171 595
74 762
203 370
100 556
614 463
387 218
259 180
33 727
145 223
544 738
282 610
808 616
200 100
770 42
137 447
123 357
492 397
88 96
434 95
70...

output:

20
669947424 36588010 275386238 636111032 362170545 28761078 75505320 734772708 668935097 371005761 89964037 475626773 796719823 527339119 264358895 819531045 862498983 535960889 802263087 492844857
203
252602307 293012450 833685745 872221508 891626692 79448066 851288068 418854162 100960736 29963792...

result:

ok 38979 numbers

Test #110:

score: 0
Accepted
time: 397ms
memory: 28496kb

input:

432
71 2650
62 54
65 28
5 41
21 28
5 39
41 43
53 23
22 36
50 16
51 63
2 11
60 31
34 61
52 63
5 21
29 16
65 64
65 64
42 31
24 36
18 55
32 45
42 30
43 64
69 2
29 45
29 44
6 7
60 70
62 20
3 67
29 50
41 43
49 26
30 60
35 21
9 66
41 65
2 7
6 7
61 28
66 25
71 55
69 12
71 48
6 58
32 45
23 1
37 68
71 48
6 5...

output:

1
845514788
1
397324631
204
291511236 368594400 709664098 82821209 988829288 28678466 264074718 175415979 687696264 833701566 199867437 596002403 848258870 987147889 521653344 684403418 232367193 976882633 290864964 868192232 212041414 546967271 276863791 551013650 723665144 945325637 844178717 9150...

result:

ok 13663 numbers

Test #111:

score: 0
Accepted
time: 399ms
memory: 28560kb

input:

474
1458 2760
45 1327
1353 652
84 131
828 803
1334 927
1253 306
1162 173
897 1246
598 363
1038 1275
379 213
845 266
69 1300
215 1145
538 1328
82 288
1151 834
547 1122
956 125
243 21
630 677
100 1409
299 986
223 279
718 745
312 110
323 864
1305 231
1245 1287
1209 967
681 1153
749 235
880 180
648 64
9...

output:

181
681046726 44291396 732147512 136226083 31605784 391975289 643568905 782769263 746535459 726235784 239164056 340619447 305453026 176505187 826688448 235729368 786802183 388740874 843450683 766697932 54006097 672310584 904822309 497356664 549511497 185130625 425717268 885679356 431796693 172710289...

result:

ok 35227 numbers

Test #112:

score: 0
Accepted
time: 434ms
memory: 28388kb

input:

501
1864 3576
629 1555
653 1524
1815 1653
506 885
1197 158
334 1220
371 439
134 171
678 471
129 207
817 496
835 812
1332 1763
1396 1492
1620 1179
1848 647
219 171
1198 1239
998 56
1835 470
1270 88
1318 1756
721 738
365 1096
1607 1854
1232 30
722 1625
297 189
642 1243
469 256
1840 865
1085 523
1532 7...

output:

80
74335670 734409176 922886881 856718531 693084540 79514494 187721127 16591629 163220137 269672105 620863825 997607876 509708595 709035291 730510838 146851630 985237948 48522119 800939743 695716199 977793966 360941985 738640788 94230584 660772889 400331907 843024707 318945075 210031982 961651432 17...

result:

ok 52163 numbers

Test #113:

score: 0
Accepted
time: 612ms
memory: 37336kb

input:

48
15935 16492
8193 12472
13191 4424
10947 5657
9244 15640
2614 7351
6245 7451
132 13609
4574 7363
6522 9745
6138 4898
402 10137
11111 1133
6440 10918
281 6319
8067 1743
9308 12444
1429 4644
9526 937
12990 5669
8584 6933
3511 7509
8219 9039
13817 12783
4458 11939
15213 15620
11976 10876
15179 6124
1...

output:

4323
787302804 625461999 438753977 250113498 531316395 905607213 376223944 345173401 697141987 296804273 195777942 38234545 838611608 931633700 264926983 61917991 131401420 516369809 178493919 808866545 419085196 472473459 535178127 644418403 491774969 275848783 266719839 947517303 765364505 5547652...

result:

ok 42208 numbers

Test #114:

score: 0
Accepted
time: 624ms
memory: 37812kb

input:

40
18325 35492
5896 17230
1107 8646
12228 2525
4818 11278
7534 10848
7093 13055
4038 14912
17555 12976
15819 3180
9184 9099
6255 2443
5296 14352
13193 6914
17619 8541
3215 5688
5093 13689
10855 11083
11207 5049
9705 4531
17866 2805
12286 11239
17191 3540
16167 10382
11202 17632
12055 14321
5320 1984...

output:

163
196794016 861954379 710185010 561689032 175234602 836836755 85071732 660908739 33782098 383864871 574332081 955706738 212453037 750940337 878440331 364260420 886074579 691817737 824899729 862309798 38480930 540908065 803937926 633642584 831450934 250813065 142462651 434816793 789502236 306940208...

result:

ok 33683 numbers

Test #115:

score: 0
Accepted
time: 676ms
memory: 36816kb

input:

54
9261 15348
4315 4940
1606 3663
2920 6360
4419 3762
7185 2183
1633 7002
7024 190
7280 3879
616 8995
2130 6848
7418 3099
7007 371
9096 5595
7354 8862
1341 5007
7178 8570
3054 8402
2050 2399
4701 4958
3975 556
1278 5578
4835 278
1074 1727
7160 1707
6037 4412
5276 1883
2761 5243
821 8211
2495 8760
89...

output:

91
934044699 171036109 789358108 357947923 802169773 169121300 639901105 213154054 948537571 963917292 991116646 893512064 67834019 637910403 108351820 157509334 199033139 742504752 427165376 519980671 58587559 315156711 159770375 426700808 833242458 474755337 293708402 599920204 192758253 678163536...

result:

ok 48102 numbers

Test #116:

score: 0
Accepted
time: 649ms
memory: 36484kb

input:

53
3101 15815
2561 485
311 2153
1448 1017
1747 1296
2970 2007
2899 2148
2299 1276
2790 1964
306 2640
1442 648
1166 907
2983 1973
234 1433
2800 1814
1815 1719
2465 315
818 2257
781 1306
2579 2383
1931 1014
2656 202
853 19
2648 2125
2065 1863
2035 2929
2044 703
2656 2723
1849 284
1676 2969
888 731
242...

output:

0
0
0
0
0
8621
848990213 806876782 314295796 345130898 864797418 431220628 582620916 681513768 466143821 725098129 724816458 361917838 815289046 300932231 700121454 550661974 90018036 634029403 852537830 527594427 412522554 187474677 391664225 16425204 806022681 341586736 753848881 869963344 3469891...

result:

ok 72393 numbers

Test #117:

score: 0
Accepted
time: 932ms
memory: 65076kb

input:

8
57639 127703
25859 18935
12908 27389
5566 29189
39846 15637
22283 33381
33436 50500
36004 40619
23909 13473
46713 49143
13448 56117
39796 46012
10966 6326
7443 54436
4085 33496
1836 13377
9248 49088
31455 27388
19649 36984
50183 18444
40456 47721
56030 19802
32031 15687
37843 3257
25699 44902
5124...

output:

225
29541203 455099419 48359513 302026292 648565524 352169871 97702045 497530142 122224654 643064067 146833610 778389521 327586941 702839437 152123241 973221012 295072056 829883014 137895860 622833514 783232776 604186032 859015172 694517246 217077388 265208690 80957020 344127390 309175179 221956201 ...

result:

ok 10393 numbers

Test #118:

score: 0
Accepted
time: 680ms
memory: 65168kb

input:

9
3371 47740
2663 2563
1051 1165
2667 2453
2601 3330
3121 88
3030 2143
348 2166
821 2296
1195 537
1944 3118
1480 1543
2459 2480
1191 785
2169 2957
1586 740
2662 2595
2181 318
1107 810
680 3264
1157 553
2148 777
1218 612
704 412
2494 1550
188 3068
168 1066
3282 3311
132 1707
2123 2041
2338 35
3274 17...

output:

0
0
6164
118740349 883003154 927175143 603486832 664938796 453255491 397800148 855089280 647443451 935366072 778895115 283303928 679210900 361558927 640745530 256161860 972590483 24732785 693831456 980642310 391676794 843839568 53204748 276591156 511349406 841972065 637829419 50892063 405722686 3962...

result:

ok 17093 numbers

Test #119:

score: 0
Accepted
time: 965ms
memory: 108384kb

input:

6
2962 21825
704 1944
690 2796
2594 952
768 1481
1178 1963
1882 2037
31 1711
935 903
1166 2607
1951 2577
136 2958
2067 1324
2402 294
1770 2294
276 2259
2099 1565
733 2508
529 859
863 2885
1131 1946
1464 1915
137 1996
2889 2261
1659 954
548 1284
498 722
2168 368
968 995
2114 1804
1595 1796
388 2728
1...

output:

36
813612680 407913551 812287768 913442553 266830729 245866390 799699726 598047330 95202147 78047567 872775101 979882582 286206666 464360747 180836726 977579901 602191856 770469217 578453483 746169680 836111603 129960603 281966548 137554889 131566910 791658932 376011860 280832421 678972976 398325955...

result:

ok 123184 numbers

Test #120:

score: 0
Accepted
time: 979ms
memory: 97488kb

input:

7
129657 223454
71601 3882
79135 116794
11321 96253
81863 65412
57461 81275
95431 108050
109357 3041
111929 48190
43748 104457
56303 24741
6459 65754
107903 126624
91317 126892
67458 27764
106107 110587
73059 2951
119291 90174
32143 3151
51438 65195
50221 70597
59682 72084
25731 44517
16733 105705
1...

output:

0
0
24969
286495903 722211104 361300770 683905650 334756100 500150653 462156190 213383151 834087496 520910516 374877504 958222011 371199939 608669179 158164138 68892023 131838989 477338352 345700621 82307760 443566490 477448086 194938693 114973627 266040945 868509176 766498764 23828927 435838170 833...

result:

ok 33834 numbers

Test #121:

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

input:

4053
125 196
19 78
104 110
24 33
50 117
5 48
72 116
39 40
85 2
44 64
107 81
15 75
67 1
84 105
100 28
122 68
121 74
76 46
88 70
68 48
90 109
114 20
110 92
82 89
35 14
40 11
95 114
110 1
119 97
77 22
119 43
97 88
81 87
44 89
113 16
47 117
74 122
36 38
117 20
61 112
13 59
8 99
69 47
81 57
67 94
101 26
...

output:

0
0
0
0
1
209182563
0
0
0
1
573207038
0
5
49843212 336699437 196771742 426918309 265311212
0
0
0
0
1
321
0
0
1
141112977
1
822292649
0
1
745875097
0
1
801931771
0
0
1
614757359
0
0
0
0
1
412576910
0
0
2
12 21
0
1
221391976
0
0
0
0
1
25242522
1
736038001
1
731477484
1
745837837
0
0
0
0
3
566411665 40...

result:

ok 9918 numbers

Test #122:

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

input:

4092
58 230
5 38
35 17
17 22
48 18
37 38
34 18
3 25
33 29
11 15
55 44
32 24
27 20
33 6
43 22
42 55
58 8
2 10
33 2
20 18
48 20
34 55
47 41
57 33
30 17
58 30
53 15
27 32
57 36
2 16
42 57
5 47
42 55
48 13
11 23
54 9
15 26
3 38
6 39
22 43
24 44
48 22
47 5
25 31
39 38
15 39
26 8
34 3
24 52
41 42
23 39
11...

output:

0
0
1
229582692
0
0
1
310653388
2
560358947 530987689
0
0
1
724963301
7
569319415 925916746 178674676 500566919 178215580 633210455 409999861
0
19
986888897 863594260 121246575 568893950 836218930 689633408 150350963 162209423 103533164 135950949 435358543 596355898 659538074 824864270 453617355 122...

result:

ok 11517 numbers

Test #123:

score: 0
Accepted
time: 245ms
memory: 27476kb

input:

4034
118 376
38 112
21 17
45 32
18 64
18 73
52 46
48 89
78 75
48 55
73 67
22 31
64 85
16 33
14 30
17 50
101 12
98 33
45 70
16 21
43 10
97 82
67 102
91 52
57 60
70 112
92 55
21 79
114 53
73 49
31 29
64 28
100 37
103 21
3 36
1 8
54 117
85 48
2 66
94 42
87 91
60 37
11 7
16 20
113 72
45 27
88 5
101 8
23...

output:

0
0
0
1
355516468
0
4
567091416 14075793 935002785 768737631
0
0
0
1
523791528
1
969540508
1
353842398
0
1
65884294
1
870898483
0
0
0
2
634659428 835301842
15
148735710 664897574 663439852 678715360 764065960 967547957 151300018 47851654 485109224 550457921 702344475 987460698 806727768 929943891 21...

result:

ok 10169 numbers

Test #124:

score: 0
Accepted
time: 238ms
memory: 27472kb

input:

4035
199 281
144 62
17 136
75 142
171 102
140 33
26 149
147 6
94 119
197 132
4 121
166 197
117 71
18 38
18 173
173 13
71 158
29 180
22 67
176 61
93 98
119 75
105 51
146 11
133 33
21 146
11 113
53 133
87 120
150 33
83 66
172 115
26 59
2 32
66 14
74 60
50 44
11 192
71 169
91 6
126 136
40 19
19 180
75 ...

output:

3
580884374 951769724 744925543
0
0
0
2
977200557 356002954
1
316587249
0
2
732636237 614664142
1
985421402
0
0
0
0
0
0
0
0
1
983936579
0
0
0
0
1
924207410
1
180603996
0
0
1
641877319
1
357447957
0
6
62092620 115723414 118062875 758076364 782495379 264597671
3
396753876 527986355 967208896
0
3
79670...

result:

ok 8888 numbers

Test #125:

score: 0
Accepted
time: 374ms
memory: 28584kb

input:

413
1731 4376
431 226
1470 1012
78 559
1353 1052
1052 1577
1389 668
1478 1707
1162 1451
1102 718
1225 697
698 308
1168 427
1444 82
751 462
1150 840
887 804
451 930
720 556
620 941
609 98
1721 1508
1542 1120
1485 103
1492 1515
10 882
600 1303
1452 1015
405 1029
1332 574
413 940
121 714
1588 659
554 1...

output:

2
947132595 909934471
0
2
964924965 756423729
0
0
2
927546808 222709094
1
3240618
0
3
797247178 872077605 277331491
1
81327465
0
3
481333721 396614328 786313524
0
5
885406232 167632038 514030791 659436924 508531439
1
272374937
0
0
0
5
24698041 135144532 320419185 495201274 943021969
3
788441178 2190...

result:

ok 3488 numbers

Test #126:

score: 0
Accepted
time: 386ms
memory: 28500kb

input:

414
150 2577
34 13
98 52
100 7
146 86
43 132
107 99
5 57
31 98
95 81
120 34
71 119
124 83
141 32
94 52
126 24
24 99
129 63
20 32
31 126
43 81
64 134
95 63
120 21
15 9
95 85
59 137
111 105
98 139
22 114
143 89
14 84
70 30
75 139
129 131
49 88
103 105
83 7
55 26
110 83
32 119
36 145
107 24
31 30
41 35...

output:

0
5
234610626 321729154 880439824 727095525 614973044
0
11
609358903 470116575 247895255 43973102 62274676 968668377 50967859 392108605 586003323 77369611 893414580
20
228744610 168215316 548075339 446486821 163384353 47435106 627619045 918747190 670930034 732818145 935624469 908534490 599848709 562...

result:

ok 8667 numbers

Test #127:

score: 0
Accepted
time: 385ms
memory: 28536kb

input:

413
121 1547
43 55
108 26
20 106
17 116
59 22
98 81
82 103
17 52
93 106
72 55
79 52
76 100
38 119
76 77
119 59
115 89
43 9
40 22
27 33
11 41
105 4
117 85
86 30
9 76
93 20
102 76
47 52
45 50
33 37
80 44
93 34
91 26
102 9
73 50
78 59
35 71
41 20
67 37
106 103
72 79
63 112
46 58
45 12
47 17
65 1
65 57
...

output:

0
5
886620788 265435920 891020650 658383310 460524793
22
436672366 237328125 739137091 890360081 924314829 35171845 963363367 220005579 704660643 132731043 628336923 726361055 594660242 497569758 108407205 919213046 666332565 912661206 964131042 927013242 722537305 754856473
0
46
532915138 881188225...

result:

ok 5371 numbers

Test #128:

score: 0
Accepted
time: 330ms
memory: 28572kb

input:

399
276 2417
58 78
245 183
80 108
243 198
129 244
199 104
61 168
42 188
202 155
113 132
153 194
34 155
79 114
30 205
258 229
79 179
162 112
205 213
146 122
163 166
110 74
212 181
11 224
264 249
80 67
151 113
98 108
103 7
214 255
258 240
159 274
174 4
137 215
222 86
164 173
32 112
49 94
83 275
129 38...

output:

1
853529563
0
0
0
0
0
0
5
550140131 256460077 269732448 324484701 332018985
8
488003695 356589160 199150836 597407003 534496096 721790997 428887580 461369722
0
2
301619813 196999242
0
0
0
0
0
0
3
4902465 243567165 851348742
1
162884279
0
0
4
458973822 167888332 576001803 840525272
6
899657962 104784...

result:

ok 2493 numbers

Test #129:

score: 0
Accepted
time: 642ms
memory: 37492kb

input:

37
9912 24498
8833 5000
447 5803
4563 6063
4637 1133
1815 1290
2537 3820
5614 7918
1083 8066
7460 9071
3933 945
754 139
7168 1805
5284 3781
513 4304
4788 6911
1697 1951
5782 1233
1964 7090
910 969
9322 2828
7744 3394
7650 7408
6807 7361
8116 6398
8149 5329
1072 5194
6501 3538
7998 7010
5649 9126
874...

output:

19
450982889 302604046 591922753 46670984 349248504 645568140 718035267 854429245 558657466 555499231 914206719 334181092 486870404 453571373 908164545 314979076 454909932 205145737 204715313
0
0
20
677518114 13403347 211387182 2926256 561328427 945209764 228925156 413806290 934455666 514475339 6144...

result:

ok 2231 numbers

Test #130:

score: 0
Accepted
time: 603ms
memory: 37800kb

input:

40
2783 5036
899 2285
1516 1167
2237 1017
1057 138
585 391
1801 1968
2453 2015
974 2334
192 889
747 1028
1567 2116
1637 2652
2486 1915
675 2728
816 2216
2282 2104
1309 113
1796 197
828 2407
2630 1568
778 1645
2315 893
638 2107
2098 624
2673 469
1402 361
2770 350
97 1891
1020 329
2396 1473
562 2654
1...

output:

2
800002512 224398346
11
512517464 783717680 705760606 660497525 325029017 997191869 358041355 594643566 966944034 87130494 487374922
0
0
45
993439962 371938341 788188548 107467803 752699616 267688610 570993764 892939445 411105478 395995099 112826628 391048895 772484302 339833631 479388824 916853740...

result:

ok 873 numbers

Test #131:

score: 0
Accepted
time: 621ms
memory: 38660kb

input:

42
7779 32806
3066 4343
2491 486
792 7549
3953 3430
1194 5841
2240 455
5350 2317
7217 220
7181 4432
2180 7283
3739 6230
5218 6373
640 1414
4225 2078
4577 4021
5415 7141
6231 2935
2416 6140
5135 5455
7638 562
7376 419
274 6943
1044 5286
5358 3617
5206 7468
769 5690
3415 3285
5302 7132
3107 2554
6053 ...

output:

0
0
15
243710048 774123544 436210014 881736357 145229532 482697862 939215689 790353663 857244490 129417862 538500490 556198968 624592153 317459897 124046983
0
0
0
339
712192299 285459702 57989492 335412463 225301386 724312324 263521968 505261648 552196451 528354492 558516649 629164682 262759971 8137...

result:

ok 2588 numbers

Test #132:

score: 0
Accepted
time: 647ms
memory: 37460kb

input:

41
6865 18195
6342 5225
132 994
767 6462
3478 1686
324 4710
2318 1040
4084 3285
1840 1317
1842 4324
3048 3867
2788 6027
2063 159
4247 3905
5933 1674
4676 5275
6419 3240
3742 4770
6132 1154
3733 4706
6460 2839
1513 3253
3127 1653
484 68
4889 5996
5944 779
4735 5297
3278 5366
4095 5672
5423 2723
1873 ...

output:

20
785599288 906789658 149564549 72029419 108758839 779050952 702260560 721021215 735768447 292149026 160450082 334436369 774299331 949001326 564895925 540599307 381581866 476925006 76785056 76496552
3
71338499 907485608 198112166
302
776834414 605152320 710251913 98530801 402217566 852880360 935371...

result:

ok 3972 numbers

Test #133:

score: 0
Accepted
time: 746ms
memory: 68412kb

input:

10
29209 56313
6934 11391
25479 5861
4039 9258
23996 7055
15106 27389
10386 20259
9044 430
18988 2804
22107 6486
12432 3200
11201 1712
12092 25796
27883 15003
21042 4839
24622 2160
289 7490
8206 24218
19101 19435
18108 23714
8403 18184
1920 28360
422 17654
14828 16974
27661 10899
8086 13530
27195 17...

output:

208
198782207 347552431 840193703 559065034 288432114 366075709 207290338 359733905 324047609 728659643 263064716 85518257 831319757 74369743 971574919 969355730 997044108 165296294 144088909 230829299 649186304 904709867 313208167 498201198 146315106 354158347 16243898 384801501 110064841 888391988...

result:

ok 1733 numbers

Test #134:

score: 0
Accepted
time: 782ms
memory: 79036kb

input:

6
77646 84149
8318 30803
23973 31255
7720 51343
49764 10585
23182 27362
65150 36741
41775 24183
18037 908
2362 3076
54517 64369
77436 18532
36076 44060
35017 69966
60126 33569
45655 23582
49097 34952
30096 2315
39938 14285
46483 33129
71416 13621
2909 74084
48406 9671
34393 34883
52945 25853
71076 2...

output:

656
105402168 586047371 858258073 34632583 838806693 567894516 19723861 432047036 984605766 796617309 560970623 797329122 281340338 486579560 977279502 504504311 420099364 967436980 258417344 403979420 788999821 934725979 193749450 348996820 572635866 35766049 58246563 919263162 206753747 32577696 7...

result:

ok 1537 numbers

Test #135:

score: 0
Accepted
time: 1270ms
memory: 125920kb

input:

3
196356 392982
111080 109256
74190 72826
39493 13895
174786 42105
68846 105856
171469 189129
83011 66225
123139 38802
76738 98234
106845 94426
179131 105939
116211 81896
60865 74164
34811 178730
73881 189580
107605 129495
107019 10163
175638 160958
66221 20414
178073 124477
104776 135727
113467 532...

output:

450
268690555 171629927 80570678 202555071 661658210 936443923 555591292 843510886 927092882 774317570 767364119 47050436 609907162 609530678 941840738 676190888 530358689 826716317 242938811 623024118 583623294 993562811 386488614 50129748 346528271 244977862 237394386 387670833 222870358 740995561...

result:

ok 741 numbers

Test #136:

score: 0
Accepted
time: 966ms
memory: 117888kb

input:

5
174946 271346
146749 11264
112378 104907
77007 96052
81398 89709
8958 21367
86034 115650
67584 91799
16680 44284
173040 152164
25345 14149
133162 31096
89513 34419
32822 100200
143651 71707
109012 30226
36209 111899
78476 18499
53941 122793
97313 38442
19425 96719
32844 171867
33923 18935
41158 85...

output:

947
206256952 91566053 415683384 687814955 732197898 479214101 637675911 688738438 392124483 356659722 336358593 887893387 190237955 531508809 625036258 398798838 303285791 759101451 299276407 472986672 145786604 843684037 714254318 898239586 588995837 872586164 666337560 806480447 787822816 4579268...

result:

ok 1271 numbers

Test #137:

score: 0
Accepted
time: 266ms
memory: 27464kb

input:

4896
13 81
8 9
12 1
7 13
8 6
13 4
7 12
6 2
13 5
1 10
8 6
9 3
5 12
10 1
6 9
11 3
6 2
12 4
8 3
6 9
11 5
4 5
8 9
11 7
8 3
11 13
8 9
13 10
5 1
10 5
6 2
7 5
6 9
7 1
8 2
9 3
6 9
11 13
6 3
12 10
13 4
6 9
4 13
8 6
7 12
9 2
11 1
7 5
6 2
8 6
4 12
13 5
3 9
8 3
8 1
6 8
11 7
13 5
6 2
7 11
6 9
12 10
2 3
11 12
2 9...

output:

0
0
0
0
0
1
836594863
0
0
0
0
0
1
904304986
1
742650993
1
364251
0
0
0
1
999374582
0
0
38
67169752 526196060 251144869 840703770 839137442 311746251 632660971 78737921 124453430 928820579 710652197 534966679 272217708 894678861 391485651 827403598 946102278 802972804 996861919 684054054 27287980 159...

result:

ok 7157 numbers

Test #138:

score: 0
Accepted
time: 266ms
memory: 27420kb

input:

4967
31 45
8 20
23 29
13 20
30 6
20 19
4 13
26 23
19 4
9 1
10 28
8 17
15 25
3 5
21 8
31 2
5 27
22 4
26 18
28 3
3 1
12 7
11 30
14 11
9 18
26 18
16 1
17 21
17 24
27 25
7 14
9 16
15 30
2 26
26 31
1 22
28 6
2 31
9 13
19 21
25 15
27 26
18 31
29 12
24 9
6 10
124 210
9 99
95 108
30 108
68 16
21 70
64 35
72...

output:

1
565794383
0
1
129220196
0
0
1
961911081
0
0
0
1
846732145
1
40549535
0
0
0
1
258467007
0
0
1
4231
1
84121491
0
0
0
0
0
0
0
1
847398731
1
968954689
0
0
0
1
468570880
0
0
1
116609168
1
174329307
0
0
1
925529871
0
0
1
677137031
0
0
0
1
965737524
1
184444798
0
0
0
0
0
0
1
535242584
1
548364270
0
2
12 ...

result:

ok 7435 numbers

Test #139:

score: 0
Accepted
time: 234ms
memory: 27536kb

input:

4193
143 318
108 3
42 79
36 64
79 57
141 78
100 62
72 86
92 102
123 21
79 59
135 76
49 12
11 126
126 121
142 110
118 57
99 52
11 123
17 143
142 64
98 51
79 57
31 77
121 116
127 134
47 52
79 57
52 130
132 39
113 83
93 78
83 117
31 36
133 17
37 78
42 118
31 107
68 75
126 121
93 111
71 16
134 80
107 31...

output:

0
0
0
0
0
0
0
0
0
1
219778627
0
0
0
1
186762088
1
568145875
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
32885795
0
0
0
0
0
0
0
0
1
27380842
0
0
0
0
0
1
251813058
0
0
0
0
0
0
0
0
0
1
875642289
2
875516507 258545732
0
0
0
0
0
0
0
0
0
1
134738067
0
0
0
0
0
0
0
0
1
539106856
0
0
0
0
0
1
620273410
0
1
4596...

result:

ok 5262 numbers

Test #140:

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

input:

4145
116 210
98 67
22 3
2 50
9 43
114 110
38 48
39 43
56 79
96 38
86 36
39 57
90 34
57 73
96 97
32 116
14 81
60 17
116 76
14 116
94 35
39 105
61 79
8 115
116 96
73 54
39 90
31 115
56 3
110 35
35 58
41 25
99 98
39 15
39 12
80 27
24 105
44 8
65 1
15 8
84 20
44 54
10 20
10 17
108 97
88 115
73 105
56 22...

output:

0
1
807489216
0
0
0
0
0
0
0
0
1
270354890
0
0
0
1
269843928
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
593268939
0
1
665260213
1
376367761
0
1
576231841
0
1
357797960
0
1
197009188
0
0
0
0
1
830357353
1
153001449
2
12 21
0
0
0
0
0
0
0
0
0
0
1
335330644
0
0
0
0
1
640650231
0
0
0
0
1
2461753
0
1
592487740
0
...

result:

ok 5306 numbers

Test #141:

score: 0
Accepted
time: 381ms
memory: 28368kb

input:

490
774 1238
5 510
430 97
680 554
470 64
432 409
562 495
721 167
351 68
468 720
184 352
343 487
298 152
220 750
549 569
518 124
337 99
717 535
576 206
408 750
285 32
415 636
385 765
597 512
17 383
236 321
538 188
569 415
146 211
594 256
638 5
128 746
697 327
10 732
502 199
411 200
392 325
610 73
122...

output:

1
371578811
1
40989284
0
0
0
0
0
0
0
1
342405534
0
0
0
1
172497788
0
1
497903155
0
0
0
0
0
1
414866758
1
821432049
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
211958503
1
30891139
1
407500046
0
0
0
0
0
0
1
969445538
1
971465518
0
0
0
0
0
0
0
0
1
552871233
1
358351340
1
797749588
0
0
1
125552527
1
30718251...

result:

ok 614 numbers

Test #142:

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

input:

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

output:

1
884871768
1
406881256
0
0
0
1
187925323
0
0
0
0
0
0
1
873911233
0
0
0
0
0
0
0
0
0
0
0
1
496460506
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
956453990
0
0
0
0
2
334966688 146124797
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
656369299
0
0
0
0
0
0
0
0
0
1
648448964
0
0
0
0
0
0
0
0
0
1
117601512
0
0
0
0
...

result:

ok 481 numbers

Test #143:

score: 0
Accepted
time: 398ms
memory: 28360kb

input:

495
1876 3769
564 1305
321 164
1014 573
1425 107
105 396
1630 1639
610 242
326 973
466 321
506 52
240 585
157 1026
1582 1791
525 1584
1242 718
221 368
831 748
119 435
316 999
1868 1635
493 43
1453 1778
974 964
1407 1525
970 1153
1121 3
88 766
320 207
826 806
456 1860
1315 1675
888 1052
268 967
880 3...

output:

1
325731444
1
672078659
0
2
583116977 695889055
0
0
0
0
0
1
386365286
0
1
767998383
1
430221916
0
0
0
0
0
0
0
0
0
1
631271922
0
0
0
2
667319212 991257649
0
0
0
1
224550740
0
1
824191498
0
0
0
0
2
12 21
1
33760495
1
114626196
0
0
0
1
240762055
0
0
0
0
0
1
27069329
1
876606781
0
1
922334945
0
1
949733...

result:

ok 810 numbers

Test #144:

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

input:

472
853 1403
786 430
594 653
700 853
853 700
124 557
596 212
74 236
44 632
418 841
445 610
614 587
66 174
143 436
318 653
467 687
8 201
164 433
671 309
170 732
639 45
416 574
550 26
500 737
614 351
18 439
343 277
834 616
231 451
81 229
230 322
401 66
91 834
181 179
42 270
362 418
833 190
4 142
694 8...

output:

0
0
1
50755238
0
0
0
0
0
1
210630421
0
0
0
1
731439546
0
0
0
0
0
0
0
0
0
0
0
0
1
251613818
0
1
262614558
0
0
0
0
0
0
1
603115162
0
0
0
0
0
0
0
0
1
888568604
1
884718985
0
0
0
3
799455188 980194818 623217843
1
715204898
0
1
884668903
0
0
0
0
0
1
50785274
0
1
886362517
0
1
728276598
0
0
0
0
0
0
2
2045...

result:

ok 599 numbers

Test #145:

score: 0
Accepted
time: 583ms
memory: 36644kb

input:

45
17845 18405
6923 14808
4531 12219
2144 2284
5913 16422
10022 5653
16583 4345
15330 4920
14975 7319
17727 3447
7757 10335
13203 587
7859 10120
13743 6744
9633 1217
2354 15395
2637 644
3446 5764
10655 6936
2997 15428
11211 269
7061 14102
8473 4726
3667 3846
10197 14460
1997 14856
7131 2824
12180 16...

output:

1
820625487
0
0
0
0
0
0
0
1
8796723
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
599216008
0
1
623002994
0
0
0
0
0
0
0

result:

ok 49 numbers

Test #146:

score: 0
Accepted
time: 584ms
memory: 36796kb

input:

47
6104 20129
1558 778
4223 3353
2889 540
2990 3293
5824 1771
598 5432
3638 4429
3346 2943
4860 5336
5922 1221
4682 3984
3888 921
5468 1604
4229 1172
4830 5325
4840 4742
5705 4271
2725 2064
1844 2556
1351 3234
3349 4626
5293 3028
804 4016
1050 2664
1900 3563
1512 2810
1174 1364
2680 296
180 4312
447...

output:

0
1
523995930
0
0
0
0
0
0
1
575259494
1
926359592
0
0
0
0
0
1
623878431
0
0
1
109693328
0
0
0
0
1
440992145
0
0
0
0
0
0
1
559557223
1
570291648
1
995198837
0
0
0
0
1
770673572
0
0
0
0
0
0
0
0
0

result:

ok 57 numbers

Test #147:

score: 0
Accepted
time: 607ms
memory: 37168kb

input:

41
14519 23833
12342 9248
3320 6335
1198 13231
4433 12432
7830 4718
380 13800
11618 3221
12083 7395
14056 2217
11330 301
1931 12449
9089 12097
8613 12640
13597 5704
5302 5387
13578 3624
1457 10898
11246 9135
3742 10348
9260 12210
7115 2711
4462 9051
4914 2862
9209 5647
2950 7492
6006 12336
4737 4598...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
404213037
0
0

result:

ok 42 numbers

Test #148:

score: 0
Accepted
time: 628ms
memory: 36668kb

input:

44
6478 24647
4836 4443
1640 5400
2628 688
5163 810
997 3644
655 2816
2339 2682
5660 971
1112 4481
1917 3983
2963 6467
1464 1875
5272 2071
6000 3007
1546 2928
2391 5511
5196 5465
1325 1999
3643 5079
4374 1347
5324 818
2903 2788
933 4480
2613 2262
693 2547
4962 647
4589 298
3763 2504
2921 3074
1672 1...

output:

0
1
872284526
0
0
0
0
1
216207580
0
1
638628067
0
0
0
1
85232456
0
1
464889213
1
935788424
1
167364023
0
0
0
0
0
0
0
0
0
0
0
0
1
352708546
0
0
0
0
0
0
0
0
1
659466056
0
0
1
981139173
1
577055967
0

result:

ok 55 numbers

Test #149:

score: 0
Accepted
time: 904ms
memory: 66324kb

input:

8
4006 75804
3436 3970
398 204
3242 3761
466 1540
3897 546
2811 2029
2951 2988
1772 635
2868 993
876 3366
408 3595
2784 2069
2256 3138
2202 3939
766 2839
3411 2682
3072 1067
1173 3086
2505 1136
2202 3939
3767 3633
2527 3882
3633 3810
842 3223
2821 2643
3122 2172
2163 27
3536 2437
1260 864
2112 638
2...

output:

0
0
0
0
0
0
0
1
334799885

result:

ok 9 numbers

Test #150:

score: 0
Accepted
time: 777ms
memory: 70640kb

input:

9
8748 40073
893 4155
7026 4759
7162 3859
1437 1508
6951 5587
8553 7487
2669 8342
1567 1465
8678 7103
7943 3824
7193 5519
5949 7123
7709 128
1730 609
4908 3630
3645 8719
4395 4633
681 7012
2541 3074
1326 1238
8126 3467
8424 6982
2771 4036
1185 4223
4230 3133
2174 6127
3238 1455
4440 8476
1208 7250
7...

output:

0
0
0
1
802644146
0
0
0
0
0

result:

ok 10 numbers

Test #151:

score: 0
Accepted
time: 896ms
memory: 110536kb

input:

3
171784 380710
26752 49644
58219 94553
122058 1523
56644 109727
16451 167785
32320 111091
77463 108201
117552 167303
42998 79946
60553 63342
158145 149169
38261 154204
103768 52191
89879 116719
165737 119968
71997 89906
119613 119344
66435 99385
149372 114147
46877 38697
20628 26808
106106 100003
2...

output:

0
1
201871985
1
383236700

result:

ok 5 number(s): "0 1 201871985 1 383236700"

Test #152:

score: 0
Accepted
time: 959ms
memory: 70648kb

input:

6
82182 272868
46281 10573
69960 55488
28885 20353
51675 19579
23692 58192
77386 59130
32719 78783
48829 6063
60585 72187
19496 12712
23997 22269
49925 74543
49933 38062
16228 361
11848 65717
38481 32087
17313 17150
36109 25350
71885 40513
16760 6840
32624 30616
13078 19130
21707 12839
37698 37035
3...

output:

0
0
0
0
0
0

result:

ok 6 numbers

Test #153:

score: 0
Accepted
time: 233ms
memory: 27412kb

input:

4016
92 244
45 54
83 84
72 58
44 33
41 64
23 85
51 36
48 46
85 59
28 83
88 19
49 54
75 47
91 16
81 2
31 73
38 37
84 47
3 36
2 48
69 9
12 88
21 5
43 36
52 32
31 11
11 44
80 39
14 31
34 25
88 21
38 26
90 61
68 60
71 44
40 92
10 5
82 84
71 50
76 16
88 66
10 50
26 79
32 73
20 4
49 6
70 3
48 17
55 76
30 ...

output:

1
290717512
1
473045812
1
360005437
1
661380469
0
0
0
0
1
123
1
252538048
1
29892659
1
893067721
1
76560842
1
603289729
2
12 21
1
4371562
0
0
0
2
12 21
1
414091876
1
52173864
1
757655876
1
197855198
1
295826535
0
1
906621727
0
0
0
0
1
35659190
0
1
436981180
1
789563935
1
311115253
0
1
21574836
0
0
0...

result:

ok 5893 numbers

Test #154:

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

input:

3975
81 379
56 29
37 30
53 81
78 12
21 1
67 6
33 58
48 71
63 80
38 46
49 7
69 18
2 24
26 4
80 18
46 38
73 9
2 73
77 49
21 30
74 28
10 16
37 78
71 1
36 6
50 49
20 9
6 45
31 19
73 7
78 23
62 68
35 31
31 42
2 66
73 33
2 49
39 20
36 68
33 78
24 45
73 62
32 20
11 74
54 34
48 55
47 26
63 22
5 81
2 24
43 2...

output:

0
1
443258683
1
838121229
1
103966850
1
213456
1
61752438
1
18585529
1
592998681
1
747808949
0
1
975246696
0
1
342296551
1
923313017
0
0
1
585118303
1
606737406
1
762096520
1
367925217
1
522662346
1
525497666
0
1
205422631
0
1
932715037
1
581829319
1
986494197
0
0
0
0
1
45327816
0
0
1
532392606
1
93...

result:

ok 6172 numbers

Test #155:

score: 0
Accepted
time: 352ms
memory: 28552kb

input:

410
1722 3378
698 966
1091 1391
125 328
942 1146
1492 1695
1009 770
841 409
1222 1045
767 56
677 930
811 658
1163 5
1125 190
1320 1126
1299 200
1156 41
1262 974
828 1153
500 858
1061 1501
349 1322
553 1259
1465 485
1438 214
859 390
742 1519
1505 60
162 740
1477 1308
1213 1709
716 859
547 1132
1011 1...

output:

0
0
0
0
0
0
0
1
109047164
0
0
0
0
0
0
0
0
0
0
1
400242374
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
465260316
0
0
0
0
0
0
0
1
744229784
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
3136718
0
0
0
0
0
0
0
0
1
531716796
0
0
0
0
0
1
826397514
0
0
1
951555960
0
0
0
1
704090677
0
0
0
0
0
0
0
0
0
0
1
536892...

result:

ok 558 numbers

Test #156:

score: 0
Accepted
time: 341ms
memory: 28552kb

input:

400
1071 2037
649 294
315 1031
506 663
497 55
781 234
34 55
967 611
562 918
1013 620
858 359
722 452
463 492
409 746
472 296
685 917
350 1039
507 1054
321 222
1035 127
240 241
754 332
559 983
337 239
493 113
541 175
608 307
395 760
300 830
163 290
94 446
532 957
795 483
28 649
743 727
194 400
218 52...

output:

0
1
433433257
0
0
0
0
0
0
1
726945528
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
147211407
0
3
687684371 811593917 890226865
0
0
0
1
745764228
0
0
1
7461523
0
0
0
0
0
0
0
1
948576416
1
480613300
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
802950...

result:

ok 435 numbers

Test #157:

score: 0
Accepted
time: 560ms
memory: 38208kb

input:

35
10158 32705
496 1864
5382 8215
314 3977
4970 7864
6568 5894
268 8795
4537 7289
9401 5050
4685 2341
8115 1914
1944 3919
5033 5509
4255 5694
8763 393
3120 5805
794 5918
660 8809
6549 8876
1892 7394
4668 6975
2634 2721
7011 9916
1877 5554
4291 1415
8139 2772
4785 9249
9084 5289
5679 5027
6838 2428
6...

output:

0
0
0
0
0
0
0
0
0
2
915049630 940030960
0
0
0
0
1
606250922
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
244147505
0
0
0

result:

ok 39 numbers

Test #158:

score: 0
Accepted
time: 619ms
memory: 36572kb

input:

45
9396 26839
3134 9097
8860 1668
2086 1747
2774 5587
6202 4790
5631 1952
4026 6450
7464 3188
4578 2139
6568 3299
3350 6724
2197 3593
5160 9079
4488 5241
5776 3442
6140 4665
1837 3863
7711 192
8730 7185
1311 5728
349 4882
8603 1113
2312 4451
5875 1811
8159 6179
2434 8327
2865 199
1396 3440
355 8268
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 45 numbers

Test #159:

score: 0
Accepted
time: 1331ms
memory: 123976kb

input:

3
172603 407417
26017 14245
72889 47569
89501 85016
39646 50365
149470 107070
63808 109344
156449 171985
7882 60271
85029 102145
155397 103476
21105 142290
153719 111564
158334 123534
61830 82936
60647 135879
76509 169685
143666 24223
24703 82947
79097 135695
74635 89843
134748 23984
97648 57898
104...

output:

0
0
0

result:

ok 3 number(s): "0 0 0"

Test #160:

score: 0
Accepted
time: 725ms
memory: 83440kb

input:

4
62693 136378
41953 33931
56456 2949
18770 48572
61776 7749
56887 16816
45154 21227
8878 7345
22818 11163
36244 59265
22712 13633
19204 20303
4411 30629
24303 52882
3769 11819
16870 14070
36234 18583
5728 37367
41272 53440
20932 10431
44033 56074
21496 49982
29098 44052
14326 42130
56942 26244
2581...

output:

0
0
0
0

result:

ok 4 number(s): "0 0 0 0"

Test #161:

score: 0
Accepted
time: 201ms
memory: 27396kb

input:

4815
173 184
83 11
166 101
1 154
122 93
78 47
109 100
98 24
58 144
9 27
127 172
122 163
65 37
97 20
87 109
86 157
11 35
68 69
3 8
26 118
131 149
126 117
142 131
173 95
23 158
88 173
90 52
157 114
17 4
132 103
35 168
82 112
71 97
158 160
150 124
156 134
99 53
15 122
21 14
20 160
79 75
36 33
60 54
8 9...

output:

2
176454834 831302977
6
126543 265431 312654 431265 543126 654312
2
265358744 325311751
2
14462301 362146041
2
944898372 559548567
2
372191594 996008770
2
948542270 746096919
2
561169663 407169379
2
437457409 766026346
2
48949037 311332834
188
586424791 169132685 283459211 543668588 42682458 2559386...

result:

ok 29905 numbers

Test #162:

score: 0
Accepted
time: 201ms
memory: 27380kb

input:

4874
110 132
36 18
50 81
20 66
26 82
54 44
44 70
59 57
84 90
45 48
71 34
97 109
10 30
101 68
17 28
23 8
40 106
60 54
29 42
41 107
51 53
89 64
25 2
82 50
64 16
108 87
43 19
98 58
96 93
27 7
92 73
63 85
62 104
8 6
75 19
66 80
81 73
77 107
7 95
106 72
102 35
39 94
48 83
32 49
38 15
77 60
29 5
99 105
9 ...

output:

2
997914501 666558382
2
727753773 834059892
2
49763843 31016647
2
780608606 991412873
2
626977278 148760488
2
968477156 783308685
2
430230199 579858773
2
243562197 61791105
2
74829137 529174798
2
474827629 845186453
2
334224271 715191514
70
537491039 360014999 684882281 365931525 496374693 899145497...

result:

ok 29655 numbers

Test #163:

score: 0
Accepted
time: 313ms
memory: 28184kb

input:

495
1190 1194
196 756
840 137
904 1047
568 870
384 403
664 293
958 815
990 741
421 1060
671 580
863 131
417 933
379 651
21 569
1075 124
606 884
259 643
843 47
96 674
724 1089
395 996
851 436
997 72
591 1144
42 519
945 949
821 730
611 457
515 28
735 87
537 65
1189 85
409 895
563 1118
447 551
224 534
...

output:

2
953079749 694811913
2
290005138 401693272
794
286432111 684796149 794396718 256929792 991612387 580930827 484852852 198892004 770846647 696001754 673531673 823652 937646184 787677320 320435056 187663083 682126214 750966735 581578198 826435590 510763106 69499678 979960841 871809381 355852091 863053...

result:

ok 95871 numbers

Test #164:

score: 0
Accepted
time: 305ms
memory: 28152kb

input:

497
184 188
89 34
63 70
168 88
117 11
106 167
149 123
184 176
22 150
34 175
93 155
38 51
32 94
132 127
115 112
121 34
43 35
100 55
37 124
8 79
121 7
19 73
27 57
141 39
180 116
17 159
7 23
31 133
142 52
138 2
59 135
98 132
147 146
58 121
61 38
112 170
171 174
51 8
4 108
65 75
154 68
120 162
56 60
153...

output:

2
949920520 684162623
2
22406945 97259102
2
115600691 737604793
2
464781478 557151944
2
568417583 8288682
2
214440292 581928055
2
941657488 328341458
2
209979879 988701805
2
83196343 18959072
2
270520407 896177579
2
281467225 467038649
2
230296996 582774615
2
165698420 70616423
2
487123795 301973839...

result:

ok 13789 numbers

Test #165:

score: 0
Accepted
time: 527ms
memory: 36472kb

input:

44
12388 12388
5641 9902
3196 7592
3064 2221
10213 9707
10307 905
7552 7619
4689 6236
10690 6706
3698 3488
7839 2802
6592 3733
8820 12283
3556 9076
2000 7731
3439 3452
318 8930
1529 8021
9867 6608
7883 10905
7294 4659
8938 1287
9468 7236
3393 2517
1168 5943
7551 9476
2342 6532
4805 11654
5252 10734
...

output:

12388
186662495 602220990 287554869 315150467 983286825 956397079 269553159 615349810 113547082 966643506 628098847 24891792 708678918 208197380 672904586 850604802 791385794 419485413 191909580 558311572 886305994 520262318 912902805 277728871 86479517 880370729 836283344 258755093 624633035 530464...

result:

ok 210108 numbers

Test #166:

score: 0
Accepted
time: 513ms
memory: 36064kb

input:

49
8022 8026
3626 2377
3992 7382
5722 4478
5267 6894
3804 1913
4292 6020
1593 485
5977 1335
5615 2983
6831 3296
1296 6465
5827 5030
4095 2305
6760 3212
690 2723
5706 861
2444 1379
6435 5508
6678 6566
1797 2573
1748 5970
6239 8006
1784 5243
5757 1634
5272 1644
114 1181
2043 270
6386 1550
1030 3479
29...

output:

2
163698217 298364438
2
77739966 548158429
2
676539503 671707675
2
336680394 129495114
15483
574606808 975102527 436863566 264538481 933719684 737704343 188875025 426764136 680522337 60601623 822448012 677150561 135547164 368755579 526773185 968847478 710762190 268769116 752354419 702366150 30660301...

result:

ok 37052 numbers

Test #167:

score: 0
Accepted
time: 935ms
memory: 88728kb

input:

7
128129 128130
50048 100813
111942 26980
60952 119728
24718 23582
114246 9219
105037 111837
72604 106169
48960 66088
119772 27802
21174 37522
113208 63413
125383 6370
11312 4150
120815 24408
71801 37161
68600 100816
52221 53108
44859 13111
46927 7551
113546 92660
66791 79721
111614 26273
106466 140...

output:

2
507195006 63098071
2
44354153 638011786
2
813771341 181599311
2
725149072 884533642
2
244164812 12526901
2
535975084 448108076
2
308509581 507914069

result:

ok 21 numbers

Test #168:

score: 0
Accepted
time: 768ms
memory: 114964kb

input:

3
32302 32319
2478 8790
26889 13794
31069 27411
7767 22957
5080 22796
11562 11963
12002 7549
4946 1408
11637 32024
16171 27412
5191 3857
15919 25741
22398 6346
27112 4697
16038 29680
27015 31360
1808 31906
19393 29376
9991 28603
26704 23322
15065 30192
6457 27950
1037 28952
6796 21790
23538 28662
26...

output:

2
312727701 514366758
2
366402319 325791765
2
322967431 268851804

result:

ok 9 numbers

Test #169:

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

input:

4876
82 85
3 51
52 55
57 74
22 60
55 77
32 20
59 31
68 1
39 43
69 76
56 43
36 10
24 42
75 25
73 40
8 58
37 72
47 22
23 19
78 37
45 27
18 26
16 46
46 3
60 35
6 44
7 66
79 11
42 23
62 61
50 67
4 15
28 47
17 16
15 69
44 71
33 54
48 53
43 12
29 49
2 41
2 28
61 32
53 75
64 2
67 56
51 80
30 65
77 82
65 78...

output:

2
784780390 414501307
10
835057685 183505755 505769197 57692148 769218315 921835015 692183456 350576865 218350513 576921764
2
148637559 352213601
17
242721711 329142725 414272175 713129150 691427224 451312920 655131299 127217090 508555139 872170866 721708565 917085563 355513137 570855523 385551322 2...

result:

ok 143291 numbers

Test #170:

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

input:

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

output:

2
151042619 425006228
2
469887746 230173873
2
578958265 2048836
18
119180393 311918051 212651331 377872156 265131225 126513152 803778767 787212701 131191849 721265186 872126577 513119246 37787278 651311996 778721347 918037879 180377959 191803875
2
668975591 59076483
2
198133502 50470419
2
383368094 ...

result:

ok 144197 numbers

Test #171:

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

input:

491
358 387
213 105
107 104
341 208
149 352
236 269
165 110
85 303
26 323
50 241
249 76
56 168
209 83
231 174
257 172
269 107
35 282
238 120
98 30
130 97
340 152
290 50
297 274
313 45
251 2
321 349
287 64
117 284
105 218
308 92
18 125
255 148
27 18
40 204
47 354
153 178
286 266
327 35
68 358
65 112
...

output:

2
949453283 690238268
2
751410075 236005414
2
152289773 538280970
2
917763157 132430984
2
909643908 60614811
2
31530684 225039445
2
794281998 684206104
2
117172679 484629752
2
841003007 797099256
2
369278413 79253343
2
191468952 220478279
2
370457767 589477456
2
804029768 312259968
2
129865176 97232...

result:

ok 10981 numbers

Test #172:

score: 0
Accepted
time: 304ms
memory: 28176kb

input:

498
285 301
240 150
183 92
187 121
97 243
123 37
280 211
83 136
125 167
18 270
168 164
262 123
265 139
100 241
163 281
34 69
128 264
143 284
69 230
268 17
9 182
88 206
195 246
173 112
28 277
126 214
2 223
199 25
184 133
175 56
57 165
269 4
72 28
113 206
44 106
106 49
87 95
220 276
73 212
145 268
176...

output:

2
873567325 300832877
2
649074239 658334915
2
144682404 456349418
2
723974422 958998687
2
240370167 569092458
2
830350345 66851372
2
836815076 380297173
2
756398385 973482828
2
234691433 64853161
2
151252742 777926599
2
702264643 331138113
2
115123427 954310753
2
302947776 316600584
2
584691094 8543...

result:

ok 12645 numbers

Test #173:

score: 0
Accepted
time: 422ms
memory: 35032kb

input:

54
7475 7642
5371 6192
4764 2847
980 5100
5647 1810
349 7144
6463 719
7039 3568
4916 4235
831 3305
1578 4851
1963 2471
7085 4180
1790 4602
2704 2035
6380 2011
6016 2466
3097 407
1155 3147
3502 6395
3299 264
6679 86
5097 1486
6970 7056
303 243
7323 2525
2535 6825
2022 2283
2548 2910
586 3674
692 2263...

output:

2
203318927 756004462
2
823092448 57309229
2
478558907 437099813
2
344779926 501032934
2
519302827 589498281
2
390339207 49533727
2
80882807 44640029
2
276443348 425632997
2
864626911 547315470
2
874241735 627596979
2
390685349 998439843
2
678779893 141520713
2
761156834 514148566
2
676249460 930401...

result:

ok 162 numbers

Test #174:

score: 0
Accepted
time: 435ms
memory: 35692kb

input:

48
13166 13448
6229 11108
6281 8449
9398 3844
8106 10487
1975 6066
10878 3148
1039 902
6737 8995
467 3630
10592 1414
12471 12474
3548 1306
12677 8080
7030 12777
6849 281
10574 284
7784 7409
11910 10812
12074 8165
8413 5529
911 6147
1482 8869
7140 6618
5092 2943
10149 10662
3461 12589
4754 9076
3671 ...

output:

2
901014735 16652090
2
615396945 558023994
2
219436635 744266981
2
902084168 556717669
2
326357442 551288317
2
484811591 539538201
2
665943198 342925083
2
189425285 177723088
2
629651172 679213203
2
769278545 676992177
2
779212493 437064453
2
491663770 752391204
2
311169021 675607486
2
57758881 4728...

result:

ok 144 numbers

Test #175:

score: 0
Accepted
time: 702ms
memory: 86184kb

input:

4
81679 82336
77877 59183
81470 32897
76217 2584
30817 62800
66701 50732
38256 73054
37604 39829
7969 28881
70397 21371
68821 35258
80607 54760
26254 32009
20093 54524
19413 20994
31382 659
56377 74862
75769 30644
56407 69222
65787 70447
65188 35870
65182 13068
60896 3698
48757 64399
37808 30303
702...

output:

2
312106830 234429087
2
754500782 321207359
2
80258469 5149080
2
462550221 819513513

result:

ok 12 numbers

Test #176:

score: 0
Accepted
time: 816ms
memory: 97004kb

input:

7
100850 102561
97365 1433
56193 29528
47089 90426
55882 87241
97671 42367
34439 90493
87618 24979
47974 88902
82757 11856
53804 80703
57286 22583
85672 3817
24419 57647
90638 95372
78400 69986
4642 82415
34764 24049
91869 39876
40506 11760
37806 29795
100740 24614
62714 86869
99630 46730
22419 3432...

output:

2
84962146 956089563
2
946646823 85179119
2
851901464 554554865
2
923038926 76003716
2
150490955 396361133
2
598835136 66321460
2
949266568 417602842

result:

ok 21 numbers

Test #177:

score: 0
Accepted
time: 295ms
memory: 27488kb

input:

4954
5 189
1 4
1 2
1 4
1 4
1 4
1 4
2 4
1 2
1 4
1 5
2 4
1 2
1 2
1 4
1 4
1 2
1 2
1 2
1 4
1 2
1 4
1 4
2 4
1 2
2 4
1 4
2 4
1 4
1 2
1 4
2 4
1 2
2 4
2 4
2 4
1 2
1 2
2 4
3 4
1 2
1 2
2 4
2 4
1 4
1 2
2 4
1 2
2 4
1 2
2 4
1 4
1 2
2 4
2 4
1 2
2 4
2 4
2 4
2 4
1 4
1 4
1 2
1 4
1 2
1 2
1 4
2 4
2 4
1 4
2 4
2 4
1 4
1...

output:

3
34215 42153 53421
2
930305941 231369485
2
33306490 985489527
2
183381974 671216361
2
181280286 12444932
2
2891192 938111697
2
64308831 205273477
2
508617837 154977508
2
115700662 840511142
2
794384137 860980709
2
888258875 78087592
2
205044454 15230870
2
797915865 664144829
2
2266265 989770098
2
6...

result:

ok 17799 numbers

Test #178:

score: 0
Accepted
time: 276ms
memory: 27452kb

input:

4922
178 226
45 173
50 79
67 164
152 110
107 138
16 101
49 87
63 112
31 28
110 175
164 5
80 159
9 171
44 42
102 124
21 100
105 6
1 111
176 91
18 32
13 168
97 146
80 106
90 105
93 6
99 30
128 15
66 131
35 147
34 92
96 84
38 141
41 134
1 54
20 172
92 63
77 102
43 61
175 106
173 174
86 29
39 149
11 76
...

output:

2
479056426 618970712
2
940763268 61620564
2
133479048 977566362
2
498890172 59148409
2
498266348 218938569
2
361231023 366322235
2
706519032 22425757
2
129243146 58980587
2
852329574 382032080
2
269719888 967700354
2
165767137 558087043
2
37497868 937743321
2
278192595 996574052
2
958175523 4842851...

result:

ok 31365 numbers

Test #179:

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

input:

4878
72 91
54 18
66 63
66 30
32 70
42 71
49 54
16 6
69 32
19 38
69 27
44 27
67 41
2 52
28 4
13 6
34 19
58 31
63 26
37 14
8 20
53 33
25 71
65 41
72 41
20 35
3 34
30 10
11 25
64 7
7 18
10 68
59 16
1 57
47 43
62 55
51 28
7 29
61 60
26 37
41 72
50 49
70 3
48 36
12 56
45 1
33 65
71 25
56 8
55 42
4 23
9 2...

output:

2
747382113 558286246
2
647692587 250273705
22
545929098 360848262 290013754 667195876 438997797 206235534 581339444 542467582 925109637 196349546 267544395 972704329 49099683 191264774 385613712 683859184 2603938 852573430 288621777 646853143 723378136 794201497
2
279943292 421342497
2
187549238 17...

result:

ok 21354 numbers

Test #180:

score: 0
Accepted
time: 276ms
memory: 27460kb

input:

4921
163 202
135 142
99 75
89 95
143 94
108 81
117 125
149 82
23 11
80 31
63 76
158 161
144 3
44 18
33 82
12 120
120 43
94 97
155 148
126 103
104 38
11 23
20 155
93 142
121 118
38 66
49 17
30 109
112 133
10 54
149 65
163 89
109 156
83 21
147 24
62 4
23 27
7 125
128 117
94 33
153 84
83 96
26 157
84 1...

output:

2
837564806 219591538
2
743905540 442248952
2
597998976 279128781
2
532631282 279695517
2
618793421 223310056
2
508790135 360419691
2
854434872 814395981
2
123409789 16178388
2
129614499 557828493
2
741689291 725338352
2
287495923 571798461
2
592642376 292186948
2
402049764 680487575
2
502281549 726...

result:

ok 19988 numbers

Test #181:

score: 0
Accepted
time: 407ms
memory: 28620kb

input:

516
547 1091
517 532
226 209
354 248
133 487
275 6
331 408
316 123
394 247
32 249
125 370
100 87
183 432
393 148
269 428
441 363
456 379
313 286
260 280
358 519
8 52
242 170
235 326
351 338
351 424
488 70
388 381
154 467
255 66
127 302
507 399
62 306
266 314
322 421
100 219
406 358
425 107
84 33
30 ...

output:

2
960888379 701768375
2
769403541 390489130
2
469009983 244595844
2
302562003 724445841
685
957226192 661640958 126503861 794910050 775822533 286874434 550913284 558888752 126880345 124954640 674606606 595482917 639771267 892354252 8236254 397838838 204550542 35951748 648346527 775720945 529348642 3...

result:

ok 22060 numbers

Test #182:

score: 0
Accepted
time: 420ms
memory: 28400kb

input:

480
1555 3049
1377 496
452 1105
487 875
1318 958
597 1189
1372 1542
758 1465
620 301
1154 742
517 1530
177 935
1292 580
1063 266
44 165
1509 304
1390 127
1422 132
255 741
883 810
1188 1285
399 885
31 1257
1488 767
268 886
892 1171
833 772
782 1205
1386 582
1259 762
1177 98
1482 466
475 30
982 397
16...

output:

2
644947139 360857524
2
623725936 490294257
2
693258645 618884650
2
896032095 848959209
2
908192472 909880154
2
278757197 566426928
2
255821808 172729449
2
958650691 786414777
2
110955843 159576755
2
428173461 236745635
2
950069446 49580170
2
928494955 75816608
2
234887196 329874930
2
668587799 7062...

result:

ok 3435 numbers

Test #183:

score: 0
Accepted
time: 399ms
memory: 28596kb

input:

499
1852 2031
574 1178
1271 1310
1848 1329
38 312
1138 612
746 1548
1102 676
774 379
1562 516
980 552
1011 1721
1623 103
1089 1843
555 1476
161 927
1192 1179
253 1330
801 1227
342 362
578 1233
688 562
471 932
675 1612
1300 1542
155 20
1474 1287
127 914
682 417
802 842
108 1844
947 338
579 205
296 91...

output:

1467
79231459 205254333 886240304 672148468 139785505 971672098 321624116 86061104 628346038 935630261 114899399 512479347 42520681 521698654 41577659 439207899 638609010 910036642 462669718 251319242 552991888 195506793 94457492 478100304 247962573 656432781 182257261 513305285 675857503 808412123 ...

result:

ok 20274 numbers

Test #184:

score: 0
Accepted
time: 388ms
memory: 28376kb

input:

486
1804 1934
1163 1684
432 101
751 1455
1319 1470
1072 1586
665 1110
184 482
1012 269
808 935
1425 154
1506 1045
86 114
1501 1170
729 1444
529 686
103 580
614 880
1538 328
536 1196
304 57
1673 620
649 452
1794 1625
605 34
380 2
1733 30
947 1596
1111 894
709 1247
904 607
874 1452
953 1250
463 1120
8...

output:

2
374968396 914128553
2
354628796 335586540
2
461380115 735731025
2
749855770 939948252
2
798497735 803656254
2
880336927 377759378
2
841157507 404040157
2
26475630 624926502
2
284124307 762218510
2
557420750 483603488
2
133187300 81727162
2
915023484 955470339
2
689284905 525398621
2
643052284 6236...

result:

ok 10355 numbers

Test #185:

score: 0
Accepted
time: 707ms
memory: 37588kb

input:

46
1369 12163
935 863
75 1217
1104 502
429 450
18 964
662 1064
1312 181
572 104
935 1142
1252 417
1165 135
1003 768
339 990
661 395
1309 30
507 1262
461 227
243 1027
985 572
199 267
1064 1255
478 294
1266 632
304 494
1327 875
930 1348
1282 413
1196 1358
906 624
390 881
339 784
637 244
1237 470
204 5...

output:

2
785269719 620297421
2
718956232 676586140
2
955312657 210223783
2
546324048 22091850
2
353487992 862050306
2
905845481 463826953
2
881762175 477391982
2
741329070 563445132
2
84472929 714283665
2
404377036 847029648
2
537483805 608095175
2
958904720 364297820
2
193694512 534510017
2
329764590 8659...

result:

ok 1185 numbers

Test #186:

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

input:

51
18320 34916
12061 559
7395 14150
7819 9490
1425 10578
6857 926
10282 12174
7371 1112
5059 3123
7043 17951
2655 13408
131 8577
8083 2221
5017 11659
8363 3497
9460 16884
4685 13231
14795 15715
13808 15395
5450 2085
10172 10071
14924 12898
10540 2687
15791 5014
7609 8061
5513 16582
1766 739
17832 94...

output:

2
477647232 178630472
2
991337262 2530992
2
871088083 867722214
2
27495263 836427659
2
267632757 570932174
2
649241024 996144176
2
778464908 513850923
2
660916586 416029558
2
276269993 331756185
2
669133736 802867734
2
729560786 528749038
2
244371887 307283880
2
898817623 591263463
2
307476318 17678...

result:

ok 3969 numbers

Test #187:

score: 0
Accepted
time: 713ms
memory: 37276kb

input:

47
15939 25206
6038 9756
15352 2017
11788 12171
1035 14929
7625 12504
5238 6619
11377 8586
12063 858
849 8872
2558 13215
10836 10092
13654 3494
1399 12090
1739 5747
7142 11991
8679 5798
13800 14150
10516 679
6559 15647
705 15333
10872 1029
1055 1434
15546 15781
14256 1774
12408 8012
5476 5295
2275 8...

output:

2
591567820 304001325
2
513222946 231425449
2
236307021 494798377
2
337825981 782264090
2
835317298 61444470
2
573245535 874699543
2
177310155 678994106
2
928409015 661164069
2
530061895 432540609
2
104314747 660424909
2
520148911 672740585
2
415540145 448876583
2
238708810 629578010
2
632909433 803...

result:

ok 4954 numbers

Test #188:

score: 0
Accepted
time: 733ms
memory: 36900kb

input:

45
6630 21591
1014 6434
1649 448
3217 4469
1023 591
6121 6469
3441 2750
6538 3440
952 2840
1408 4578
5833 6266
6196 2758
708 4020
3865 99
2351 4061
1715 5065
5408 3525
2531 3779
2245 5307
1593 1615
4154 2277
1735 2271
1934 487
5641 6497
1331 3672
4465 5008
2920 2492
1642 2270
6547 681
1800 4120
4179...

output:

2
389876973 547876743
2
864040793 189035567
2
638624228 322658463
2
255336569 993877462
2
495971149 100055350
2
228264995 332470084
2
469816706 967431569
2
42143039 658820060
2
165037712 633575971
2
775932269 430331496
2
639375713 18319538
2
795657894 312561511
2
373961128 936582551
2
806393724 8523...

result:

ok 135 numbers

Test #189:

score: 0
Accepted
time: 989ms
memory: 64240kb

input:

9
74416 112295
67119 19815
67756 69078
37026 72290
1283 30777
52075 65274
34031 58024
49490 37641
55317 18170
48449 59331
2300 21597
19011 37171
4913 115
7578 13587
35919 64035
31111 50006
57507 367
6667 16388
45234 11098
22249 29609
45188 27020
41528 50019
13991 17285
57922 43558
68549 19388
50540 ...

output:

2
618492250 700625312
2
92898817 329941168
2
546206521 633832967
2
782962717 539567798
2
464898756 74350139
2
651272011 938089405
2
401346286 493603090
2
316162857 336154848
2
729552161 143411565

result:

ok 27 numbers

Test #190:

score: 0
Accepted
time: 1109ms
memory: 72232kb

input:

8
83258 113949
43544 42418
54235 69409
5395 78254
983 3109
38905 50315
39504 19140
36883 5639
11296 23984
238 19216
5824 38779
11816 79222
63804 78745
10287 17169
18495 25037
79251 44067
76553 25845
31273 73236
8620 47137
26654 41939
62696 42575
21567 28676
62735 10799
61142 79502
40949 60684
51494 ...

output:

2
951496053 85134238
2
666104225 201156689
2
786270645 965137439
2
516858479 892654295
2
686719113 145544193
2
673068272 171777442
2
759987864 514542579
2
646394097 571096394

result:

ok 24 numbers

Test #191:

score: 0
Accepted
time: 1118ms
memory: 94592kb

input:

5
129063 302401
58248 54160
5435 29383
40647 53290
4944 100526
51417 104722
72486 90074
60285 57670
117039 71644
32892 66652
58538 38428
74551 49658
68820 128476
88848 24140
123699 124538
121104 8714
120868 37256
19666 64766
57591 10645
58006 81556
33739 31136
65213 111272
107508 41508
103602 117315...

output:

2
85742167 206522547
2
450211266 916666922
2
450874058 421775610
2
997439287 299411081
2
922391057 715394272

result:

ok 15 numbers

Test #192:

score: 0
Accepted
time: 1325ms
memory: 120012kb

input:

4
131479 179879
13149 121989
32702 48775
27085 91087
9391 21852
69007 56220
129708 27515
15822 74848
42795 69360
31226 16992
33201 6469
70612 105884
22734 41190
97239 3524
114867 103561
14242 30287
124392 51763
47590 60774
50869 95745
90512 17212
75372 35003
123756 81240
116070 33735
118733 119156
4...

output:

2
489365272 270937007
2
577696365 275641357
2
200173651 700343312
2
583714621 779405482

result:

ok 12 numbers