QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#23685#3307. Query on a Tree 17QingyuTL 410ms33732kbC++203.3kb2022-03-18 18:53:022022-04-30 03:51:35

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 03:51:35]
  • 评测
  • 测评结果:TL
  • 用时:410ms
  • 内存:33732kb
  • [2022-03-18 18:53:02]
  • 提交

answer

#include <bits/stdc++.h>

const int N = 1e5 + 50;

inline int lc(int o) { return o << 1; }
inline int rc(int o) { return o << 1 | 1; }

int64_t tag[N << 2], sum[N << 2];
int n, m, jump[N][19];
int fa[N], siz[N], dep[N], top[N], son[N], dfn[N], id[N], dfn_r[N], tot;
std::vector<int> G[N];

void push_up(int o) {
	sum[o] = sum[lc(o)] + sum[rc(o)];
}
void maintain(int o, int l, int r, int64_t v) {
	sum[o] += 1ll * (r - l + 1) * v;
	tag[o] += v;
}
void push_down(int o, int l, int r) {
	if (tag[o]) {
		const int mid = l + r >> 1;
		maintain(lc(o), l, mid, tag[o]);
		maintain(rc(o), mid + 1, r, tag[o]);
		tag[o] = 0;
	}
}

void add(int o, int l, int r, int ql, int qr, int v) {
	if (ql <= l && r <= qr)
		maintain(o, l, r, v);
	else {
		push_down(o, l, r);
		const int mid = l + r >> 1;
		if (ql <= mid)
			add(lc(o), l, mid, ql, qr, v);
		if (qr > mid)
			add(rc(o), mid + 1, r, ql, qr, v);
		push_up(o);
	}
}

int64_t query(int o, int l, int r, int ql, int qr) {
	if (ql <= l && r <= qr)
		return sum[o];
	push_down(o, l, r);
	const int mid = l + r >> 1;
	int64_t sum = 0;
	if (ql <= mid)
		sum += query(lc(o), l, mid, ql, qr);
	if (qr > mid)
		sum += query(rc(o), mid + 1, r, ql, qr);
	return sum;
}

int query_mid(int o, int l, int r, int64_t cur_sum, int64_t total_sum) {
	if (l == r) return l;
	const int mid = l + r >> 1;
	push_down(o, l, r);
	if (2 * (sum[lc(o)] + cur_sum) >= total_sum)
	   return query_mid(lc(o), l, mid, cur_sum, total_sum);
	return query_mid(rc(o), mid + 1, r, cur_sum + sum[lc(o)], total_sum);	
}

void dfs1(int x, int f, int d) {
	fa[x] = f, dep[x] = d, jump[x][0] = f;
	int maxson = -1;
	for (int i = 0; jump[x][i]; ++i) {
		jump[x][i + 1] = jump[jump[x][i]][i];
	}
	for (int y : G[x])
		if (y != f) {
			dfs1(y, x, d + 1);
			siz[x] += siz[y];
			if (maxson < siz[y]) {
				maxson = siz[y];
				son[x] = y;
			}
		}

}

void dfs2(int x, int topf) {
	top[x] = topf;
	dfn[x] = ++tot; id[tot] = x;
	if (son[x]) {
		dfs2(son[x], topf);
		for (int y : G[x])
			if (y != fa[x] && y != son[x])
				dfs2(y, y);
	}
	dfn_r[x] = tot;
}

void chain_add(int x, int y) {
	while (top[x] != top[y]) {
		if (dep[top[x]] < dep[top[y]])
			std::swap(x, y);
		add(1, 1, n, dfn[top[x]], dfn[x], 1);
		x = fa[top[x]];
	}
	if (dep[x] > dep[y]) std::swap(x, y);
	add(1, 1, n, dfn[x], dfn[y], 1);
}

