QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#326566#1411. Communication Jammingsocpite100 ✓476ms37160kbC++202.5kb2024-02-13 14:07:462024-02-13 14:07:46

Judging History

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

  • [2024-02-13 14:07:46]
  • 评测
  • 测评结果:100
  • 用时:476ms
  • 内存:37160kb
  • [2024-02-13 14:07:46]
  • 提交

answer


// #include "assistant.h"
#include<bits/stdc++.h>
using namespace std;

const int maxn = 2e5+5;
const int INF = 1e9+5;

map<int, vector<pair<int, int>>> g1, g2;

int n, m1, m2, q;

int X1[maxn], Y1[maxn];
int X2[maxn], Y2[maxn];

bool cmp1(pair<int, int> a, pair<int, int> b){
	return min(X1[a.first], X1[a.second]) < min(X1[b.first], X1[b.second]); 
}

bool cmp2(pair<int, int> a, pair<int, int> b){
	return min(X2[a.first], X2[a.second]) < min(X2[b.first], X2[b.second]); 
}

int up[maxn];
pair<int, int> rg[maxn];
multiset<int> ms;
int t[maxn];

int Find(int x){
	if(!up[x])return x;
	else return up[x] = Find(up[x]); 
}

void Union(int a, int b, int md, int y){
	a = Find(a);
	b = Find(b);
	if(a > b)swap(a, b);
	if(b > n){
		up[b] = a;
		return;
	}
	if(rg[a].first > rg[b].first)swap(a, b);
	if(md == 1)t[rg[a].second] = y;
	else {
		if(ms.find(t[rg[a].second]) == ms.end())cout << "SUS" << endl;
		else ms.erase(ms.find(t[rg[a].second]));
	}
	up[b] = a;
	rg[a].second = rg[b].second;
}

vector<pair<int, int>> ans;

int main(){
	cin >> n >> m1 >> m2 >> q;
	for(int i = 1; i <= n; i++){
		X1[i] = X2[i] = i;
	}
	for(int i = 1; i <= m1; i++){
		cin >> X1[i + n] >> Y1[i + n];
	}
	for(int i = 0; i < n + m1 - 1; i++){
		int ty, a, b;
		cin >> ty >> a >> b;
		if(ty == 1)g1[max(Y1[a], Y1[b+n])].push_back({a, b+n});
		else g1[max(Y1[a+n], Y1[b+n])].push_back({a+n, b+n});
	}
	g1[0].push_back({0, 0});
	g1[0].clear();

	for(int i = 1; i <= m2; i++){
		cin >> X2[i + n] >> Y2[i + n];
		Y2[i+n] *= -1;
	}
	for(int i = 0; i < n + m2 - 1; i++){
		int ty, a, b;
		cin >> ty >> a >> b;
		if(ty == 1)g2[max(Y2[a], Y2[b+n])].push_back({a, b+n});
		else g2[max(Y2[a+n], Y2[b+n])].push_back({a+n, b+n});
	}
	// cout << "SUS" << endl;
	memset(up, 0, sizeof(up));
	for(int i = 1; i <= n; i++)rg[i] = {i, i};
	for(auto ele: g2){
		auto vec = ele.second;
		sort(vec.begin(), vec.end(), cmp2);
		for(auto v: vec)Union(v.first, v.second, 1, ele.first);
	}
	for(int i = 1; i <= n; i++)ms.insert(t[i]);
	memset(up, 0, sizeof(up));
	for(int i = 1; i <= n; i++)rg[i] = {i, i};
	for(auto ele: g1){
		auto vec = ele.second;
		sort(vec.begin(), vec.end(), cmp1);
		for(auto v: vec)Union(v.first, v.second, 0, ele.first);
		ans.push_back({ele.first, *ms.rbegin()});
		// cout << *ms.rbegin() << endl;
	}
	while(q--){
		int x;
		cin >> x;
		cout << -(*(lower_bound(ans.begin(), ans.end(), make_pair(x, INF))-1)).second << "\n";
	}

}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 7796kb

input:

100 99 99 100
40 71
79 29
1 20
88 54
70 38
77 30
31 12
79 81
84 34
17 65
68 57
40 2
14 22
56 3
15 17
11 75
36 77
52 7
30 91
82 13
19 64
44 14
63 41
38 18
99 84
22 49
68 39
64 63
99 93
8 48
66 10
6 83
45 35
94 37
58 87
89 15
71 4
75 60
59 42
74 62
56 59
82 73
90 24
76 95
36 21
91 67
33 31
13 79
20 50...

output:

-98
-98
-95
-95
-95
-99
-98
-98
-95
-98
-98
-99
-98
-98
-89
-95
-98
-98
-99
-98
-98
-95
-99
-95
-98
-95
-95
-95
-95
-95
-95
-95
-98
-98
-95
-99
-98
-98
-98
-99
-95
-98
-95
-98
-98
-98
-95
-95
-89
-98
-98
-95
-98
-95
-99
-99
-95
-99
-98
-98
-95
-98
-98
-95
-98
-98
-95
-98
-95
-99
-98
-95
-98
-95
-95
...

result:

ok 100 lines

Test #2:

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

input:

100 99 99 100
62 48
60 86
34 55
43 69
80 46
37 29
9 61
54 44
1 98
73 39
98 64
59 62
60 71
93 33
27 27
18 99
56 43
35 81
39 93
82 89
64 45
46 17
100 34
75 85
70 74
84 60
51 63
81 6
72 24
16 76
23 73
42 50
69 84
87 87
2 1
48 68
40 5
69 40
84 41
54 51
15 9
97 7
31 92
12 16
32 4
77 47
17 30
6 58
30 56
4...

output:

-97
-99
-99
-99
-97
-97
-99
-97
-97
-97
-97
-97
-97
-99
-99
-97
-97
-99
-99
-99
-97
-97
-97
-99
-99
-99
-97
-97
-97
-97
-97
-1
-97
-99
-97
-97
-97
-97
-97
-97
-99
-97
-97
-97
-99
-96
-99
-99
-96
-97
0
-97
-97
-97
-97
-97
-97
-38
-97
-97
-99
-97
-97
-99
-96
-97
-99
-97
-97
-97
-97
-99
-97
-99
-97
-97...

result:

ok 100 lines

Test #3:

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

input:

100 99 99 100
77 73
75 16
56 37
48 27
95 40
88 99
26 87
25 14
44 43
7 55
44 4
55 2
26 23
42 68
10 26
89 1
21 19
37 35
83 72
20 20
21 81
6 46
1 18
3 90
91 71
69 65
67 38
69 63
98 10
39 69
46 42
88 93
34 92
59 6
50 47
86 49
30 24
74 21
81 78
12 61
66 53
30 98
9 45
16 32
95 51
34 77
90 67
54 59
76 80
7...

output:

-99
-93
-99
-91
-99
-91
-99
-93
-93
-93
-93
-93
-99
-99
-99
-93
-93
-93
-99
-91
-91
-93
-93
-93
-99
-91
-99
-99
-93
-99
-91
-99
-93
-99
-99
-99
-99
0
-91
-93
-91
-93
-93
-99
-99
-99
-99
-99
-93
-99
-93
-99
-91
-93
-91
-91
-93
-91
-93
-93
-99
-93
-91
-99
-93
-91
-99
-99
-93
-93
-99
-91
-61
-93
-93
-9...

result:

ok 100 lines

Test #4:

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

input:

100 99 99 100
24 3
87 3
37 2
37 7
23 2
42 2
92 8
22 4
78 3
86 1
48 3
64 5
94 1
100 2
25 1
81 7
36 10
10 2
8 3
97 4
19 1
68 3
16 3
14 1
19 6
70 4
29 2
97 3
88 1
58 10
35 1
83 4
32 9
56 3
15 4
90 1
6 5
65 1
51 1
43 5
72 9
2 1
69 2
3 3
42 1
74 4
16 2
52 4
61 3
76 1
54 2
65 2
54 1
77 2
67 1
81 6
29 3
34...

output:

0
0
0
0
0
-7
0
0
0
0
-7
0
0
0
0
-9
0
0
0
0
0
0
0
-2
0
0
0
0
-10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-7
0
0
0
0
0
0
0
0
0
0
0
0
-7
-7
0
-9
0
0
0
0
0
-7
0
-10
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 100 lines

Test #5:

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

input:

100 99 99 100
22 94
11 7
7 98
57 63
31 77
2 23
83 91
60 73
59 51
75 57
5 96
98 41
45 19
73 53
13 82
95 97
63 72
38 4
94 60
49 26
79 8
41 92
32 9
8 6
82 56
68 64
33 36
54 34
77 87
71 31
13 80
66 83
44 14
70 32
91 76
51 24
52 84
47 68
85 89
100 20
73 55
88 13
24 81
29 86
18 79
3 22
97 21
81 45
23 1
75...

output:

-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-3
-16
-3
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-3
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16
-16...

result:

ok 100 lines

Test #6:

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

input:

100 99 99 100
50 1
18 1
34 3
24 3
6 2
42 4
14 5
69 1
65 4
36 1
19 3
36 6
73 2
53 1
41 1
32 2
6 1
75 1
45 2
27 1
14 1
15 4
82 2
64 1
10 1
76 3
50 3
19 1
12 3
39 1
60 2
98 2
71 5
55 6
97 1
40 3
38 5
46 1
51 5
2 1
57 3
62 2
35 1
96 3
88 7
60 13
59 1
26 2
91 10
12 4
91 1
62 1
17 2
77 6
66 1
21 14
84 1
2...

output:

0
0
-90
-90
0
0
0
0
0
0
0
0
0
0
0
0
0
-35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-90
0
0
0
0
0
-99
0
-90
0
0
0
-90
0
-99
-99
-99
0
0
0
0
0
0
0
0
0
-99
0
0
0
0
0
0
0
0
0
0
0
0
-30
-90
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-99
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 lines

Test #7:

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

input:

100 99 99 100
50 71
6 86
31 83
99 31
17 84
74 90
21 43
29 30
44 57
69 41
27 33
37 78
75 16
99 8
24 98
42 10
38 72
64 67
62 68
93 35
25 99
30 88
66 12
91 65
84 66
12 23
72 54
96 95
3 34
2 29
65 42
44 37
61 45
5 85
20 40
39 73
70 70
81 21
14 62
28 9
16 61
9 5
95 76
90 36
54 17
79 75
48 4
52 18
31 96
6...

output:

-51
-33
-88
-11
-96
-92
-53
-53
-41
-46
-17
-24
-44
-98
-1
-94
-41
-60
-91
-41
-99
-4
-48
-94
-66
-90
-72
-66
-32
-60
-60
-56
-10
-72
-78
-96
-50
-31
-23
-16
-37
-9
-20
-22
-45
-28
-74
-45
-86
-67
-82
-70
-50
-63
-76
-41
-6
-16
-41
-76
-34
-72
-88
-7
-35
-80
-7
-82
-26
-15
-31
-22
-47
0
-3
-28
-31
-...

result:

ok 100 lines

Test #8:

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

input:

100 99 99 100
94 28
42 79
56 77
38 8
32 9
2 19
77 84
84 16
16 47
43 2
53 89
89 71
13 63
3 18
85 97
5 96
70 72
48 66
10 88
7 49
40 81
57 43
95 61
66 45
61 11
67 24
43 92
32 34
59 26
16 22
35 74
50 38
17 67
63 76
19 4
62 42
53 64
35 33
21 86
93 37
46 12
48 39
8 98
25 85
2 50
88 32
12 48
25 41
95 54
91...

output:

-5
-37
-40
-88
-32
-27
-47
-86
-85
-99
-86
-70
-99
-31
-21
-96
-42
-66
-9
-41
-23
-22
-20
-74
-79
-60
-85
-20
-58
-56
-34
-63
-94
-16
-63
-33
-85
-59
-96
-75
-39
-68
-66
-85
-7
-68
-17
-53
-55
-85
-48
-94
-21
-7
-35
-47
-8
-22
-76
-26
-74
-15
-92
-91
-36
-40
-45
-56
-26
-70
-13
-44
-62
-91
-44
-28
-...

result:

ok 100 lines

Test #9:

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

input:

100 99 99 100
37 14
14 12
48 41
89 79
89 38
19 1
77 29
45 5
80 76
72 96
74 10
61 59
98 7
14 20
2 23
41 15
9 33
19 37
46 8
96 3
94 90
68 13
99 92
76 68
25 17
36 40
68 83
77 66
39 82
79 16
12 63
52 42
73 53
56 98
56 24
63 91
34 46
28 19
38 80
90 11
47 43
17 70
29 36
5 84
42 99
51 65
43 6
59 44
4 81
42...

output:

-40
-84
-87
-31
-53
-87
-38
-5
-36
-15
-84
-85
-58
-45
-85
-96
-10
-66
-81
-56
-15
-37
-68
-51
-75
-34
0
-3
-21
-99
-51
-54
-24
-73
-88
-7
-8
-62
-21
-10
-21
-96
-48
-42
-58
-15
-78
-31
-51
-44
-34
-99
-26
-97
-59
-56
-21
-90
-16
-1
-84
-25
-71
-73
-36
-11
-28
-95
-66
-47
-92
-31
-46
-15
-81
-74
-43...

result:

ok 100 lines

Test #10:

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

input:

100 99 99 100
76 93
59 12
54 11
40 74
73 43
48 47
38 31
95 78
65 37
28 44
96 17
35 13
90 85
86 65
81 4
88 79
71 64
47 15
41 63
52 46
32 90
42 73
16 9
62 10
87 94
97 70
2 99
42 21
6 5
21 6
58 58
56 76
100 69
46 83
12 42
31 75
74 14
97 24
37 50
9 35
5 8
22 84
69 39
30 49
54 52
77 51
27 38
94 45
25 16
...

output:

-38
-22
-40
-98
-25
-4
-46
-80
-43
-46
-77
-98
-4
-51
-82
-85
-7
-46
-35
-51
-75
-15
-77
-70
-90
-12
-55
-12
-59
-31
-55
-62
-88
-62
-9
-51
-7
-17
-86
-85
-59
-48
-28
-43
-92
-22
-19
-22
-46
-14
-12
-51
-27
-13
-35
-4
-90
-38
-19
-70
-19
-73
-65
-75
-64
-1
-75
-94
-85
-73
-32
-70
0
-80
-94
-27
-60
-...

result:

ok 100 lines

Test #11:

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

input:

1000 999 999 1000
29 797
230 668
310 981
2 879
197 826
352 362
407 805
890 87
249 584
295 199
531 588
687 528
433 565
288 46
385 474
431 86
639 686
942 656
388 667
310 282
737 578
161 430
823 664
333 979
989 745
46 432
999 236
962 545
949 655
902 406
812 521
632 812
715 47
313 691
840 665
294 336
72...

output:

-995
-999
-998
-999
-999
-999
-999
-999
-995
-999
-995
-999
-999
-999
-999
-998
-995
-995
-998
-995
-998
-999
-995
-995
-998
-995
-999
-995
-995
-998
-999
-999
-995
-998
-999
-999
-999
-999
-999
-999
-998
-999
-995
-998
-995
-998
-995
-995
-995
-999
-995
-999
-999
-995
-998
-995
-999
-995
-999
-999
...

result:

ok 1000 lines

Test #12:

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

input:

1000 999 999 1000
113 7
720 15
233 4
882 1
419 1
818 2
746 2
168 1
682 3
470 5
927 11
673 3
945 1
178 6
25 3
460 2
26 7
709 1
746 1
563 6
309 3
280 2
774 2
657 2
133 5
512 1
394 1
634 4
175 6
720 7
272 12
825 1
287 2
787 1
327 2
978 7
705 1
758 6
716 1
101 1
46 3
273 1
545 1
62 9
316 7
247 2
917 1
7...

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
0
0
0
0
0
0
0
0
0
-12
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
-12
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-5
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...

result:

ok 1000 lines

Test #13:

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

input:

1000 999 999 1000
186 468
139 615
570 530
605 807
641 183
726 576
130 798
424 351
211 765
738 860
537 162
784 345
176 130
683 52
564 622
977 483
670 264
204 124
573 195
222 490
561 635
265 350
89 642
75 539
760 517
630 139
955 417
173 458
69 497
246 718
852 972
321 813
840 521
889 276
748 801
658 59...

output:

-22
-21
-11
-22
-21
-22
-22
-22
-22
-21
-21
-21
-22
-22
-22
-21
-21
-11
-22
-21
-21
-22
-4
-22
-11
-22
-21
-11
-11
-21
-22
-22
-21
-22
-22
-21
-22
-21
-21
-21
-22
-16
-22
-22
-8
-21
-11
-21
-21
-22
-11
-21
-22
-21
-21
-21
-21
-21
-22
-11
-22
-22
-22
-22
-22
-22
-22
-21
-21
-21
-21
-21
-11
-21
-21
-2...

result:

ok 1000 lines

Test #14:

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

input:

1000 999 999 1000
750 2
443 4
154 3
57 1
921 3
571 4
203 2
973 1
947 1
473 1
351 1
399 1
569 2
897 7
724 2
449 3
879 5
814 1
451 2
392 3
648 1
403 1
69 1
960 1
631 1
885 1
124 2
243 13
735 3
245 2
867 1
295 12
14 1
765 2
972 2
474 2
715 2
949 1
433 1
495 2
845 2
999 1
669 4
560 5
393 2
462 6
501 4
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-997
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-965
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
-997
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #15:

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

input:

1000 999 999 1000
339 258
742 59
9 789
162 443
644 881
258 148
738 874
784 97
744 944
392 633
73 175
587 102
121 735
791 35
281 588
310 540
795 699
934 4
574 911
44 747
320 716
86 376
84 115
491 648
555 459
275 251
108 49
485 888
465 437
301 329
832 891
617 955
950 558
356 961
264 153
446 128
95 185...

output:

-983
-998
-998
-959
-934
-999
-999
-999
-998
-999
-999
-999
-999
-998
-999
-998
-998
-999
-998
-999
-998
-945
-999
-998
-999
-998
-999
-959
-999
-999
-934
-998
-999
-998
-999
-998
-998
-998
-983
-983
-983
-999
-998
-999
-998
-999
-998
-999
-983
-999
-998
-999
-998
-999
-945
-999
-999
-998
-998
-999
...

result:

ok 1000 lines

Test #16:

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

input:

1000 999 999 1000
664 444
906 415
58 123
271 234
85 819
661 994
767 121
918 963
229 344
431 250
474 889
87 908
329 528
172 290
43 958
647 944
169 510
287 1
624 690
59 520
537 903
764 639
820 441
915 89
429 655
286 877
504 484
742 143
241 986
281 129
531 798
4 519
521 401
33 32
853 326
228 157
344 75...

output:

-999
-998
-990
-999
-999
-999
-996
-990
-999
-999
-999
-998
-999
-999
-999
-999
-999
-999
-999
-999
-996
-999
-999
-999
-999
-999
-941
-999
-999
-999
-999
-999
-999
-999
-999
-996
-999
-998
-999
-999
-999
-999
-999
-996
-999
-999
-999
-999
-999
-999
-996
-996
-999
-999
-999
-999
-999
-999
-990
-999
...

result:

ok 1000 lines

Test #17:

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

input:

1000 999 999 1000
247 409
208 518
746 474
615 302
137 504
690 823
523 416
729 795
652 183
597 121
643 287
634 157
985 867
375 359
456 549
553 637
509 900
434 793
13 147
36 125
542 742
647 413
979 712
153 391
20 577
800 895
480 122
509 478
575 281
552 305
468 468
155 980
607 966
285 256
437 576
295 8...

output:

-506
-680
-606
-408
-188
-465
-70
-967
-515
-311
-652
-448
-15
-436
-541
-840
-465
-430
-766
-814
-885
-250
-900
-640
-689
-58
-101
-387
-372
-862
-739
-639
-263
-380
-265
-814
-700
-244
-209
-836
-147
-590
-342
-769
-612
-935
-455
-133
-233
-702
-26
-594
-874
-538
-963
-42
-491
-750
-675
-578
-351
...

result:

ok 1000 lines

Test #18:

score: 0
Accepted
time: 2ms
memory: 8000kb

input:

1000 999 999 1000
76 531
513 936
377 350
881 868
184 119
42 199
417 516
446 82
430 865
588 775
519 198
827 966
475 677
573 195
49 247
666 61
977 698
181 335
991 241
33 100
429 605
421 311
736 913
242 903
296 266
505 772
605 85
136 878
323 215
770 291
301 741
137 73
133 265
464 160
101 407
84 996
863...

output:

-195
-512
-820
-313
-761
-661
-899
-136
-851
-230
-916
-246
-288
-116
-558
-761
-424
-144
-846
-957
-862
-59
-265
-331
-774
-945
-165
-280
-104
-398
-710
-738
-240
-772
-140
-793
-284
-714
-548
-138
-605
-239
-765
-312
-943
-960
-315
-331
-717
-265
-385
-703
-371
-847
-88
-200
-949
-984
-499
-932
-4...

result:

ok 1000 lines

Test #19:

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

input:

1000 999 999 1000
981 981
567 567
622 622
868 868
676 676
696 696
996 996
580 580
20 20
388 388
468 468
333 333
65 65
291 291
459 459
472 472
978 978
251 251
518 518
989 989
101 101
825 825
599 599
565 565
339 339
486 486
292 292
935 935
796 796
290 290
371 371
715 715
934 934
898 898
160 160
96 96
...

output:

-548
-615
-864
-712
-51
-205
-831
-64
-182
-307
-701
-414
-127
-762
-163
-122
-985
-868
-539
-375
-428
-679
-167
-186
-389
-224
-953
-9
-396
-606
-616
-794
-51
-662
-112
-505
-569
-100
-99
-558
-268
-109
-72
-912
-202
-884
-637
-523
-384
-774
-268
-288
-405
-334
-491
-193
-994
-996
-221
-359
-884
-3...

result:

ok 1000 lines

Test #20:

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

input:

1000 999 999 1000
899 101
360 642
326 676
517 486
488 515
846 155
148 850
906 94
842 157
575 425
358 640
259 743
920 80
280 721
122 878
962 38
356 645
614 386
861 138
419 581
923 78
859 141
916 85
700 300
157 844
197 801
741 260
972 27
219 780
182 821
115 887
415 584
75 924
186 813
758 242
659 341
5...

output:

-167
-767
-477
-985
-709
-570
-522
-595
-552
-748
-54
-54
-150
-444
-182
-885
-94
-627
-63
-189
-623
-756
-187
-887
-15
-312
-62
-351
-832
-54
-902
-143
-523
-783
-267
-791
-931
-597
-437
-610
-388
-372
-153
-229
-519
-829
-744
-600
-146
-709
-111
-510
-937
-737
-528
-39
-721
-115
-612
-434
-335
-15...

result:

ok 1000 lines

Test #21:

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

input:

300 999 999 1000
192 269
245 1
237 211
479 2
284 180
478 409
79 2
262 1
213 268
371 93
34 2
462 75
408 36
268 270
434 2
347 1
84 1
363 2
486 442
122 392
143 24
25 1
398 1
169 138
304 1
396 1
175 276
57 2
158 102
322 1
24 1
365 2
270 1
280 169
77 2
38 1
235 1
452 25
297 203
38 213
341 63
427 2
384 1
...

output:

0
-501
0
-490
0
-500
-477
0
0
0
-477
0
-500
-501
-492
-500
-501
0
-492
-477
0
0
0
-500
0
-501
-500
0
0
-501
0
-501
-501
-490
0
-501
-500
0
0
-501
-492
0
-500
0
-492
0
0
-501
0
-500
-492
-501
-490
0
-477
0
-501
-492
-501
-501
-492
0
0
-490
0
-501
-501
-501
0
0
0
-501
-500
0
-492
-501
0
-501
-490
0
-5...

result:

ok 1000 lines

Test #22:

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

input:

300 999 299 1000
220 2
282 249
206 176
368 2
363 257
239 34
431 1
229 1
137 8
401 1
257 316
24 274
425 1
78 1
494 103
35 1
474 15
430 49
352 1
150 1
416 1
385 1
31 2
194 206
139 378
346 461
25 159
433 186
347 1
419 9
29 171
407 105
111 2
428 1
255 246
91 2
409 1
494 1
470 2
17 47
271 132
127 198
267...

output:

-228
-189
-67
0
-163
-11
0
-147
0
0
-107
-72
0
-277
0
0
0
0
0
-62
-184
0
0
0
-73
0
-124
-98
0
0
-249
-184
-43
0
0
-232
-299
0
0
-245
-166
-205
-119
0
0
0
-203
-218
0
-197
0
0
-50
-106
0
0
-41
0
0
0
0
0
0
-149
-11
-163
0
0
0
0
-211
-176
-56
-273
0
0
0
-166
0
0
0
-171
-237
0
0
-251
0
0
0
0
0
-256
-247...

result:

ok 1000 lines

Test #23:

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

input:

300 299 999 1000
168 93
65 180
281 223
279 131
226 31
8 247
224 122
58 137
56 76
247 98
117 271
169 201
182 138
213 55
3 133
229 72
174 4
34 274
203 3
179 299
47 195
87 286
54 24
220 257
166 209
161 119
2 264
179 82
298 113
70 140
276 169
169 37
232 259
274 291
223 251
299 210
288 170
227 127
216 18...

output:

0
0
-257
0
0
0
0
0
-96
0
-228
0
-391
-347
0
0
-235
-383
0
0
0
0
0
0
0
-215
-376
0
-488
0
-429
0
0
0
-412
0
0
0
-379
-388
0
-444
0
0
0
0
0
-451
0
0
-420
0
0
0
0
-57
0
0
-146
-478
0
0
0
0
-406
0
0
0
-363
0
-291
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-192
0
-200
0
0
0
0
-422
0
-15
0
0
-63
0
-379
-442
-228
0
-19...

result:

ok 1000 lines

Test #24:

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

input:

400 999 999 1000
479 1
30 1
273 365
354 2
342 243
65 399
485 1
204 1
160 1
196 1
429 1
127 139
379 1
408 1
445 1
307 2
149 1
298 437
459 1
367 1
49 1
302 313
487 137
76 106
253 26
60 68
464 1
428 381
128 373
405 369
253 1
83 1
308 499
216 382
98 1
53 39
45 362
232 1
397 11
266 308
226 1
382 371
292 ...

output:

0
0
-501
-499
-500
0
0
0
-501
0
-501
-501
0
0
0
0
-501
-501
0
-501
-428
0
-501
0
0
-501
-494
0
0
-500
0
-494
0
-501
-499
0
-501
0
-501
-501
0
-501
-499
0
0
0
-501
0
-471
0
-501
-501
0
-501
0
-499
0
0
-479
-501
-500
-501
0
-501
-501
-501
0
-501
0
-501
-501
-501
0
0
-501
0
-501
0
0
0
0
0
-501
-501
-50...

result:

ok 1000 lines

Test #25:

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

input:

400 999 399 1000
305 1
472 58
490 1
270 416
239 2
380 2
491 325
311 1
422 1
404 25
429 362
66 354
162 353
291 300
129 1
63 139
337 1
84 488
253 1
406 271
406 124
211 57
246 28
242 2
234 359
76 1
304 414
243 112
189 501
401 1
268 207
218 1
152 108
258 134
449 1
477 303
289 1
132 1
224 1
88 259
386 25...

output:

0
-79
0
0
-13
0
-226
-277
0
-322
-226
-9
0
-170
-239
-112
-178
0
0
0
0
-190
0
0
0
-309
0
-326
0
-32
-94
0
0
-193
-117
-65
-266
-9
-303
-151
-246
-398
-379
-332
-392
-331
-339
-399
0
-126
0
0
0
0
0
0
0
-1
-325
-148
-399
-25
0
0
-361
0
0
-61
0
-199
-46
0
0
0
-243
-111
0
-175
-321
0
-316
0
-320
0
0
-22...

result:

ok 1000 lines

Test #26:

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

input:

400 399 999 1000
149 272
145 399
344 303
152 226
247 258
23 143
219 324
184 354
204 49
96 275
160 33
65 137
102 376
303 78
120 379
395 183
342 25
388 127
372 148
18 296
167 282
196 166
4 128
272 398
387 346
219 253
377 290
284 338
17 252
88 16
10 322
201 309
276 185
357 138
30 265
317 69
191 62
117 ...

output:

-429
-8
0
0
0
0
0
0
-412
-150
-329
0
-112
0
0
0
0
-205
0
-356
0
0
0
-489
0
-171
0
-334
-244
-493
0
0
-501
-144
-354
0
-171
-221
-86
-168
0
-111
0
-242
0
0
0
0
0
0
0
0
0
0
-470
0
0
0
0
0
0
0
-378
-185
-396
-457
-421
0
0
-13
-352
-58
-484
0
0
-488
0
0
-424
0
-86
0
0
0
-245
-366
0
0
-119
-286
0
0
0
0
-...

result:

ok 1000 lines

Subtask #2:

score: 80
Accepted

Dependency #1:

100%
Accepted

Test #27:

score: 80
Accepted
time: 108ms
memory: 16372kb

input:

30000 29999 29999 30000
24803 3231
24780 22370
25989 13379
17289 23919
4723 23653
27989 9338
17425 9778
8696 29289
13009 3372
8978 23725
18744 264
13827 13631
2251 3426
5753 177
20702 1305
10078 17722
16385 17752
15214 5785
13271 5369
12684 14073
4841 9874
28778 9172
11261 20111
11255 22886
13178 11...

output:

-29999
-29999
-29999
-29999
-29999
-29988
-29988
-29999
-29996
-29996
-29999
-29999
-29999
-29999
-29999
-29999
-29967
-29996
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29988
-29999
-29999
-29999
-29988
-29999
-29988
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29988
-29999
-29999...

result:

ok 30000 lines

Test #28:

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

input:

30000 29999 29999 30000
8387 26851
14683 19970
27753 6841
21903 27957
22030 869
10692 990
22656 16810
4594 15919
7298 16881
16066 6202
17661 11283
1078 8640
23192 17133
25777 5807
25119 5002
21601 1410
28594 10327
25915 5758
23262 14027
14400 3542
29721 2561
10377 23894
2651 18720
21084 12612
28904 ...

output:

-29997
-29997
-29999
-29997
-29999
-29995
-29997
-29999
-29999
-29999
-29997
-29997
-29999
-29997
-29997
-29997
-29999
-29997
-29997
-29997
-29999
-29999
-29999
-29999
-29999
-29999
-29995
-29997
-29999
-29999
-26475
-29999
-29999
-29997
-29999
-29999
-29997
-29999
-29999
-29999
-29995
-29999
-29999...

result:

ok 30000 lines

Test #29:

score: 0
Accepted
time: 109ms
memory: 16156kb

input:

30000 29999 29999 30000
24591 6025
8913 7207
20780 8627
7760 18292
15269 8601
5417 11359
3556 12752
5602 18793
25238 11944
4444 11625
25172 22182
19144 12822
29110 3566
19011 12029
21481 21416
8816 7869
13965 26736
9395 12970
5309 24959
884 13449
2349 17989
19889 13969
501 11832
17694 3472
2046 1957...

output:

-29999
-29968
-29987
-29999
-29995
-29999
-29999
-29999
-29999
-29999
-29991
-29999
-29999
-29999
-29999
-29999
-29999
-29968
-29999
-29991
-29999
-29995
-29999
-29999
-29968
-29999
-29991
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29999
-29991
-29999
-29999...

result:

ok 30000 lines

Test #30:

score: 0
Accepted
time: 91ms
memory: 10560kb

input:

30000 29999 29999 30000
11908 1
16710 16
6870 4
26135 2
13024 7
4095 1
19266 4
11629 1
26805 3
5707 3
22805 5
13427 4
21904 3
20649 6
9191 1
18476 2
22756 1
575 7
9935 1
25710 1
28187 2
6415 1
11619 12
10547 8
29954 7
4373 4
18450 3
20551 3
16510 10
25424 3
10754 16
2925 1
130 8
18911 1
8136 15
2147...

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
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
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
0
0
0
0
0
...

result:

ok 30000 lines

Test #31:

score: 0
Accepted
time: 91ms
memory: 13460kb

input:

30000 29999 29999 30000
14591 16131
28720 18766
21971 19650
11469 15394
1834 25532
19948 19998
21139 10364
2014 13458
22600 27768
12831 558
13085 4454
1250 18870
22073 24943
10415 17034
18679 26839
28777 14579
4595 5044
9903 27084
7767 17302
16836 6066
12494 29031
15589 3263
5698 25887
26486 16255
2...

output:

-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-23
-35
-35
-34
-35
-35
-34
-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-22
-35
-35
-35
-34
-35
-35
-35
-35
-35
-35
-35
-35
-35
-35
-22
-35
-35
-22
-35
-35
-35
-35
-35
-35
-35
-22
-35
-35
-35
-17
-35
-35
-23
-35
-23
-35
-35
-35
-32
-35
-35
-35
-35
...

result:

ok 30000 lines

Test #32:

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

input:

30000 29999 29999 30000
139 1
13135 9
1865 6
6009 9
15537 6
24407 10
11900 1
2410 1
11847 5
19408 5
11171 2
19025 6
22549 1
28396 4
18562 7
4501 11
1609 1
10410 1
16922 1
19063 1
22670 1
5370 2
4404 6
13425 5
14804 1
25345 1
825 6
17157 1
9393 2
13223 1
17049 1
14174 4
490 2
17561 1
14672 1
15430 21...

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
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
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
0
0
0
0
0
...

result:

ok 30000 lines

Test #33:

score: 0
Accepted
time: 107ms
memory: 16408kb

input:

30000 29999 29999 30000
2458 19287
2361 20031
25561 10305
23969 1095
18387 184
26595 17560
26162 7555
15415 7384
19670 18689
13583 7937
17918 7764
15976 29411
27453 21353
5937 17076
16191 29342
16972 7700
27249 18726
3446 21893
25186 23214
13157 26475
14280 13969
17873 2898
9834 9631
24088 26661
156...

output:

-24899
-15083
-15924
-21990
-13459
-10506
-10930
-11801
-8384
-25164
-2455
-6246
-23966
-2986
-23640
-25643
-22741
-24157
-12671
-26187
-5922
-21558
-18183
-3320
-11560
-25575
-2147
-5416
-5879
-1392
-19307
-20246
-4489
-7240
-5245
-2198
-11005
-24023
-20537
-16827
-28829
-13927
-10499
-27232
-3715
...

result:

ok 30000 lines

Test #34:

score: 0
Accepted
time: 113ms
memory: 17860kb

input:

30000 29999 29999 30000
14205 27195
13136 18520
24263 27086
28804 16210
26216 25755
6223 15923
8744 9797
23595 12563
16176 9753
3236 12632
16961 26112
5979 29300
9491 26078
5848 22156
22405 26519
27628 9093
6960 24388
8804 29119
3039 15658
12516 25281
17563 23209
10968 21910
21246 6770
12375 3421
21...

output:

-6604
-9119
-2053
-16549
-5678
-23602
-12153
-23560
-9747
-10214
-20515
-13437
-21364
-20800
-4990
-15054
-22538
-8109
-23791
-14536
-13581
-27019
-12636
-16341
-6450
-15883
-26887
-15183
-20822
-24587
-25346
-2806
-8398
-25631
-9725
-22784
-20761
-15187
-20593
-5781
-21705
-24293
-6948
-22486
-2057...

result:

ok 30000 lines

Test #35:

score: 0
Accepted
time: 113ms
memory: 16324kb

input:

30000 29999 29999 30000
14629 16558
21895 12527
721 28963
16869 17167
2446 20395
22774 11036
18869 28706
27610 8235
4289 7421
1423 16743
18912 10825
14964 26330
24035 21643
10188 16831
20713 19680
10934 17257
21832 18316
24738 22897
5866 18054
20452 10134
738 21863
2719 17243
11296 27664
27911 25734...

output:

-20113
-3424
-6147
-3080
-18330
-21229
-12919
-6434
-5037
-7145
-29772
-24016
-18689
-29940
-28966
-26137
-12650
-10245
-2571
-26611
-10417
-129
-19978
-18755
-313
-10800
-27524
-18757
-24600
-20011
-20670
-28848
-27207
-5964
-5280
-4982
-19781
-4880
-169
-29056
-5012
-27836
-27717
-25000
-17260
-18...

result:

ok 30000 lines

Test #36:

score: 0
Accepted
time: 112ms
memory: 16284kb

input:

30000 29999 29999 30000
5524 22034
2598 18331
23356 4988
3998 2159
16652 23799
10539 14541
9926 22048
24572 20975
5573 22163
24118 22479
14228 19326
5144 26210
3870 1387
20575 29703
18117 8401
9055 11258
479 24013
12436 22773
17865 21639
18829 27822
3958 21429
8211 27778
6448 20938
431 6806
2843 527...

output:

-14627
-27982
-25318
-5157
-21731
-18084
-23268
-23809
-17182
-11809
-28136
-7592
-5877
-19748
-28973
-1643
-24071
-9771
-28680
-7575
-22579
-11352
-18945
-1891
-13976
-2224
-17152
-11305
-12921
-26156
-11915
-15311
-20725
-22613
-20052
-23888
-8123
-13562
-15110
-15770
-14704
-2435
-3006
-29871
-13...

result:

ok 30000 lines

Test #37:

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

input:

100000 99999 99999 100000
1336 13083
95635 88516
21454 25025
95428 71356
70990 68827
15855 23620
47078 67259
94490 44879
85128 6209
2991 97398
14905 98853
52809 34885
93039 47738
27997 459
84172 65841
30676 54392
30335 35964
55181 63319
57657 22995
57305 35312
32226 39035
32505 49092
77291 21349
288...

output:

-99999
-99999
-99999
-99999
-99999
-99999
-99999
-99989
-99989
-99989
-99999
-99989
-99999
-99999
-99989
-99989
-99989
-99895
-99999
-99999
-99999
-99999
-99895
-99895
-99999
-99853
-99999
-99999
-99999
-99989
-99999
-99989
-99868
-99989
-99999
-99999
-99974
-99999
-99999
-99999
-99999
-99999
-99989...

result:

ok 100000 lines

Test #38:

score: 0
Accepted
time: 308ms
memory: 18152kb

input:

100000 99999 99999 100000
56611 2
36446 1
62761 2
90197 3
47191 1
75813 3
66787 3
30257 4
43052 1
29776 1
38009 2
10667 2
61184 1
16220 1
5322 4
19745 1
29548 14
22375 4
48333 2
29860 4
27996 3
70958 6
35613 2
18304 2
58393 5
52290 1
52471 1
16586 1
893 4
40768 1
85777 1
35704 2
76009 1
18046 5
5465...

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
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
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
0
0
0
0
0
...

result:

ok 100000 lines

Test #39:

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

input:

100000 99999 99999 100000
50010 97429
84042 57650
81421 25851
73875 99930
51386 86251
93583 7983
55447 74076
30649 91739
42777 28081
46699 17756
13531 60126
89749 70929
53414 81166
54880 83342
56939 62647
9886 80279
18895 16981
28728 29743
90581 13826
73125 18665
28583 90815
32173 61104
48025 84316
...

output:

-35
-35
-39
-30
-35
-39
-39
-39
-37
-39
-30
-39
-39
-37
-37
-39
-39
-39
-39
-39
-39
-39
-39
-35
-37
-35
-39
-39
-39
-37
-39
-39
-39
-39
-39
-39
-37
-39
-33
-39
-39
-39
-28
-30
-39
-39
-37
-39
-39
-37
-39
-29
-39
-35
-30
-39
-39
-39
-37
-39
-39
-39
-35
-39
-39
-39
-18
-37
-39
-39
-39
-39
-35
-37
-39
...

result:

ok 100000 lines

Test #40:

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

input:

100000 99999 99999 100000
28593 5
57587 5
22093 8
45914 7
58429 8
94000 1
54545 4
74445 1
23929 1
72155 1
66227 1
19007 2
22155 2
56899 4
56467 4
60725 9
97512 1
96661 2
23294 2
99715 3
6978 10
73043 1
24712 4
74550 4
15081 2
90375 1
43937 1
50744 2
84862 9
66569 2
74457 1
83007 2
46798 2
62793 2
17...

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
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
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
0
0
0
0
0
...

result:

ok 100000 lines

Test #41:

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

input:

100000 99999 99999 100000
87516 97359
24387 58696
22788 50314
15328 4412
60516 66395
5360 71561
98428 62929
42346 31291
13478 82799
79226 81317
25471 10182
60136 45482
26608 6024
90097 62068
75501 26821
27309 18569
70031 10582
67875 29509
46295 44159
70974 8289
76024 29428
52316 73515
31534 57501
16...

output:

-99894
-99999
-99998
-99999
-99999
-99998
-99999
-99998
-99998
-99998
-99999
-99999
-99999
-99998
-99999
-99999
-99999
-99998
-99998
-99999
-99998
-99999
-99998
-99999
-99999
-99999
-99999
-99999
-99998
-99998
-99999
-99999
-99999
-99999
-99999
-99998
-99999
-99999
-99999
-99999
-99999
-99999
-99999...

result:

ok 100000 lines

Test #42:

score: 0
Accepted
time: 470ms
memory: 36544kb

input:

100000 99999 99999 100000
27514 99688
49552 55220
81342 57945
7904 51232
26982 23004
94648 883
81791 55656
51656 58502
28235 98420
99113 24970
62474 72832
5806 3479
81752 846
60562 66837
13889 56945
69286 18988
8448 85643
11181 66731
67502 44895
39879 53374
98891 32326
73477 45913
65112 34175
13548 ...

output:

-99999
-99998
-99998
-99998
-99996
-99996
-99966
-99996
-99996
-99996
-99996
-99996
-99996
-99998
-99996
-99998
-99996
-99998
-99996
-99999
-99998
-99966
-99996
-99996
-99998
-99999
-99998
-99998
-99999
-99966
-99996
-99996
-99996
-99996
-99996
-99996
-99999
-99998
-99999
-99996
-99996
-99996
-99998...

result:

ok 100000 lines

Test #43:

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

input:

100000 99999 99999 100000
45734 35770
39609 79299
61047 77226
44050 91961
85420 15993
58468 55742
91717 2449
78865 13332
61030 75321
40785 36391
26159 34204
11190 80409
75090 81694
29225 59287
90916 31034
65641 6719
46359 33267
76546 15462
4438 71291
51590 36320
97331 2203
60366 9691
18095 58705
950...

output:

-73890
-47992
-10202
-92930
-38267
-1382
-86469
-11787
-2076
-55584
-89550
-98909
-66844
-15630
-46353
-94033
-21110
-58706
-3568
-70228
-25339
-61401
-32944
-86963
-25117
-71322
-61328
-94307
-57339
-77180
-55983
-80393
-14538
-77375
-26878
-23135
-73990
-94076
-97709
-80150
-88645
-58643
-42207
-5...

result:

ok 100000 lines

Test #44:

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

input:

100000 99999 99999 100000
72758 32625
2654 75263
21018 99946
85043 71079
58223 85158
72301 91160
8237 44217
55450 28593
37244 62423
11052 38896
69206 76661
46956 54124
21049 72266
37672 31566
97443 39122
85977 59820
99364 89908
49117 32914
31894 11828
54602 86418
54000 475
55141 45541
2358 7887
2171...

output:

-58458
-11017
-81651
-63548
-47576
-68406
-26293
-23930
-53826
-30273
-68175
-8061
-17907
-30404
-12142
-73480
-13811
-73251
-64876
-81533
-62500
-73464
-65033
-39384
-40184
-64114
-44901
-34557
-37259
-24859
-88835
-11575
-14319
-76664
-997
-90419
-90060
-73408
-23820
-1294
-53697
-95577
-83697
-62...

result:

ok 100000 lines

Test #45:

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

input:

100000 99999 99999 100000
17865 17865
13736 13736
23455 23455
6491 6491
775 775
83940 83940
43935 43935
12740 12740
46810 46810
72269 72269
85014 85014
25826 25826
15783 15783
3262 3262
19952 19952
14244 14244
42335 42335
48569 48569
39456 39456
10004 10004
38017 38017
56657 56657
1180 1180
72034 72...

output:

-49868
-22136
-22652
-99442
-235
-8360
-38180
-50978
-67567
-69939
-51537
-61634
-38468
-35621
-39932
-40054
-6821
-84050
-40552
-43044
-92902
-45210
-87922
-12945
-21948
-16452
-22764
-17888
-87860
-36029
-2916
-14185
-55551
-55881
-78688
-47694
-37093
-96373
-61177
-7082
-77876
-2067
-27877
-59850...

result:

ok 100000 lines

Test #46:

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

input:

100000 99999 99999 100000
43960 56043
53768 46231
49509 50492
40189 59811
64702 35298
20442 79557
11986 88013
39798 60204
17967 82033
18780 81220
81512 18487
49300 50700
40044 59956
38750 61249
64356 35645
6058 93943
80699 19302
21575 78424
43677 56322
61914 38087
2785 97215
40509 59491
86772 13227
...

output:

-55660
-10894
-12214
-65412
-43548
-42246
-83050
-51831
-50042
-45676
-54391
-27314
-53149
-81376
-85110
-87533
-31129
-63285
-95830
-51719
-94756
-82649
-88423
-26216
-31646
-47742
-27102
-5664
-74668
-53089
-33951
-81493
-33931
-44372
-29872
-75355
-50878
-31285
-61015
-7730
-56631
-45915
-44852
-...

result:

ok 100000 lines

Test #47:

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

input:

30000 99999 99999 100000
25704 1
9711 1
14495 1
17029 28744
549 2
26462 32208
44893 45544
10059 2
33080 23330
44540 7426
23226 1
31072 17543
40369 40827
13276 1
33577 34668
20222 1
41670 16955
8069 1
21068 1
8389 35485
40339 436
10330 17358
23927 1
1509 14960
43221 1
22015 2
15074 13752
27092 11381
...

output:

0
0
-50000
0
0
-50000
-50001
0
0
-50001
0
0
-50001
-49976
0
-50001
-50001
0
-50001
0
0
-50001
-50001
0
-50000
0
0
-50001
0
-50000
0
-50001
0
0
0
0
0
0
-50000
0
-50001
-50001
-50001
-50001
-50001
0
-49986
0
-50001
0
-50001
0
-50000
-49976
0
0
-50000
0
0
-50001
0
0
0
-50001
-50001
0
-50001
0
0
0
0
0
0...

result:

ok 100000 lines

Test #48:

score: 0
Accepted
time: 210ms
memory: 20332kb

input:

30000 99999 29999 100000
7097 11014
27635 1
16515 10607
12944 1
7216 8050
6465 1
7220 14376
20856 1
36429 20523
41750 19035
44226 26191
25 2
14304 1
29887 27643
31775 47570
27541 22873
6633 2
10878 39541
48667 1
31735 48207
12145 2
22285 24934
25192 2
19603 1
11150 1
27587 20518
17703 1
26294 2
4799...

output:

0
-19615
0
-20987
-25011
-19826
0
0
-18313
0
-13502
0
0
0
-20130
-17212
0
0
0
0
0
0
-15170
-6330
-28959
-7430
0
0
0
-19577
-20296
-5703
-16614
0
0
-28356
0
0
-11699
-1959
0
0
0
-14891
-4834
0
0
-28457
-26724
0
-20670
0
-28574
0
0
-26070
-9516
0
-17002
-17536
0
0
-18909
-17247
-11343
-8075
0
0
0
0
-2...

result:

ok 100000 lines

Test #49:

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

input:

30000 29999 99999 100000
21459 22016
23029 3340
17343 26333
20760 29666
7795 18444
21765 18630
5977 26678
6828 13803
17185 4612
7307 19329
28476 23383
26569 5497
5610 4670
8030 13542
25169 19706
25004 27375
26304 25603
14726 27443
23218 7382
16606 22201
23697 12332
23658 21011
27878 18798
15032 2822...

output:

0
0
0
0
-33783
-31880
0
-45592
-5176
0
-35489
0
0
0
-43373
0
0
0
0
0
0
0
0
0
-47984
0
0
0
0
-48166
0
0
0
-19840
0
0
0
-20893
0
0
0
0
0
0
-28793
-12241
-38109
0
0
0
0
0
-35516
0
-43041
0
0
-26757
-42160
0
0
0
-36451
-38736
0
0
0
0
0
0
-30339
0
0
-48479
0
0
0
0
0
0
0
0
0
0
-26981
0
0
0
0
-40006
0
0
-1...

result:

ok 100000 lines

Test #50:

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

input:

40000 99999 99999 100000
24989 31952
42806 20833
20384 8538
25289 18538
47964 33916
3982 17450
26916 28456
41999 1
43159 5677
49399 48768
42477 41525
18445 1
30246 34781
27574 46491
18175 45859
6421 2
23700 1613
49025 1
15545 1
11853 42492
8209 23587
14126 30633
49192 34663
21308 1
9512 20021
16091 ...

output:

0
-50000
-49991
-50001
0
-50000
-50001
0
0
-50000
-50000
-50000
0
-50000
0
0
0
0
0
-50000
0
-50000
-50000
-50000
-50000
-49952
-50000
-50000
-50000
0
-50000
0
0
-50000
-49991
0
-50000
0
-49952
-50000
0
0
0
0
-49991
-50000
0
0
0
0
-50000
0
0
-49991
0
0
-50000
0
0
0
-49991
0
-50001
0
-50000
0
-50000
-...

result:

ok 100000 lines

Test #51:

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

input:

40000 99999 39999 100000
23855 1
44424 1
46541 1
15329 1
17510 2
38755 2
19892 30096
44839 1
24654 1
8056 2
27269 1
24598 1
366 10704
26976 2
25383 1
40203 1
46331 2
48478 1
9369 2
48361 1
3429 32993
8653 1
12656 18054
2428 34896
40492 1
9330 1
30969 35285
27878 23061
4779 1
34092 1
14831 48279
3687...

output:

0
0
0
-151
0
0
-20431
-35682
-2020
-30935
0
0
-22205
0
0
-6059
-17216
0
0
0
0
0
-12166
0
0
0
-15700
-30429
-34705
-1311
0
0
0
-37162
-6610
0
-16164
-2784
0
-32524
-32705
0
-18771
0
-17880
-25896
-32367
0
0
0
-33475
0
-22050
0
0
-37450
-38289
0
-13807
-32205
0
-17287
0
0
-7462
-13363
-29849
-20469
0
...

result:

ok 100000 lines

Test #52:

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

input:

40000 39999 99999 100000
39198 39290
13027 36642
21626 34262
36578 31069
36485 32256
32292 34152
8214 37295
28459 21466
37433 18254
29600 28773
37831 26225
36972 36549
7073 14042
39000 13096
10990 22971
8351 14736
9636 15966
27506 10806
16874 20373
6759 6113
36718 2248
4684 24509
34718 27419
21356 3...

output:

0
0
0
-4265
0
0
-49531
-44903
-46873
-17169
0
-15255
-42616
0
-1650
-33467
0
0
0
0
0
0
-12925
-23274
-21610
-40923
-32998
0
0
-24278
0
0
-49808
0
0
0
0
-39476
0
0
0
-37745
0
-49977
-22048
-11143
0
-16068
-48369
-44791
0
-27769
-21287
0
0
0
-25564
-34459
-24409
-204
0
0
0
-15248
-4644
-47960
-9990
0
...

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed