QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630519#8700. Tree Automorphismshos_lyricAC ✓1ms4116kbC++144.2kb2024-10-11 18:59:122024-10-11 18:59:13

Judging History

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

  • [2024-10-11 18:59:13]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4116kb
  • [2024-10-11 18:59:12]
  • 提交

answer

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

using namespace std;

using Int = long long;

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


int N;
vector<int> A, B;

vector<vector<int>> graph;
vector<int> sz;

void dfsSz(int u, int p) {
  for (const int v : graph[u]) if (p != v) {
    dfsSz(v, u);
    sz[u] += sz[v];
  }
}

int H;
map<vector<int>, int> ids;
vector<int> dp;
vector<vector<int>> subtree;
vector<vector<int>> ans;

vector<int> identity() {
  vector<int> perm(N);
  for (int u = 0; u < N; ++u) perm[u] = u;
  return perm;
}
void sw(vector<int> &perm, int u, int v) {
  assert(subtree[u].size() == subtree[v].size());
  for (int j = 0; j < (int)subtree[u].size(); ++j) {
    swap(perm[subtree[u][j]], perm[subtree[v][j]]);
  }
}

void dfs(int u, int p) {
  vector<pair<int, int>> hvs;
  for (const int v : graph[u]) if (p != v) {
    dfs(v, u);
    hvs.emplace_back(dp[v], v);
  }
  sort(hvs.begin(), hvs.end());
  const int hvsLen = hvs.size();
// cerr<<u<<" "<<p<<": "<<hvs<<endl;
  for (int j = 0, k = 0; j < hvsLen; j = k) {
    for (; k < hvsLen && hvs[j].first == hvs[k].first; ++k) {}
    // permute us[j, k)
    if (k - j >= 2) {
      auto perm = identity();
      sw(perm, hvs[j].second, hvs[j + 1].second);
      ans.push_back(perm);
    }
    if (k - j >= 3) {
      auto perm = identity();
      for (int l = j; l < k - 1; ++l) sw(perm, hvs[l].second, hvs[l + 1].second);
      ans.push_back(perm);
    }
  }
  
  vector<int> hs(hvsLen);
  for (int j = 0; j < hvsLen; ++j) hs[j] = hvs[j].first;
  if (!ids.count(hs)) ids[hs] = H++;
  dp[u] = ids[hs];
  
  subtree[u] = {u};
  for (const auto &hv : hvs) {
    const int v = hv.second;
    subtree[u].insert(subtree[u].end(), subtree[v].begin(), subtree[v].end());
  }
}

int main() {
  for (; ~scanf("%d", &N); ) {
    A.resize(N - 1);
    B.resize(N - 1);
    for (int i = 0; i < N - 1; ++i) {
      scanf("%d%d", &A[i], &B[i]);
      --A[i];
      --B[i];
    }
    
    graph.assign(N, {});
    for (int i = 0; i < N - 1; ++i) {
      graph[A[i]].push_back(B[i]);
      graph[B[i]].push_back(A[i]);
    }
    sz.assign(N, 1);
    dfsSz(0, -1);
    
    H = 0;
    ids.clear();
    dp.assign(N, -1);
    subtree.assign(N, {});
    ans.clear();
    for (int u = 0; ; ) {
      int vm = -1;
      for (const int v : graph[u]) if (!~vm || sz[vm] < sz[v]) {
        vm = v;
      }
      if (~vm && 2 * sz[vm] > sz[u]) {
        sz[u] -= sz[vm];
        sz[vm] += sz[u];
        u = vm;
      } else if (~vm && 2 * sz[vm] == sz[u]) {
        dfs(u, vm);
        dfs(vm, u);
        if (dp[u] == dp[vm]) {
          auto perm = identity();
          sw(perm, u, vm);
          ans.push_back(perm);
        }
        break;
      } else {
        dfs(u, -1);
        break;
      }
    }
// cerr<<"subtree = "<<subtree<<endl;
    
    if (!ans.size()) {
      ans.push_back(identity());
    }
    
    printf("%d\n", (int)ans.size());
    for (const auto &perm : ans) {
      for (int u = 0; u < N; ++u) {
        if (u) printf(" ");
        printf("%d", perm[u] + 1);
      }
      puts("");
    }
  }
  return 0;
}

详细

Test #1:

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

input:

2
1 2

output:

1
2 1

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

3
1 2
1 3

output:

1
1 3 2

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

4
1 2
1 3
1 4

output:

2
1 3 2 4
1 3 4 2

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 4104kb

input:

5
1 2
1 3
3 4
4 5

output:

1
4 5 3 1 2

result:

ok ok

Test #5:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

5
1 2
1 3
1 4
4 5

output:

1
1 3 2 4 5

result:

ok ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

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

output:

1
1 2 4 3 10 6 7 8 9 5

result:

ok ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

15
1 2
1 5
1 6
1 7
1 8
2 3
3 4
6 12
6 14
8 9
9 10
9 11
11 13
14 15

output:

1
1 2 3 4 7 6 5 8 9 10 11 12 13 14 15

result:

ok ok

Test #8:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

20
1 2
1 11
1 12
2 3
2 5
2 6
2 14
3 4
3 16
4 7
4 8
4 18
5 13
5 17
6 10
8 9
8 19
9 15
17 20

output:

2
1 2 3 4 5 6 7 8 9 10 12 11 13 14 15 16 17 18 19 20
1 2 3 4 5 6 18 8 9 10 11 12 13 14 15 16 17 7 19 20

result:

ok ok

Test #9:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok ok

Test #10:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

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

output:

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

result:

ok ok

Test #11:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

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

result:

ok ok

Test #12:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

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

output:

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

result:

ok ok

Test #13:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

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

output:

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

result:

ok ok

Test #14:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

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

output:

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

result:

ok ok

Test #15:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

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

output:

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

result:

ok ok

Test #16:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok ok

Test #17:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

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

output:

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

result:

ok ok

Test #18:

score: 0
Accepted
time: 0ms
memory: 4096kb

input:

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

output:

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

result:

ok ok

Test #19:

score: 0
Accepted
time: 0ms
memory: 4112kb

input:

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

output:

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

result:

ok ok

Test #20:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

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

output:

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

result:

ok ok

Test #21:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

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

output:

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

result:

ok ok

Test #22:

score: 0
Accepted
time: 0ms
memory: 4112kb

input:

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

output:

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

result:

ok ok

Test #23:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

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

output:

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

result:

ok ok

Test #24:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

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

output:

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

result:

ok ok

Test #25:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

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

output:

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

result:

ok ok

Test #26:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

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

output:

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

result:

ok ok

Test #27:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

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

output:

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

result:

ok ok

Test #28:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

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

output:

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

result:

ok ok

Test #29:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

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

output:

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

result:

ok ok

Test #30:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

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

output:

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

result:

ok ok

Test #31:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

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

output:

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

result:

ok ok

Test #32:

score: 0
Accepted
time: 1ms
memory: 3872kb

input:

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

output:

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

result:

ok ok

Test #33:

score: 0
Accepted
time: 0ms
memory: 4104kb

input:

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

output:

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

result:

ok ok

Test #34:

score: 0
Accepted
time: 0ms
memory: 4104kb

input:

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

output:

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

result:

ok ok

Test #35:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

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

output:

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

result:

ok ok

Test #36:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok ok

Test #37:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

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

output:

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

result:

ok ok

Test #38:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok ok

Test #39:

score: 0
Accepted
time: 0ms
memory: 4116kb

input:

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

output:

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

result:

ok ok

Test #40:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

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

output:

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

result:

ok ok

Test #41:

score: 0
Accepted
time: 0ms
memory: 4108kb

input:

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

output:

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

result:

ok ok

Test #42:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

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

output:

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

result:

ok ok

Test #43:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok ok

Test #44:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

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

output:

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

result:

ok ok

Test #45:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

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

output:

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

result:

ok ok

Test #46:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

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

output:

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

result:

ok ok

Test #47:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

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

output:

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

result:

ok ok

Test #48:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

6
2 1
3 1
1 4
5 4
6 4

output:

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

result:

ok ok

Test #49:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

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

output:

1
1 2 3 4 5 6 7

result:

ok ok

Test #50:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

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

output:

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

result:

ok ok