int find_centroid() {
	int64_t total_sum = query(1, 1, n, 1, n);
	int v = query_mid(1, 1, n, 0, total_sum);
	int x = id[v];

	for (int b = 18; b >= 0; --b) {
		if (jump[x][b]) {
			int y = jump[x][b];
			if (query(1, 1, n, dfn[y], dfn_r[y]) * 2 <= total_sum) {
				x = jump[x][b];
			}
		}
	}
	if (query(1, 1, n, dfn[x], dfn_r[x]) * 2 <= total_sum && fa[x])
		x = fa[x];
	return x;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	std::cin >> n;
	for (int i = 1; i < n; ++i) {
		int x, y;
		std::cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs1(1, 0, 1);
	dfs2(1, 1);
	std::cin >> m;
	for (int i = 1; i <= m; ++i) {
		int op;
		std::cin >> op;
		if (op == 1) {
			int x;
			std::cin >> x;
			add(1, 1, n, dfn[x], dfn_r[x], 1);
		}
		else {
			int x, y;
			std::cin >> x >> y;
			chain_add(x, y);
		}
		std::cout << find_centroid() << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 13196kb

input:

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

output:

2
7
7
1

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 15040kb

input:

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

output:

2
2
2
2
2
2
2
2
2
2
2

result:

ok 11 lines

Test #3:

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

input:

2
1 2
1
1 1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

2
1 2
1
2 1 2

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 6ms
memory: 14940kb

input:

100
1 2
58 2
2 87
63 87
65 63
65 19
6 87
58 21
87 8
87 74
91 6
95 65
2 61
87 59
3 61
37 87
67 87
23 2
63 9
87 46
40 67
70 2
12 58
46 75
75 36
28 3
12 33
72 87
39 6
75 52
85 70
1 76
26 40
47 28
2 49
41 65
66 28
51 37
15 47
86 51
8 60
97 19
48 58
72 90
33 83
97 54
36 5
23 14
78 52
90 7
99 2
48 82
48 6...

output:

72
3
3
87
87
2
2
2
2
87
87
87
87
87
2
87
87
87
87
87
87
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87...

result:

ok 10000 lines

Test #6:

score: 0
Accepted
time: 6ms
memory: 13248kb

input:

100
27 1
27 35
96 1
54 35
25 54
81 35
69 25
27 18
69 83
27 99
70 83
81 61
1 77
73 54
35 68
61 89
20 89
99 95
37 20
63 95
95 38
7 83
63 78
86 35
89 13
71 77
70 14
95 34
13 62
24 95
77 98
99 33
25 100
36 63
35 8
65 54
66 83
40 8
15 81
78 59
15 4
62 28
97 14
15 58
69 3
89 44
47 100
52 73
12 95
53 38
39...

output:

46
35
46
83
83
83
83
35
35
35
25
25
25
35
25
25
25
25
25
54
54
35
35
35
54
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
...

result:

ok 10000 lines

Test #7:

score: 0
Accepted
time: 3ms
memory: 13708kb

input:

100
1 19
19 45
58 45
58 72
36 45
45 94
94 13
90 58
64 90
90 23
45 12
90 52
27 36
19 42
72 35
23 32
67 36
1 18
54 36
33 67
10 1
55 90
54 65
92 72
53 42
65 24
9 45
81 42
85 35
8 81
10 44
85 68
23 30
69 12
43 69
23 25
12 88
85 99
91 9
24 100
48 81
60 94
33 41
52 51
17 19
51 82
30 49
32 28
52 7
82 79
82...

output:

33
45
45
45
45
45
58
58
58
58
58
45
58
45
58
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
45
...

result:

ok 10000 lines

Test #8:

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

input:

100
67 1
34 67
34 72
26 72
63 26
26 14
63 24
63 49
42 14
45 34
14 71
71 87
71 7
14 22
64 72
90 7
14 58
87 99
33 87
24 70
65 64
42 30
33 74
99 62
3 71
60 90
84 90
40 70
47 45
84 69
89 7
57 3
99 59
66 65
58 76
37 14
6 37
72 54
38 24
15 99
51 84
93 76
59 8
89 53
75 51
97 99
20 8
28 53
95 15
11 53
95 13...

output:

21
37
14
14
14
14
71
14
14
14
14
14
14
14
14
14
14
14
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
14
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
71
...

result:

ok 10000 lines

Test #9:

score: 0
Accepted
time: 3ms
memory: 14960kb

input:

100
1 56
1 65
50 1
50 4
4 8
4 27
31 8
10 50
25 10
31 28
31 64
97 25
44 64
16 4
44 89
43 64
89 23
33 43
37 33
10 13
90 43
26 37
97 39
16 52
10 12
20 39
33 78
36 37
37 34
79 1
34 3
20 32
25 77
81 78
35 20
82 25
35 19
35 74
5 20
63 39
38 43
37 66
89 42
57 19
3 18
19 69
100 90
59 69
45 78
34 88
69 60
35...

output:

77
50
77
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
25
10
10
10
10
10
10
10
10
50
50
50
10
50
50
50
10
50
50
50
10
50
50
50
10
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
4
4
4
4
4
50
50
50
50
50
50
50
50
50
50
50
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4...

result:

ok 10000 lines

Test #10:

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

input:

100
1 13
4 1
57 4
13 30
4 73
30 78
30 25
28 30
64 57
4 52
25 83
66 64
99 64
21 28
25 98
28 14
28 7
99 39
13 71
74 99
7 31
14 72
72 45
74 68
79 83
79 93
83 20
11 30
4 95
7 18
86 83
88 68
72 6
32 30
97 95
90 7
89 97
99 29
26 90
90 5
66 67
90 91
49 30
90 51
87 39
28 24
5 22
72 38
50 24
80 74
88 9
81 95...

output:

50
30
28
30
28
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
...

result:

ok 10000 lines

Test #11:

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

input:

100
11 1
1 46
1 55
46 65
43 46
84 1
11 73
77 46
1 78
46 92
81 55
28 55
11 6
1 16
14 78
95 46
1 18
22 77
10 73
65 88
37 11
34 6
14 32
74 16
16 27
43 58
89 1
50 1
55 30
11 38
45 55
92 33
67 78
92 75
80 22
73 23
79 43
69 28
25 78
85 11
65 82
77 99
32 97
2 16
65 62
42 73
46 72
83 58
67 53
100 28
14 51
3...

output:

40
77
46
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 10000 lines

Test #12:

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

input:

100
1 17
78 17
1 24
17 34
24 70
67 24
78 36
17 13
94 1
1 32
36 80
17 50
15 1
78 92
53 78
32 79
28 1
34 30
21 50
67 49
62 67
25 15
61 80
94 73
36 72
71 13
67 85
46 15
13 54
70 4
28 3
33 24
32 18
79 19
5 32
26 73
99 94
75 33
39 25
63 71
61 84
29 73
100 17
5 88
2 34
3 6
68 92
4 11
5 82
39 23
49 69
87 5...

output:

31
1
31
32
32
32
32
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 lines

Test #13:

score: 0
Accepted
time: 6ms
memory: 14520kb

input:

100
95 1
87 1
95 72
99 95
76 1
67 95
54 1
50 72
94 95
1 29
99 78
52 54
25 1
27 76
27 48
18 50
48 32
54 9
44 29
31 72
63 50
36 95
57 99
81 99
52 39
29 47
28 94
47 42
87 93
98 78
16 32
44 12
18 100
34 57
20 95
31 70
63 13
69 31
9 17
68 47
76 49
48 30
95 71
44 56
14 94
2 50
98 43
79 49
53 87
8 81
75 52...

output:

14
95
95
95
95
95
95
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
95
1
95
95
95
95
95
1
95
95
95
95
95
1
95
1
1
1
1
1
95
95
95
95
95
1
1
1
1
1
...

result:

ok 10000 lines

Test #14:

score: 0
Accepted
time: 8ms
memory: 13160kb

input:

100
43 1
4 43
90 4
90 9
56 9
56 53
57 53
57 74
47 74
47 27
25 27
25 62
44 62
44 12
81 44
81 87
88 12
21 87
42 87
42 18
31 42
18 67
41 31
21 71
71 30
60 41
17 60
26 41
96 17
96 100
100 94
86 94
50 94
39 94
35 86
82 39
100 55
3 100
92 30
20 86
3 93
22 20
14 20
99 82
93 79
50 33
15 22
58 15
79 36
15 32...

output:

20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
86
86
86
86
86
86
86
86
86
86
86
86
86
86
86
86
86
20
20
20
86
20
20
20
86
86
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
20
86
86
86
86
20
20
...

result:

ok 10000 lines

Test #15:

score: 0
Accepted
time: 7ms
memory: 14048kb

input:

100
1 5
98 5
82 98
2 82
98 47
47 77
40 77
40 38
38 99
38 32
59 32
59 50
94 50
94 88
45 94
51 45
15 88
55 45
73 45
8 55
83 8
57 83
81 83
55 11
90 8
62 11
11 12
36 90
62 30
48 30
36 20
36 25
27 25
17 25
24 30
42 25
25 52
84 42
42 95
65 42
42 33
33 16
74 95
63 65
63 22
22 13
65 70
13 64
85 70
22 43
79 ...

output:

77
77
35
55
55
55
42
42
42
42
65
65
65
65
85
85
85
85
31
85
85
85
85
65
65
65
85
65
65
65
65
65
65
65
65
65
65
65
85
85
85
85
85
85
85
85
93
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
65
65
65
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
85
...

result:

ok 10000 lines

Test #16:

score: 0
Accepted
time: 6ms
memory: 13748kb

input:

100
61 1
61 14
14 21
21 15
21 5
65 5
5 64
64 77
80 77
58 80
80 85
18 85
58 13
29 13
79 29
12 79
12 66
66 48
95 66
95 33
95 76
76 49
93 49
88 93
83 49
88 17
57 48
88 3
3 25
25 9
9 71
71 75
75 6
97 6
97 26
26 28
87 71
6 78
86 28
86 81
24 17
81 94
37 24
94 54
37 4
35 81
67 4
94 10
67 46
10 47
73 10
19 ...

output:

85
80
88
88
9
88
88
88
88
88
88
88
88
88
88
88
88
88
88
88
9
9
9
88
9
25
25
88
88
88
25
88
25
25
25
25
9
9
71
71
75
71
71
71
71
71
75
71
71
71
71
71
71
71
71
71
71
71
75
75
6
75
75
71
75
71
75
71
75
71
71
71
71
71
71
71
71
71
71
9
9
25
25
25
25
88
25
88
88
88
88
88
88
88
88
88
88
88
88
88
88
88
88
8...

result:

ok 10000 lines

Test #17:

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

input:

100
8 1
93 1
66 1
82 1
88 1
1 96
77 1
8 38
8 70
19 1
1 20
1 43
1 95
1 80
1 29
92 1
56 1
71 1
8 73
62 82
1 78
1 87
8 76
1 45
22 77
8 6
54 1
1 46
1 58
50 66
34 1
28 93
66 30
66 15
38 85
1 9
93 61
8 16
66 48
93 14
93 90
27 1
21 1
93 44
1 60
8 51
66 65
95 84
4 8
83 88
32 93
11 8
40 88
1 74
1 7
96 35
93 ...

output:

6
8
8
8
8
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 lines

Test #18:

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

input:

100
1 66
76 1
41 1
1 6
1 38
67 66
31 1
91 1
1 96
42 1
1 5
41 16
1 30
59 66
28 76
1 58
66 43
41 68
1 48
78 1
1 60
72 76
61 1
15 1
94 1
66 27
1 4
38 29
38 20
23 66
10 76
36 6
75 41
37 1
6 13
19 76
76 35
1 18
1 86
1 49
44 1
1 64
6 85
1 39
80 5
1 71
1 7
66 34
56 41
76 92
65 91
8 76
41 33
99 6
1 51
93 58...

output:

87
1
87
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 10000 lines

Test #19:

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

input:

100
1 25
72 1
1 16
1 96
55 1
11 1
26 1
2 1
1 37
8 25
72 6
1 4
1 13
46 25
31 1
99 1
21 1
1 10
52 1
83 72
86 1
16 22
49 16
72 80
76 1
1 15
35 1
44 25
33 1
66 11
91 11
43 72
85 1
7 1
54 72
94 1
50 16
32 16
28 72
1 20
16 59
1 48
14 72
84 25
16 17
58 1
63 26
97 25
57 55
65 26
61 16
19 1
16 92
95 1
2 74
1...

output:

78
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 10000 lines

Test #20:

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

input:

100000
1 33107
1 49683
49683 23838
33107 33841
25927 23838
1 74779
99345 74779
36731 99345
23838 70246
38975 49683
36605 74779
49283 1
72218 49283
36605 89277
16724 49283
15597 89277
74779 70693
25927 10882
18787 49683
49283 89923
74779 18891
18891 72904
70246 64950
74779 39040
51544 39040
48338 722...

output:

89754
28789
33107
33107
49683
49683
49683
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 268ms
memory: 25404kb

input:

100000
1 98526
98526 71881
71881 32316
71881 91701
97004 71881
1 50154
50154 25648
90382 32316
98526 51008
81074 71881
88290 91701
20835 81074
1 88584
81163 1
5066 98526
63220 71881
5066 43945
88290 89171
97004 78551
49986 91701
53367 88584
50154 89663
50154 90725
98456 89663
90382 74858
90725 53584...

output:

94781
47260
71881
66830
1649
81074
20703
66830
66830
66830
35108
20703
66830
66830
20703
20703
20703
20703
20703
20703
20703
20703
20703
66830
66830
20703
20703
1649
1649
1649
1649
1649
1649
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
81074
8...

result:

ok 100000 lines

Test #22:

score: 0
Accepted
time: 148ms
memory: 24856kb

input:

100000
98458 1
18530 1
95442 1
98458 2967
97766 95442
18530 5382
5382 45839
97766 70789
97766 46371
51056 70789
2100 5382
97766 40344
193 98458
18530 45452
2967 91534
5382 71051
68600 5382
65092 2967
43663 70789
66738 1
20267 95442
2100 61712
39565 66738
95442 56590
29031 61712
8607 91534
91681 5105...

output:

98813
97766
97766
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #23:

score: 0
Accepted
time: 182ms
memory: 24904kb

input:

100000
1 93030
48178 93030
1655 1
93030 95380
15742 95380
15742 38782
49563 93030
93030 94593
38782 10482
94593 62811
62811 38444
62630 93030
23379 1
66269 95380
15320 66269
69627 1
93030 637
10482 46696
62570 66269
43085 69627
40421 15320
40421 29280
38444 29544
13323 29280
15320 51097
13323 33995
...

output:

57889
1
1
1
93030
93030
93030
1
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
93030
9303...

result:

ok 100000 lines

Test #24:

score: 0
Accepted
time: 171ms
memory: 25420kb

input:

100000
1 46788
46788 74831
38318 46788
46788 28121
28121 85162
46788 24705
62068 1
46788 86508
24705 85078
80001 24705
91029 80001
62068 55738
62068 11972
62068 80422
11972 36665
36665 81942
28121 85074
85078 35507
85074 93487
46788 65180
2803 46788
67158 85074
11972 30193
6547 36665
67785 55738
543...

output:

10039
1
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
46788
4678...

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 127ms
memory: 26020kb

input:

100000
1 86599
1715 1
86599 79823
65172 1715
93401 79823
18478 1
95324 18478
1534 79823
86599 40049
18478 84772
88749 40049
33592 84772
20450 93401
72786 33592
54506 79823
49207 20450
20450 52827
40049 32100
51159 1
51159 69551
52827 83745
1974 51159
7678 32100
2139 93401
53523 69551
26607 40049
847...

output:

90253
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
86599
1
1
1
1
1
86599
1
1
1
86599
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
86599
86599
86599
1
86599
1
86599
1
86599
86599
86599
1
86599
86599
86599
86599
86599
86599
86599
86599
86599
86599
86599
86599
8659...

result:

ok 100000 lines

Test #26:

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

input:

100000
66827 1
66827 3020
37001 3020
86421 37001
48188 86421
48188 66366
64459 66366
64459 70776
70776 88217
88217 53546
53546 60759
94219 60759
52771 94219
52771 1872
1872 33491
33491 15705
78366 15705
68591 78366
68591 70054
70054 94898
94898 37055
83477 37055
83477 61881
61881 39144
39144 70057
7...

output:

75000
33373
7590
64240
43814
89834
70488
29117
71794
43268
14768
42809
43375
25401
40632
33598
46593
645
20236
3674
36430
65000
92273
25595
56960
55003
45432
70243
77446
16509
4099
20265
66645
34989
58809
98353
9329
62421
97020
6494
64065
50143
23005
99419
84985
21578
77627
75730
39291
63567
59463
1...

result:

ok 100000 lines

Test #27:

score: 0
Accepted
time: 403ms
memory: 32404kb

input:

100000
17714 1
9191 17714
99673 9191
65651 99673
65651 11385
11385 2682
28082 2682
34681 28082
34681 38648
65899 38648
9099 65899
5024 9099
83703 5024
9649 83703
9649 33178
98045 33178
98045 41340
41340 94118
27384 94118
27384 68738
45636 68738
14788 45636
14788 74533
76190 74533
27493 76190
27493 6...

output:

19816
16751
92098
59112
95318
51697
31218
7148
61778
28385
74434
85323
65962
51202
63974
35110
43035
58792
36169
46581
25438
24399
48959
74508
43446
74498
81711
65260
96892
35539
53879
80120
75837
84884
56306
10374
38768
48702
42349
16439
12177
66088
75848
34280
81648
43035
33126
38354
25635
33771
1...

result:

ok 100000 lines

Test #28:

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

input:

100000
22928 1
22928 80138
80138 561
12243 561
64650 12243
68732 64650
23722 68732
63491 23722
57000 63491
57000 44184
30887 44184
26871 30887
26871 56867
22988 56867
22988 67437
21428 67437
21428 9383
9383 41140
33629 41140
33629 84078
89444 84078
16241 89444
16241 57736
57736 57002
57002 98436
984...

output:

61510
34581
37507
71837
35782
90366
40788
60437
44372
40065
64539
30913
8418
50045
43019
11105
81636
18541
43468
61287
17528
17323
6869
79125
1628
50522
90601
74270
32092
41168
90398
70850
15388
50392
87916
66529
47928
80580
63001
93220
46118
59712
95602
88299
91706
75258
79564
22101
38398
74933
539...

result:

ok 100000 lines

Test #29:

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

input:

100000
36566 1
35565 36566
35565 41765
41765 78635
92475 78635
43861 92475
43861 54432
44236 54432
44236 30867
11626 30867
15133 11626
71235 15133
71235 60829
7111 60829
7111 76908
92659 76908
17220 92659
17220 53109
55382 53109
49506 55382
98726 49506
98726 93200
14583 93200
74476 14583
26983 74476...

output:

34469
95360
5067
34259
44697
22563
88596
41596
23791
81565
77364
12208
56234
61174
19597
19619
10340
42797
8122
13921
36822
72154
6797
58136
17121
30086
7982
75074
92953
13322
36030
60229
95226
29797
22532
61169
75770
44787
48249
48104
79100
74035
56468
40690
52239
80023
22624
84667
23551
61468
6208...

result:

ok 100000 lines

Test #30:

score: 0
Accepted
time: 337ms
memory: 32544kb

input:

100000
52155 1
52155 28555
28555 53036
82183 53036
12992 82183
12992 36886
31409 36886
31409 53742
53742 2950
40312 2950
40312 73127
81907 73127
81907 50179
57734 50179
57734 35176
79708 35176
2155 79708
2155 56804
56804 42542
73941 42542
53647 73941
53647 29939
91177 29939
91177 84502
96741 84502
6...

output:

34377
34377
46854
43072
46854
46854
61917
61917
27332
27332
27332
95646
27332
95646
95646
94522
94522
15317
94522
94522
97146
97146
97146
94522
97146
94522
94522
94522
94522
94522
97146
97146
97146
97146
95646
95646
59143
59143
59143
95646
59143
98785
98785
98785
98785
95646
98785
98785
82244
82244
...

result:

ok 100000 lines

Test #31:

score: 0
Accepted
time: 355ms
memory: 32524kb

input:

100000
1 82275
82275 69037
48648 69037
62642 48648
62642 49100
49100 94778
94778 92658
81639 92658
85975 81639
15507 85975
89132 15507
89132 49101
49101 87656
19548 87656
8626 19548
69442 8626
59978 69442
59978 36541
36541 86262
86262 17979
17979 41886
58912 41886
96688 58912
55459 96688
55459 75400...

output:

8315
21157
8315
171
8315
171
171
14519
171
171
171
97500
171
171
171
171
171
171
8315
8315
38017
8315
26481
26481
26481
26481
26481
8315
26481
8315
8315
171
8315
171
171
171
8315
171
171
72688
72688
48039
48039
48039
48039
30747
30747
30747
48039
48039
72688
48039
48039
48039
48039
54407
54407
30747...

result:

ok 100000 lines

Test #32:

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

input:

100000
1 37577
37577 42639
42639 12954
12954 42205
42205 57972
57972 13499
13499 40969
31653 40969
59881 31653
61124 59881
41765 61124
41765 14722
10971 14722
97743 10971
36503 97743
36503 17243
76071 17243
91422 76071
3212 91422
3212 45238
89092 45238
56468 89092
58166 56468
33675 58166
33675 94593...

output:

2182
26217
2182
67215
67215
67154
67215
67154
67154
57427
67154
67154
67215
67154
67215
67215
67215
67154
67154
67154
67215
67215
53038
67215
53038
53038
2182
2182
66936
2182
66936
66936
709
66936
709
66936
66936
66936
709
709
709
709
709
709
34564
709
34564
34564
34564
709
34564
34564
34564
34564
3...

result:

ok 100000 lines

Test #33:

score: 0
Accepted
time: 355ms
memory: 33732kb

input:

100000
47346 1
47346 82146
82146 58638
58638 2548
28951 2548
28951 1434
1434 75645
69999 75645
69999 27426
27426 6569
8468 6569
8468 67771
67771 69127
18807 69127
18807 15058
91695 15058
91695 40137
29719 40137
30509 29719
30509 44545
24317 44545
24317 87598
87598 57571
57571 49551
88786 49551
88786...

output:

23684
23684
23684
23684
23684
29268
29268
69899
69899
69899
69899
69899
69899
69899
29268
29268
29268
29986
29986
69899
69899
88585
88585
39276
39276
39276
39276
31745
31745
18197
18197
41540
18197
18197
18197
41540
18197
18197
39232
39232
31745
39232
39232
18197
39232
39232
39232
39232
39232
37176
...

result:

ok 100000 lines

Test #34:

score: 0
Accepted
time: 115ms
memory: 24880kb

input:

100000
77850 1
91927 1
1 83060
49789 1
60003 1
87409 1
39790 1
1 98290
9915 1
1 19865
67636 1
36254 1
73373 1
34671 1
1 8230
1 315
1 3225
17488 1
1 42911
1 94883
68034 1
1 52091
72112 1
57416 1
1 76917
92604 1
1 49862
92848 1
1 58423
1 43970
32996 1
1 25526
46954 1
38862 87409
7544 1
1 93016
8376 1
...

output:

12913
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #35:

score: 0
Accepted
time: 116ms
memory: 24768kb

input:

100000
1 69690
97044 1
1 41212
1 34113
95343 1
80995 1
1 14618
1 47814
96469 1
51077 1
33996 1
1 91404
1 43748
55546 1
24284 1
1 44564
1 3277
91165 1
1000 1
10440 1
97923 1
1 6173
38601 1
1 36286
1 17653
40363 1
71551 1
78734 1
1 75159
1 19579
1 76242
88277 1
51199 1
1 55489
1 67411
21524 1
44112 1
...

output:

89769
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #36:

score: 0
Accepted
time: 92ms
memory: 24844kb

input:

100000
73951 1
62709 1
1 46654
58985 1
1 94319
1 91975
1 55242
1 55010
1 51452
1 16079
40700 1
1 73091
1 57167
52199 1
1 28783
1 14463
66478 1
63197 1
1 4237
1 32128
1 92144
1 4420
1 81525
99857 1
62705 1
93853 1
1 94982
1 63503
1 49093
1 92375
45305 1
99956 1
80579 1
51653 1
54451 1
1 90586
70561 1...

output:

88803
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #37:

score: 0
Accepted
time: 111ms
memory: 25452kb

input:

100000
1 12063
1 27662
1 85953
56453 1
90373 1
58386 1
1 69482
1 62496
1 87304
69482 35539
1 76821
6567 1
1 79641
1 63118
74762 1
2405 1
58634 1
1 48225
45066 1
94452 1
1 72553
47068 1
1 14188
1 66054
1 43865
1 65354
43157 1
51077 1
1 98064
64807 1
41057 1
48908 1
67452 1
1 4346
20457 1
11680 1
3553...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #38:

score: 0
Accepted
time: 88ms
memory: 25192kb

input:

100000
1 53345
1 73234
1 60508
92591 1
56674 1
1988 1
14419 1
79313 1
58869 1
1 48855
38268 1
1 71054
7465 1
68352 1
2155 1
90039 1
39361 1
1 91261
7335 1
1 31860
78092 1
1 28146
90737 1
77560 1
1 19305
1 25510
39152 1
32905 1
1 79748
1 36212
1 30692
1 93507
1 48593
1 56170
9320 1
1 29449
1 18469
84...

output:

79422
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #39:

score: 0
Accepted
time: 93ms
memory: 24920kb

input:

100000
1 16643
50574 1
1 62435
12061 1
7938 1
89565 1
1 99958
23037 1
1 36218
34421 1
1 68626
16629 1
57534 1
63927 1
95107 1
40937 1
1 21472
3066 1
1 78388
1 26346
12983 1
48437 1
1 48049
91353 1
29972 1
26447 1
1 87367
1 11653
1 84000
77307 1
55456 1
1 59973
2819 89565
1 5954
1 45168
1 33104
1 536...

output:

2320
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 100000 lines

Test #40:

score: 0
Accepted
time: 93ms
memory: 24680kb

input:

100000
23596 1
1 5559
1 40256
1 17740
1 15513
55851 1
1 55566
18568 1
9035 1
1 6386
39699 1
27952 1
1 54280
36091 1
33890 1
38799 1
59357 1
47568 1
1 36142
1 93475
1 47642
1 42063
1 66339
1 57420
14275 1
1 67023
71213 1
1 53096
26196 1
64062 1
1 5569
20788 1
1 51686
65441 1
25136 1
1 69727
64265 1
1...

output:

69080
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #41:

score: 0
Accepted
time: 88ms
memory: 24940kb

input:

100000
27651 1
1 31797
33485 1
1 63287
90989 1
96560 1
1 92011
1 71998
1 14710
1 75896
1 97729
95362 1
1 86746
1 64800
44897 1
12661 1
48211 1
17576 1
8623 1
6029 1
1 49513
1 91557
80977 1
72835 1
1 95104
1 76206
24357 1
61005 1
3678 1
1 73018
75709 1
1 42028
1 10036
31031 1
1 32525
68393 1
12008 1
...

output:

8227
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 100000 lines

Test #42:

score: 0
Accepted
time: 359ms
memory: 25780kb

input:

100000
1 14845
14845 5586
5586 65735
44786 65735
54682 44786
56842 54682
56842 707
36542 707
58315 36542
21759 58315
21759 98499
25073 98499
13590 25073
56561 58315
29226 13590
29226 9500
9500 67441
67441 85068
85068 37813
51298 37813
69165 51298
29951 69165
16151 29951
41893 16151
56858 41893
44474...

output:

1870
15656
15656
85743
85743
6093
6093
16683
16683
60355
60355
95530
95530
95530
95466
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
39823
398...

result:

ok 100000 lines

Test #43:

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

input:

100000
8459 1
8459 48571
48571 29717
26828 29717
53324 26828
53324 68871
68871 59915
28448 59915
28448 40870
40870 64134
64134 63198
63198 69677
69677 82446
82446 40804
62820 40804
31571 62820
31571 66085
52385 66085
27166 52385
58283 27166
63497 58283
63497 63387
60484 63387
60484 41537
35011 41537...

output:

84583
78951
71335
71335
87584
87584
13449
52168
44362
44362
44362
44362
52168
52168
52168
52168
52168
52168
13449
13449
13449
52168
52168
52168
52168
52168
52168
52168
52168
52168
44362
52168
44362
44362
52168
44362
44362
44362
44362
44362
44362
44362
44362
44362
44362
44362
44362
44362
44362
44362
...

result:

ok 100000 lines

Test #44:

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

input:

100000
1 60489
90096 60489
90096 71610
4194 71610
4194 86752
35303 86752
73288 35303
73288 97076
13281 97076
4363 13281
4363 74305
74305 14622
14622 17800
17800 59406
59406 50168
50168 11322
73360 11322
25949 73360
22848 25949
22848 57818
10604 57818
10604 90015
90015 7240
7240 98146
28065 98146
235...

output:

13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
13373
...

result:

ok 100000 lines

Test #45:

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

input:

100000
1 43455
1 49641
49641 89175
88335 89175
51974 88335
51974 34678
95388 34678
21048 95388
82287 21048
16158 82287
99116 16158
51694 99116
40147 51694
40147 29972
39961 29972
39961 6569
29555 6569
29555 70758
40559 70758
25154 40559
50762 25154
50762 77567
38163 77567
38163 20392
62917 20392
964...

output:

85397
86704
95871
22860
78792
26714
75400
54713
85975
85975
41610
41610
41610
58788
58788
99709
99301
88644
89929
89929
89929
95725
42349
65702
65702
65702
85110
55577
59594
59594
62321
93071
72878
61454
24180
85281
85281
85281
30533
30533
30533
43355
85110
20206
65331
54355
88091
57808
67051
67051
...

result:

ok 100000 lines

Test #46:

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

input:

100000
92448 1
85346 92448
67099 85346
82826 67099
60296 82826
60296 47686
1208 47686
1208 15125
15125 50580
55962 50580
55962 10875
24430 10875
12413 24430
12413 42532
28620 42532
28620 42169
25245 42169
25245 57556
57556 27163
71514 27163
64984 71514
79766 64984
20313 79766
20313 72621
98806 72621...

output:

30587
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
11540
...

result:

ok 100000 lines

Test #47:

score: 0
Accepted
time: 301ms
memory: 25632kb

input:

100000
1 70699
70699 1514
1514 2156
2156 53955
53955 71456
40147 71456
40147 16553
16553 93180
83466 93180
83466 30940
41349 30940
38240 41349
1198 38240
60786 1198
37366 60786
37366 94546
94546 51689
21537 51689
21537 85591
85591 22439
65306 22439
65306 38211
2385 38211
2385 77415
84244 77415
84244...

output:

85842
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
81406
...

result:

ok 100000 lines

Test #48:

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

input:

100000
32105 1
32105 75391
75391 32112
28275 32112
28275 11977
95384 11977
95384 66537
43335 66537
55792 43335
8840 55792
8840 39887
76421 39887
76421 47100
87838 47100
23986 87838
74879 23986
13902 74879
13902 15308
2934 87838
66101 15308
66101 37188
58035 37188
58035 35725
72864 35725
43491 72864
...

output:

58223
54781
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
23138
...

result:

ok 100000 lines

Test #49:

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

input:

100000
1 30132
30132 54719
54719 91219
89845 91219
68373 89845
68373 48745
21390 48745
21390 80531
41953 80531
41953 51668
51668 5264
41868 5264
76815 41868
76815 81304
68981 81304
50369 68981
9240 50369
9240 30970
30970 13552
13552 27646
27646 66856
80407 66856
80407 20336
43144 20336
5241 43144
52...

output:

90587
23766
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
25214
...

result:

ok 100000 lines

Test #50:

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

input:

100000
96196 1
96196 82672
82672 14650
37030 14650
37030 73593
73593 88080
88080 80316
80316 70683
67341 70683
24074 67341
2074 24074
2074 92154
92154 4074
4074 54803
14818 54803
14818 39818
29546 39818
2100 29546
2100 92121
26166 92121
26166 81055
81055 37449
37449 94600
3791 94600
98187 3791
98187...

output:

23941
61076
76471
76471
19428
19428
80811
80811
77478
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
46369
...

result:

ok 100000 lines

Test #51:

score: 0
Accepted
time: 361ms
memory: 26788kb

input:

100000
90143 1
5961 90143
5961 84300
84300 6275
1214 6275
1214 85112
85112 62693
14350 62693
31646 14350
1214 84384
13148 31646
41399 13148
36922 41399
10882 36922
29075 10882
20403 29075
20403 4735
4735 7116
92491 7116
92491 42381
42381 69301
69301 16846
16846 84562
84562 75064
75064 98282
98282 59...

output:

41501
2720
72380
17501
45007
84491
33384
33384
6970
6970
42668
18738
28070
50732
10845
89837
89837
89837
89837
89837
69523
69523
1692
33038
27318
27318
27318
27318
96935
15723
15723
86640
34280
12414
72538
70723
11868
79943
79943
76948
43900
43900
43900
43900
62492
62492
9665
9665
9665
9665
97656
97...

result:

ok 100000 lines

Test #52:

score: 0
Accepted
time: 303ms
memory: 26848kb

input:

100000
34758 1
34758 4832
4832 99692
99692 82869
51637 82869
24781 51637
24781 23507
23507 95754
54625 95754
2234 54625
2234 76494
75802 76494
75802 24580
5797 24580
3179 5797
3179 95196
95196 10369
10369 5996
86385 5996
86385 90740
31314 90740
31314 83326
83326 47612
47612 12056
67726 12056
67726 9...

output:

3117
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
90227
9...

result:

ok 100000 lines

Test #53:

score: 0
Accepted
time: 298ms
memory: 26748kb

input:

100000
1 24736
24736 23980
48535 23980
44524 48535
49409 44524
49409 37756
46327 37756
98372 46327
98372 43233
43233 10685
81611 10685
41695 81611
38465 41695
38465 69515
69515 93002
93002 76271
45632 76271
42532 45632
94849 42532
3568 94849
50813 3568
58638 50813
58638 20379
20379 71338
71338 24906...

output:

8653
20706
20706
20706
20706
20706
20706
67687
20706
20706
20706
73360
20706
73360
20706
73360
20706
20706
20706
20706
20706
20706
20706
73360
73360
32376
73360
73360
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
20706
2...

result:

ok 100000 lines

Test #54:

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

input:

100000
32344 1
32344 48697
69193 48697
49768 69193
49768 8341
8341 77974
77974 24478
26913 24478
26913 63888
66275 63888
66275 91722
33159 91722
33159 25991
25991 96675
96675 21446
39559 21446
80536 39559
80536 77603
77603 80111
80111 47080
35117 47080
35117 2699
2699 13635
13635 50259
43811 50259
5...

output:

27411
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
71384
...

result:

ok 100000 lines

Test #55:

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

input:

100000
1 79813
79813 51504
51504 90961
8540 90961
8540 59903
47265 59903
59210 47265
59210 85079
71998 85079
49141 71998
44383 49141
44383 30885
30885 9256
9256 55077
55077 24213
64535 24213
65358 64535
7815 65358
85525 7815
85525 46110
25314 46110
22620 25314
53620 22620
64535 33376
53620 64516
829...

output:

87921
71301
71301
71301
80410
71301
78117
78117
78117
78117
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
80410
...

result:

ok 100000 lines

Test #56:

score: 0
Accepted
time: 384ms
memory: 28908kb

input:

100000
91680 1
78110 91680
78110 20321
20321 14594
14594 74671
74671 20769
20769 6570
6570 23309
50262 23309
52240 50262
27870 52240
19577 27870
21657 19577
21657 92750
92750 81458
81458 7624
7624 67140
67140 51156
51156 21426
21426 19628
19628 55298
53417 55298
37256 53417
37256 8810
76323 8810
763...

output:

24031
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
21482
67549
52213
52213
52213
43489
17907
17907
98884
68745
68745
20370
63786
63786
2289
2289
75920
87645
87645
87645
87645
52462
35247
57...

result:

ok 100000 lines

Test #57:

score: 0
Accepted
time: 380ms
memory: 28672kb

input:

100000
1 4865
1 37402
55336 4865
924 55336
924 37050
34616 37050
74789 34616
74789 54862
71899 54862
46755 71899
56405 46755
56405 57158
39752 57158
39752 88110
7791 88110
7791 94266
94266 17326
31545 17326
31545 24966
24966 7988
36642 7988
36642 7607
50381 7607
95484 50381
98335 95484
98335 5251
45...

output:

75672
75672
75672
56836
75672
18862
43020
6980
6980
8575
8575
60091
6116
6116
96415
44130
68995
75914
75914
9370
46367
57555
75530
84244
19060
4063
46687
46687
74694
74694
45346
67688
67688
67688
13020
39102
39102
69360
69360
69360
95482
58997
74710
98234
98234
98234
40758
77091
7115
75914
12795
127...

result:

ok 100000 lines

Test #58:

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

input:

100000
83649 1
83649 58187
45005 58187
13575 45005
18837 13575
40397 18837
61532 40397
61532 87940
27828 87940
60646 27828
44746 60646
73662 44746
73662 47750
48095 47750
48095 7141
97839 7141
97839 48696
48696 20181
20181 52932
73 52932
64331 73
58696 64331
16624 58696
16624 20737
19937 20737
59195...

output:

22680
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
89060
96595
89060
89060
89060
89060
89060
89060
89060
89060
...

result:

ok 100000 lines

Test #59:

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

input:

100000
1 28257
29440 28257
29440 90157
90157 38246
3069 38246
3069 32676
32676 32169
32169 64672
28601 64672
90751 28601
90751 17324
17324 98863
98863 47075
36120 47075
36120 69063
82748 69063
82748 52361
52361 4350
4350 29011
52289 29011
52289 78126
78126 55124
55124 71690
71690 84551
84551 94001
6...

output:

51076
57302
51076
51076
18916
18916
18916
11055
18916
18916
18916
18916
18916
11055
11055
11055
11055
11055
18916
18916
18916
18916
18916
18916
18916
18916
18916
18916
18916
11055
11055
11055
11055
35108
11055
35108
35108
81048
35108
35108
11055
11055
18916
18916
18916
11055
11055
11055
11055
11055
...

result:

ok 100000 lines

Test #60:

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

input:

100000
1 45823
45823 29370
90323 29370
90323 89924
89924 6693
6693 74187
74187 64821
64821 61516
30658 61516
30658 47920
47920 30837
30837 58732
58732 91950
91950 94807
16668 94807
16668 33328
68938 33328
68938 17058
17058 98032
98032 39992
26912 39992
26912 15958
3845 15958
60156 3845
60156 21065
2...

output:

18459
89560
92836
89560
89560
89560
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
92836
...

result:

ok 100000 lines

Test #61:

score: 0
Accepted
time: 333ms
memory: 29732kb

input:

100000
40044 1
41557 40044
79291 41557
25186 79291
27263 25186
23188 27263
23188 81704
79291 24822
81704 96807
18611 96807
18418 18611
19722 18418
19722 42165
42165 29473
29473 83245
83245 99989
99989 10995
10995 86179
86179 24983
83872 24983
83872 83327
83327 88531
45864 88531
9920 45864
9920 60773...

output:

52176
69461
61504
61504
52176
52176
34610
34610
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
76657
...

result:

ok 100000 lines

Test #62:

score: 0
Accepted
time: 382ms
memory: 31156kb

input:

100000
45348 1
25231 45348
32871 25231
32871 81276
81276 42777
8902 42777
8902 76849
76849 16425
22425 16425
36774 22425
82859 36774
30279 82859
99721 30279
99721 83138
19791 83138
75232 19791
75232 84154
84154 12945
12945 5514
5514 50779
50779 72141
2864 72141
10884 2864
54899 10884
94647 54899
946...

output:

73111
73111
73111
73111
47107
11626
64546
21149
19525
79740
96895
19860
98689
98689
98689
19785
29364
17627
67394
81018
80680
82586
92169
54415
54415
12546
36615
62622
46832
14969
59422
48426
62855
10276
69748
11313
18117
59695
59695
59695
96005
15189
73852
42027
75362
54526
56136
6347
62682
71533
7...

result:

ok 100000 lines

Test #63:

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

input:

100000
1 87148
8078 87148
30206 87148
30206 81701
35413 81701
35413 56239
56239 75991
8004 75991
8004 50161
50161 29974
29974 14049
14049 34119
35000 34119
35000 41636
41636 86237
86237 38592
32614 38592
38797 32614
38797 64804
98767 64804
65941 98767
91736 65941
91736 95180
95180 53878
37839 53878
...

output:

18048
4800
70372
86572
85694
55539
59390
42201
5055
15928
63538
63538
18781
45840
49656
66473
97302
5074
85155
85155
85155
11896
54862
30882
9389
9389
4704
37907
14631
36974
29458
78434
68648
89584
50729
50729
44636
8053
68706
98537
94037
51257
89419
30019
77794
43980
94538
9263
12789
91858
75462
42...

result:

ok 100000 lines

Test #64:

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

input:

100000
74509 1
74509 35217
60272 35217
60272 67784
91373 67784
40802 91373
11789 40802
40462 11789
62419 40462
62419 72761
25995 72761
25995 21150
47098 21150
60114 47098
60114 50779
82482 50779
82482 43617
70289 43617
70289 15518
88034 15518
99658 88034
99658 25537
76724 25537
50473 76724
50473 830...

output:

19110
74198
74198
70725
83216
83216
74198
74198
19110
19110
76212
76212
10907
10907
10907
76212
98315
98315
10907
10907
24654
10907
24654
10907
24654
10907
10907
98315
10907
26704
26704
98315
26704
26704
26704
26704
10907
10907
24654
10907
24654
10907
10907
10907
24654
10907
24654
24654
24654
10907
...

result:

ok 100000 lines

Test #65:

score: 0
Accepted
time: 351ms
memory: 31552kb

input:

100000
1 29886
69519 29886
69519 43227
16665 43227
61082 16665
61082 27901
27901 45821
60012 45821
60012 57866
57866 60905
60905 83583
91150 83583
91150 32251
32251 41301
93443 41301
93443 8191
20056 8191
26817 20056
52093 26817
52093 3977
3977 86066
630 86066
630 82041
30255 82041
8717 30255
8717 7...

output:

93578
93578
93578
30320
93578
93578
40124
93578
93578
93578
93578
30320
30320
39658
30320
39658
39658
39658
30320
30320
30320
30320
93578
30320
93578
30320
30320
30320
93578
30320
30320
30320
93578
93578
9453
93578
93578
93578
9453
93578
9453
93578
93578
93578
93578
30320
30320
30320
30320
95291
303...

result:

ok 100000 lines

Test #66:

score: 0
Accepted
time: 351ms
memory: 30640kb

input:

100000
1 10667
91377 10667
67573 91377
67573 88109
88109 17164
17164 77433
77433 29297
5770 29297
20347 5770
20347 38221
64567 38221
97867 64567
72082 97867
30742 72082
36223 30742
36223 32068
95998 32068
95998 76364
76364 22533
22533 68752
68956 68752
68956 61686
61686 93078
93078 4392
34746 5770
4...

output:

26819
26819
34270
34270
21338
21338
53861
21338
53861
53861
95446
53861
95446
95446
95446
53861
95446
53861
71675
53861
71675
53861
71675
53861
71675
71675
71675
53861
41823
53861
41823
53861
53861
87128
53861
87128
53861
87128
53861
87128
87128
87128
87128
87128
53861
53861
41823
53861
53861
87128
...

result:

ok 100000 lines

Test #67:

score: 0
Accepted
time: 336ms
memory: 30472kb

input:

100000
1 1045
58745 1045
9914 58745
9914 25404
25404 87703
80751 87703
80751 89568
89568 82539
82539 82893
82893 53002
53002 86176
86176 59439
59439 58772
3801 58772
3801 38728
70607 38728
70607 43976
43976 47712
7710 47712
99159 7710
72 99159
47612 72
12072 47612
63103 12072
63103 59668
44981 59668...

output:

90944
6568
90944
90944
19206
90944
19206
90944
19206
90944
19206
30848
30848
30848
30848
90944
90944
2764
2764
33353
33353
33353
2764
33353
33353
33353
33353
5070
33353
33353
33353
5070
5070
5070
5070
6568
6568
6568
6568
6568
5070
5070
5070
5070
5070
6568
5070
6568
6568
40363
6568
6568
6568
40363
40...

result:

ok 100000 lines

Test #68:

score: 0
Accepted
time: 405ms
memory: 31764kb

input:

100000
51277 1
51277 79509
79509 71200
41225 71200
41225 94945
52441 94945
52441 66390
4693 66390
79730 4693
79730 9407
28397 9407
28397 10154
43212 10154
43212 8238
8238 19187
19187 71811
21077 71811
35267 19187
21077 8896
81457 8896
81457 10652
10652 42169
98174 42169
58857 98174
58857 5318
2276 5...

output:

95956
27306
49017
94540
98819
32605
32605
69389
71626
65991
12786
38594
97194
16799
58223
52692
47006
77589
36886
36404
46652
28738
71780
29678
39360
20031
71019
92176
65889
94344
95931
98809
30433
52252
52252
67698
30611
65010
65010
14575
80240
15165
52886
31615
17051
60313
64627
97050
71598
45382
...

result:

ok 100000 lines

Test #69:

score: 0
Accepted
time: 364ms
memory: 31812kb

input:

100000
502 1
364 502
4919 364
4919 17571
17571 75642
75642 92688
92688 36138
59042 36138
83769 59042
83769 30158
30158 84426
41665 84426
35964 41665
35964 24393
47691 24393
12143 47691
61310 12143
17719 61310
91056 17719
91056 73490
73490 24013
24013 418
418 92815
92815 39943
39943 69530
69530 55382...

output:

77834
77834
45696
94802
44145
44145
56427
64262
54220
98555
71133
79114
50493
29357
29357
4774
4774
53378
34282
55328
39206
59759
38946
63883
28463
62084
2710
48070
31586
71433
35574
1071
78566
71822
66501
53129
68826
66069
63951
58080
74790
74790
59303
29011
53204
99617
5665
2192
76383
17365
27651
...

result:

ok 100000 lines

Test #70:

score: 0
Accepted
time: 376ms
memory: 32084kb

input:

100000
82866 1
82866 9353
9353 25574
57325 25574
11663 57325
89129 11663
89129 14515
99494 14515
37942 99494
37942 43224
43224 64877
64877 47336
47336 21800
21800 3570
3570 16309
16309 15218
15218 47378
47378 14635
62507 14635
62507 14876
14876 40967
40967 5545
29456 5545
29456 17890
97256 17890
650...

output:

5011
38392
18075
18075
87409
39982
87592
44625
50885
67713
27451
35198
81696
90302
43637
43637
17579
74738
61731
62466
5156
55302
76114
25149
32579
65772
65573
78924
17362
67713
27903
9051
41630
81759
81193
49398
86604
46347
28850
5281
95725
95725
29832
14672
76827
99174
52020
97358
96783
86802
9729...

result:

ok 100000 lines

Test #71:

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

input:

100000
1 46302
46302 32919
32919 20068
73577 20068
73577 99351
60625 99351
60625 25610
25610 57726
94072 57726
94072 84960
51682 94072
84960 68515
4399 68515
4399 79917
96339 79917
92272 96339
36571 92272
9514 36571
9514 2116
2116 7204
37037 7204
37037 31348
31348 37085
37085 61823
61823 29556
89349...

output:

32257
8242
23814
84720
7847
12568
89672
35283
33138
53378
32620
67835
14958
55919
79344
56200
38988
67239
25676
38556
83932
1903
24948
23877
57826
18721
19591
47359
17988
7413
18265
21522
2289
35790
63797
10214
10214
31811
36133
3077
74070
29006
25127
44225
51660
27892
75742
1512
10509
40905
69552
3...

result:

ok 100000 lines

Test #72:

score: 0
Accepted
time: 335ms
memory: 31740kb

input:

100000
14476 1
76368 14476
78831 76368
78831 77761
25896 77761
73752 25896
72603 73752
53790 72603
53790 46243
46243 98334
18746 98334
18746 65583
10194 65583
10194 24947
24947 25792
76658 25792
76658 85175
81848 85175
81848 79197
79197 2757
29174 2757
44226 29174
44226 34159
34159 99457
28942 99457...

output:

10555
56058
82467
21307
21307
21307
82467
82467
82467
82467
60615
82467
60615
82467
60615
60615
46358
60615
83755
83755
83755
60615
60615
60615
60615
60615
83755
67541
83755
67541
14906
67541
67541
60615
67541
67541
14906
14906
4010
14906
4010
4010
4010
4010
4010
4010
83755
83755
83755
4010
4010
149...

result:

ok 100000 lines

Test #73:

score: 0
Accepted
time: 356ms
memory: 31672kb

input:

100000
1 12920
73131 12920
73131 99847
4593 99847
76487 4593
46954 76487
46954 60243
60243 95105
95105 49129
49129 53386
78031 53386
78031 92570
68539 92570
40271 68539
40271 93254
93254 38074
2788 38074
2788 34173
34173 74634
16540 74634
16540 95480
95480 88588
88588 86691
86691 10238
94714 10238
1...

output:

57128
15224
15224
50383
15224
50383
50383
50383
50383
38963
38963
759
38963
38963
50383
38963
38963
38963
38963
38963
38963
38963
38963
38963
48498
48498
63003
48498
63003
48498
48498
38963
48498
48498
48498
38963
38963
38963
38963
38963
38963
88857
88857
13554
13554
759
13554
759
13554
13554
13554
...

result:

ok 100000 lines

Test #74:

score: 0
Accepted
time: 364ms
memory: 32552kb

input:

100000
35148 1
35148 52752
80403 52752
133 80403
133 93557
93557 30133
52971 30133
52971 43112
43112 17257
17257 24930
24930 68570
68570 69423
69423 92768
63896 92768
27067 63896
34049 27067
32396 34049
32396 60898
60898 4966
30033 4966
93557 11313
30033 97302
97302 57734
72257 57734
72257 82766
827...

output:

29474
70651
29474
29474
29474
29474
34885
29474
29474
29474
29474
81350
29474
29474
29474
57221
29474
29474
34885
34885
3794
3794
3794
34885
34885
29474
29474
29474
34885
29474
29474
57221
57221
56904
57221
56904
56904
56904
57221
56904
57221
57221
57221
56904
56904
56904
56904
81350
56904
56904
569...

result:

ok 100000 lines

Test #75:

score: 0
Accepted
time: 342ms
memory: 31864kb

input:

100000
1 1853
1853 78506
78506 85469
37490 85469
81108 37490
660 81108
660 61564
1105 61564
50251 1105
71997 50251
53552 71997
51683 53552
91301 51683
91301 89067
89067 90800
17919 90800
17919 93129
93129 88921
40505 88921
40505 15029
8759 15029
64817 8759
23942 64817
52873 23942
73957 52873
73957 2...

output:

18191
24643
24643
24643
24643
89659
89659
89659
51145
51145
75847
51145
63468
51145
51145
51145
51145
51145
63468
51145
63468
82561
63468
63468
18423
63468
63468
63468
18423
63468
18423
63468
63468
63468
63468
63468
18423
63468
63468
626
63468
626
626
82561
626
626
63468
626
63468
63468
18423
18423
...

result:

ok 100000 lines

Test #76:

score: -100
Time Limit Exceeded

input:

100000
51870 1
51870 75058
73916 51870
74567 73916
73916 47233
69274 47233
49210 47233
85439 49210
49210 54488
54488 57299
54488 48851
48851 51122
94668 48851
64821 94668
94668 53842
54910 53842
80036 53842
80036 7071
80036 19734
19734 86001
95347 19734
67425 95347
73097 95347
26470 73097
270 73097
...

output:

85716
19544
18702
65123
66289
99334
99334
22901
42249
42249
9286
95411
22314
22314
22314
82726
79767
94140
87384
87384
16151
65095
73459
68748
5835
5835
5835
89335
33031
85026
85026
85026
48977
6587
32880
82781
82781
63903
63903
26339
32045
32045
45013
45013
31043
4553
62229
59840
54643
52296
52296
...

result: