QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499835#1139. StationsDan4Life76 48ms4092kbC++231.3kb2024-07-31 19:32:572024-07-31 19:32:57

Judging History

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

  • [2024-07-31 19:32:57]
  • 评测
  • 测评结果:76
  • 用时:48ms
  • 内存:4092kb
  • [2024-07-31 19:32:57]
  • 提交

stations

#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = 1010;
int dfs_timer = 0;
vi labels, adj[mxN];

void dfs(int s, int p, int dep){
	if(!dep) labels[s] = dfs_timer;
	dfs_timer++;
	for(auto u : adj[s])
		if(u!=p) dfs(u,s,dep^1);
	if(dep) labels[s] = dfs_timer;
	dfs_timer++;
}

vi label(int n, int k, vi u, vi v) {
	labels.clear(); labels.resize(n,0); dfs_timer=0;
	for(int i = 0; i < n; i++) adj[i].clear();
	for(int i = 0; i < sz(u); i++){
		int a = u[i], b = v[i];
		adj[a].pb(b), adj[b].pb(a);
	}
	dfs(0,-1, 0); vi lol; lol.clear();
	for(auto u : labels) lol.pb(u); 
	//sort(all(lol)); lol.erase(unique(all(lol)),end(lol));
	//for(auto &u : labels) u=lower_bound(all(lol),u)-begin(lol)+1;
	return labels;
}

int find_next_station(int s, int t, vi c) {
	if(sz(c)==1) return c[0];
	for(auto u : c) if(u==t) return u;
	if(s < c[0]){
		if(!s or (s<=t and t<=end(c)[-2]+1)){
			for(int i = 1; i < sz(c)-!!s; i++)
				if(c[i-1]+1<=t and t<=c[i]) return c[i];
			return c[0];
		}
		return c.back();
	}
	if(c[1]-1<=t and t<=s){
		for(int i = 1; i < sz(c)-1; i++)
			if(c[i]<=t and t<=c[i+1]-1) return c[i];
		return c.back();
	}
	return c[0];
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3680kb

input:

0
10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
3 1000
0 1
1 2
998 1000
166 178
393 452
389 179
622 429
892 866
872 18
899 227
835 637
587 769
504 386
369 577
65 441
523 17
803 221
878 321
637 892
696 473
16 146
840 322
495 986
353 275
330 585
831 402
719 810
704 830
780 940
53 901
894 911
394 482
...

output:

10
0
14
4
12
6
16
18
10
8
2
3
0
4
2
998
0
1990
384
230
726
1034
1848
1844
86
104
1884
1684
138
1426
826
152
1766
488
898
1694
1350
1634
652
1526
620
1504
936
1180
1036
538
426
1374
1412
1512
1194
1874
672
326
1064
1306
1958
212
1906
242
532
1250
458
324
1840
696
1626
358
1304
790
802
1310
214
82
194...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

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

output:

996
0
1022
1990
2
512
1024
1534
256
510
766
1020
1278
1532
1788
1988
4
130
258
384
514
640
768
894
1026
1152
1280
1406
1536
1662
1790
1916
66
128
192
254
320
382
446
508
576
638
702
764
830
892
956
1018
1088
1150
1214
1276
1342
1404
1468
1530
1598
1660
1724
1786
1852
1914
1956
1986
6
36
68
98
132
16...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #3:

score: 16
Accepted

Test #17:

score: 16
Accepted
time: 36ms
memory: 3820kb

input:

0
10
2 1000000
1 0
997 1000000
830 513
223 672
727 200
763 415
581 440
34 42
267 325
912 693
753 59
401 289
198 641
982 214
41 49
453 107
940 806
905 732
153 482
248 405
102 79
480 837
534 620
564 856
679 178
278 247
899 206
333 672
297 308
407 863
26 752
272 178
204 603
208 10
715 562
785 285
184 5...

output:

2
0
2
997
0
1476
1300
578
1656
300
1202
1436
380
36
1068
114
1970
630
484
456
1920
1976
1682
1810
1566
1242
182
1290
172
1886
670
788
620
1328
1754
22
1652
340
1122
1352
396
226
82
706
1906
1570
604
1492
1588
588
920
958
1222
156
272
112
298
730
302
734
1910
798
1118
1012
586
568
612
864
1714
1792
1...

input:

1
59859
10 6 2
0
2
2 0 1
0
2 0 1
0
1968 1914 2
30
32
388 490 2
1798
1800
270 868 2
1734
1736
0 2 1
2
12 0 2
16
18
122 328 2
1876
1878
0 2 1
2
0 2 1
2
2 0 1
0
4 2 2
0
2
1760 174 2
1958
1960
1628 1786 2
370
372
1488 1496 2
510
512
8 18 2
2
4
2 4 1
4
1434 1224 2
292
294
46 196 2
182
184
560 586 2
1444
...

output:

2
0
0
32
1798
1734
2
18
1876
2
2
0
2
1960
370
510
2
4
294
184
1444
480
1882
1840
2
1060
526
696
4
2
642
0
546
6
0
2
1372
326
796
2
374
700
1876
642
4
6
1174
1272
1116
2
322
6
552
768
134
140
2
48
0
0
4
10
10
74
1492
830
54
6
320
12
268
1228
82
6
1570
2
1228
754
2
1580
4
936
1480
2
2
158
2
1718
2
130...

result:

ok 

Test #18:

score: 16
Accepted
time: 34ms
memory: 3788kb

input:

0
10
999 1000000
719 816
256 855
722 661
705 575
610 707
632 426
296 99
891 512
445 475
76 601
63 756
576 934
73 186
606 363
702 69
48 768
568 128
904 82
223 805
146 382
922 467
347 433
959 614
709 998
296 4
544 64
165 989
856 470
370 230
239 810
911 976
728 952
162 752
682 305
511 782
113 37
576 41...

output:

999
0
1810
972
878
546
226
1260
1404
852
1606
1186
1620
1752
1254
1680
206
1284
1352
1602
880
610
256
736
832
526
608
542
912
374
516
1818
1560
1702
744
510
1140
1846
1316
1094
938
792
1092
54
166
1244
1426
1130
1842
1388
1756
176
850
16
774
712
1034
1784
1712
1366
498
1554
1370
810
1952
536
1588
38...

input:

1
50048
1712 1300 2
148
150
342 1000 2
1144
1146
1922 1878 2
1554
1556
1272 1692 2
588
590
476 1868 2
1124
1126
276 1018 2
1324
1326
1944 1678 2
1896
1898
996 1206 2
864
866
550 1714 2
936
938
8 430 2
1914
1916
530 1416 2
1070
1072
444 144 2
1984
1986
1606 1152 2
1586
1588
1074 1460 2
848
850
986 95...

output:

150
1144
1556
588
1126
1324
1896
864
938
1914
1072
1986
1586
848
502
700
1014
618
1936
1784
616
1726
1922
532
1960
1014
236
118
1340
1110
808
292
896
266
1768
1512
1548
354
188
934
158
656
804
1406
802
1378
158
870
188
496
648
1076
996
1748
1190
1434
742
270
654
74
234
1666
1592
1158
1688
1122
1974
...

result:

ok 

Test #19:

score: 16
Accepted
time: 48ms
memory: 3728kb

input:

0
10
2 1000000
0 1
2 1000000
0 1
2 1000000
1 0
2 1000000
0 1
2 1000000
1 0
2 1000000
0 1
2 1000000
1 0
2 1000000
1 0
2 1000000
1 0
2 1000000
1 0

output:

2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2

input:

1
100000
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0...

output:

2
2
0
2
0
2
2
2
0
2
0
2
0
0
0
0
2
0
0
2
2
2
2
0
2
2
2
0
2
2
0
0
2
2
2
2
0
0
2
2
2
0
2
2
0
2
0
0
0
2
0
2
0
0
0
2
0
0
2
0
0
0
0
0
0
0
2
0
2
2
0
2
2
0
2
0
2
2
2
0
2
0
0
2
0
0
0
2
2
0
2
2
0
0
2
2
0
0
2
2
2
2
2
2
2
0
0
2
0
0
0
0
2
0
2
2
0
0
0
2
2
0
0
2
2
2
0
0
2
0
0
2
0
0
0
0
0
2
0
2
0
0
2
0
2
2
2
2
2
0
...

result:

ok 

Test #20:

score: 16
Accepted
time: 40ms
memory: 4040kb

input:

0
10
3 1000000
1 0
0 2
3 1000000
2 0
0 1
3 1000000
2 1
2 0
3 1000000
2 0
2 1
3 1000000
0 1
1 2
3 1000000
1 0
1 2
3 1000000
2 0
2 1
3 1000000
0 1
2 1
3 1000000
2 1
0 1
3 1000000
0 2
2 1

output:

3
0
2
4
3
0
4
2
3
0
2
4
3
0
2
4
3
0
4
2
3
0
4
2
3
0
2
4
3
0
4
2
3
0
4
2
3
0
2
4

input:

1
74899
0 2 1
4
2 0 1
4
2 4 1
4
2 0 1
0
4 2 1
0
0 2 2
2
4
4 0 2
0
2
0 4 1
4
0 2 1
4
4 2 2
0
2
0 4 2
2
4
0 4 1
4
0 4 1
4
2 0 1
4
2 4 1
4
0 2 1
4
0 2 1
4
0 2 1
4
4 0 1
0
4 0 2
0
2
4 2 2
0
2
2 0 1
4
0 2 1
4
0 4 1
4
2 0 1
4
0 4 2
2
4
4 2 2
0
2
0 2 1
4
4 2 1
0
4 2 1
0
0 4 1
4
2 4 1
4
0 2 1
4
4 0 2
0
2
0 ...

output:

4
4
4
0
0
2
0
4
4
2
4
4
4
4
4
4
4
4
0
0
2
4
4
4
4
4
2
4
0
0
4
4
4
0
4
4
4
4
4
0
2
4
0
4
4
4
4
4
0
0
4
4
0
4
2
2
0
2
4
2
0
4
2
4
2
4
0
2
0
4
4
4
4
0
4
0
0
2
4
4
4
2
4
4
4
4
4
4
4
4
4
0
4
4
2
0
4
4
2
2
0
4
4
2
0
0
4
0
2
0
0
2
0
4
4
4
4
4
0
4
4
2
4
0
0
4
4
0
0
0
4
0
0
2
4
4
2
0
4
0
2
4
4
4
0
4
0
4
2
4
...

result:

ok 

Test #21:

score: 16
Accepted
time: 36ms
memory: 4092kb

input:

0
10
4 1000000
0 1
2 3
0 2
4 1000000
2 1
3 1
0 2
4 1000000
3 1
3 0
1 2
4 1000000
1 3
2 1
0 2
4 1000000
1 2
1 3
0 3
4 1000000
1 0
1 2
0 3
4 1000000
3 0
0 2
2 1
4 1000000
0 1
2 0
1 3
4 1000000
2 0
0 1
2 3
4 1000000
2 1
3 0
3 1

output:

4
0
2
6
4
4
0
2
6
4
4
0
2
4
6
4
0
2
6
4
4
0
2
4
6
4
0
4
2
6
4
0
4
6
2
4
0
4
6
2
4
0
6
4
2
4
0
2
4
6

input:

1
66495
6 4 2
0
4
2 6 2
4
6
2 0 1
4
2 0 1
0
2 6 1
0
4 6 1
2
2 0 1
4
4 0 2
0
2
4 2 1
2
4 6 1
2
4 2 1
6
2 0 2
4
6
6 0 2
0
4
6 0 1
0
4 6 1
2
4 0 1
2
6 4 1
0
2 6 2
4
6
2 4 2
4
6
4 6 1
6
4 2 2
0
2
0 4 1
6
0 6 2
2
6
6 0 2
0
2
2 6 1
0
4 2 1
6
6 4 1
0
2 6 2
4
6
2 4 1
0
4 2 1
2
4 2 1
2
4 6 2
0
2
6 0 2
0
2
2 ...

output:

4
6
4
0
0
2
4
0
2
2
6
6
0
0
2
2
0
6
4
6
2
6
6
0
0
6
0
6
0
2
2
0
0
6
0
4
6
4
0
4
2
0
6
2
4
0
6
0
2
4
2
6
2
4
2
4
2
2
6
2
6
6
0
6
0
0
6
4
2
2
2
4
2
0
0
6
6
4
2
6
4
0
2
4
2
2
0
0
2
6
2
2
6
6
2
2
2
0
0
6
0
2
2
4
6
6
6
2
4
2
6
2
0
0
6
2
2
0
2
2
0
6
0
2
0
0
0
6
6
6
0
4
0
4
6
6
4
6
6
6
0
6
0
4
0
4
0
6
0
4
...

result:

ok 

Test #22:

score: 16
Accepted
time: 34ms
memory: 3792kb

input:

0
10
1000 1000000
526 757
286 227
877 883
484 370
847 13
425 107
166 745
276 357
746 21
304 131
462 834
317 58
942 423
375 631
977 908
229 838
549 167
518 60
51 772
419 970
909 386
362 829
470 46
218 986
82 787
919 307
947 691
348 900
233 650
253 762
90 850
144 627
954 103
602 268
187 746
568 992
31...

output:

1000
0
356
1100
1336
710
1172
686
1948
84
1650
116
524
220
1232
1688
1834
1334
1054
286
1902
1406
1200
370
1346
778
642
1626
1814
1916
1780
1546
1848
1716
90
1970
1320
1798
136
1192
438
1296
736
28
384
464
68
1812
1046
368
572
46
1386
776
1636
1692
1984
884
1000
1176
1330
1668
1352
1684
1700
1240
40...

input:

1
50050
510 312 2
76
78
108 110 2
570
572
1546 1014 2
1898
1900
946 262 2
1126
1128
1324 616 2
1318
1320
1878 666 2
602
604
1886 420 2
1558
1560
542 278 2
1916
1918
858 1778 2
1622
1624
988 1718 2
458
460
828 1514 2
1440
1442
986 584 2
1286
1288
976 1952 2
1504
1506
1510 1400 2
1166
1168
940 1090 2
...

output:

78
570
1900
1128
1318
604
1558
1918
1624
458
1442
1288
1506
1168
1736
796
1462
350
1982
176
492
434
1446
1508
1568
1316
120
486
824
798
264
1062
330
1402
106
1726
1000
1742
184
1464
1878
1684
1084
618
554
746
572
1512
1238
166
88
1258
540
1798
598
444
1474
716
880
1182
592
470
642
1704
478
440
236
4...

result:

ok 

Test #23:

score: 16
Accepted
time: 26ms
memory: 3744kb

input:

0
1
1000 1000000
622 589
830 829
709 500
278 363
20 230
963 181
768 29
857 332
787 757
897 285
480 939
855 617
959 84
687 755
667 30
553 1
213 98
987 780
47 851
107 764
130 863
326 832
872 636
85 159
119 330
672 210
134 576
224 282
570 387
53 941
723 69
694 642
707 49
260 390
525 768
78 273
811 220
...

output:

1000
0
1190
604
138
66
798
1308
1058
4
358
1474
458
1428
1358
1166
1230
190
890
1722
380
92
1030
1984
1134
1444
1700
1846
560
406
956
546
868
176
462
1392
1116
946
1254
1974
184
188
430
1092
1900
1528
908
112
186
1888
1844
960
1316
1850
598
1584
1878
1550
916
1710
286
1604
1626
1546
1944
400
86
156
...

input:

1
50053
1788 580 2
678
680
1614 1046 2
852
854
52 266 2
416
418
1356 756 2
1110
1112
802 1566 2
1664
1666
1130 1018 2
1336
1338
274 1066 2
194
196
724 1710 2
1742
1744
1540 622 2
926
928
644 1658 2
1822
1824
254 270 2
214
216
1028 1486 2
1438
1440
1074 26 2
1392
1394
424 1452 2
44
46
992 1016 2
1474...

output:

678
854
416
1110
1664
1338
194
1742
926
1822
214
1440
1394
44
1474
108
8
1150
1154
1794
1840
880
1482
850
846
752
134
1564
320
526
494
1434
1192
934
1348
1830
980
1750
992
282
1524
410
1078
1248
1626
928
38
1786
470
612
1552
742
1694
916
584
1304
448
840
900
1100
1920
1794
208
350
508
42
1652
890
10...

result:

ok 

Test #24:

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

input:

0
10
4 1000000
0 1
1 2
2 3
4 1000000
0 1
1 3
3 2
4 1000000
0 2
2 1
1 3
4 1000000
0 2
2 3
3 1
4 1000000
0 3
3 1
1 2
4 1000000
0 3
3 2
2 1
4 1000000
1 0
0 2
2 3
4 1000000
1 0
0 3
3 2
4 1000000
1 2
2 0
0 3
4 1000000
1 3
3 0
0 2

output:

4
0
6
2
4
4
0
6
4
2
4
0
2
6
4
4
0
4
6
2
4
0
2
4
6
4
0
4
2
6
4
0
2
6
4
4
0
2
4
6
4
0
2
4
6
4
0
2
6
4

input:

1
120
6 4 2
0
2
6 2 2
0
2
6 2 2
0
2
4 2 1
2
2 6 2
4
6
0 2 2
2
6
0 4 2
2
6
0 6 1
6
4 2 1
6
6 2 2
0
4
6 0 2
0
2
2 6 1
0
6 0 2
0
2
2 4 2
4
6
2 4 1
0
0 2 1
6
2 4 2
4
6
2 0 1
4
0 6 2
4
6
0 4 1
6
0 2 1
6
2 6 2
4
6
6 4 2
0
4
4 0 1
2
0 6 2
2
6
4 2 1
2
2 0 2
4
6
4 0 1
2
6 0 1
0
2 4 2
4
6
4 6 1
2
0 2 2
2
6
0 ...

output:

2
2
2
2
6
2
6
6
6
0
0
0
0
4
0
6
4
4
6
6
6
6
4
2
6
2
6
2
0
4
2
2
6
2
0
2
6
4
0
6
6
6
0
6
6
6
2
6
6
6
0
4
4
6
0
6
0
2
0
2
6
6
6
0
4
2
2
6
2
0
2
2
0
4
0
6
0
6
2
2
0
4
4
6
2
6
4
6
0
0
6
4
2
4
0
6
2
0
2
2
4
0
6
4
0
2
6
2
2
6
2
4
2
0
6
6
2
6
6
2

result:

ok 

Test #25:

score: 16
Accepted
time: 0ms
memory: 3784kb

input:

0
10
6 1000000
0 1
1 2
2 3
3 4
4 5
6 1000000
0 1
1 2
2 3
3 5
5 4
6 1000000
0 1
1 2
2 4
4 3
3 5
6 1000000
0 1
1 2
2 4
4 5
5 3
6 1000000
0 1
1 2
2 5
5 3
3 4
6 1000000
0 1
1 2
2 5
5 4
4 3
6 1000000
0 1
1 3
3 2
2 4
4 5
6 1000000
0 1
1 3
3 2
2 5
5 4
6 1000000
0 1
1 3
3 4
4 2
2 5
6 1000000
0 1
1 3
3 4
4 5...

output:

6
0
10
2
8
4
6
6
0
10
2
8
6
4
6
0
10
2
4
8
6
6
0
10
2
6
8
4
6
0
10
2
4
6
8
6
0
10
2
6
4
8
6
0
10
8
2
4
6
6
0
10
8
2
6
4
6
0
10
4
2
8
6
6
0
10
6
2
8
4

input:

1
300
8 2 2
2
4
4 8 2
6
8
4 0 2
6
8
4 6 2
6
8
10 6 2
0
2
8 0 2
2
4
10 8 2
0
2
4 10 2
6
8
0 10 1
10
2 6 2
8
10
0 2 1
10
8 6 2
2
4
8 4 2
2
4
2 8 2
8
10
2 4 2
8
10
4 6 2
6
8
4 2 2
6
8
6 0 1
4
6 0 1
4
2 4 2
8
10
10 4 2
0
2
10 0 2
0
2
8 0 2
2
4
4 2 2
6
8
0 4 1
10
0 10 1
10
2 10 2
8
10
4 6 2
6
8
2 8 2
8
1...

output:

2
8
8
6
2
2
2
8
10
8
10
4
4
8
8
6
8
4
4
8
2
0
2
8
10
10
10
6
8
4
8
8
10
4
8
2
10
8
4
6
4
10
4
4
6
2
10
2
2
10
8
10
2
4
6
2
10
10
8
8
2
4
2
10
10
8
10
8
8
10
10
2
2
10
10
4
4
0
4
10
8
2
8
4
8
2
2
2
2
10
10
4
4
4
10
8
8
10
8
10
10
4
8
10
2
10
10
2
8
0
8
8
8
4
8
10
10
0
8
10
4
10
2
2
4
4
8
4
4
8
10
2
8...

result:

ok 

Test #26:

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

input:

0
3
3 1000000
0 1
1 2
3 1000000
0 2
2 1
3 1000000
1 0
0 2

output:

3
0
4
2
3
0
2
4
3
0
2
4

input:

1
18
0 2 1
4
0 4 1
4
0 4 2
2
4
0 2 1
4
2 0 1
4
4 2 2
0
2
4 2 1
0
2 0 1
4
0 4 1
4
4 0 2
0
2
2 0 1
0
4 0 2
0
2
2 4 1
0
4 0 1
0
2 4 1
4
0 2 2
2
4
2 4 1
4
4 2 2
0
2

output:

4
4
4
4
4
2
0
4
4
0
0
0
0
0
4
2
4
2

result:

ok 

Test #27:

score: 16
Accepted
time: 36ms
memory: 3812kb

input:

0
10
4 1000000
2 1
1 0
3 2
4 1000000
1 2
0 1
1 3
4 1000000
1 0
2 0
0 3
4 1000000
1 3
1 0
2 0
4 1000000
3 2
0 3
3 1
4 1000000
0 1
1 3
2 1
4 1000000
0 1
0 3
3 2
4 1000000
0 3
1 2
0 2
4 1000000
0 2
3 2
2 1
4 1000000
2 0
2 3
0 1

output:

4
0
6
2
4
4
0
6
2
4
4
0
2
4
6
4
0
4
6
2
4
0
4
2
6
4
0
6
4
2
4
0
2
4
6
4
0
4
6
2
4
0
4
6
2
4
0
6
4
2

input:

1
66694
0 4 2
2
6
6 4 2
0
4
2 6 1
6
6 0 3
0
2
4
4 2 1
6
4 2 2
0
2
2 4 1
0
6 4 1
0
2 6 1
6
4 2 1
6
0 4 1
6
4 2 1
6
2 4 1
0
4 6 2
0
2
6 4 3
0
2
4
0 2 1
6
6 2 2
0
4
2 6 1
6
4 0 1
6
2 4 1
6
2 4 1
6
0 4 1
6
2 6 1
6
6 0 3
0
2
4
0 2 1
6
2 0 1
6
2 4 1
6
2 4 1
4
2 0 1
6
4 6 1
6
6 0 3
0
2
4
0 4 2
2
6
4 6 1
6
...

output:

6
4
6
0
6
2
0
0
6
6
6
6
0
0
4
6
0
6
6
6
6
6
6
0
6
6
6
4
6
6
0
6
6
6
0
6
6
4
0
6
6
0
0
0
4
6
4
6
0
2
4
6
6
6
2
0
2
0
6
0
6
6
6
6
6
2
4
6
6
6
6
6
2
6
0
0
6
0
6
0
2
6
6
6
2
4
4
6
0
4
4
6
0
4
6
2
6
6
4
0
2
4
4
6
2
6
0
6
6
0
4
0
6
0
2
2
6
0
0
6
6
0
4
6
6
6
6
6
6
4
6
0
2
6
4
4
6
0
6
0
6
6
6
4
4
4
0
6
6
6
...

result:

ok 

Test #28:

score: 16
Accepted
time: 34ms
memory: 3792kb

input:

0
10
1000 1000000
802 637
810 172
802 781
109 293
802 724
488 524
73 802
802 312
108 985
802 594
305 802
802 620
382 747
841 535
802 690
987 387
269 559
201 219
982 319
228 802
802 977
291 962
657 597
69 757
321 555
825 299
802 694
363 827
802 265
475 796
600 891
802 16
802 116
487 167
150 335
175 5...

output:

1000
0
478
928
1050
1796
1584
990
614
1772
1856
1978
1296
582
890
726
1286
114
1600
1282
196
836
980
322
712
1346
842
774
884
172
718
1570
632
1194
708
520
1792
448
542
452
1756
238
40
1236
1082
1812
1222
820
1652
968
142
156
828
1344
130
36
1172
412
598
522
1080
210
50
48
1262
1840
906
1412
1482
14...

input:

1
51340
298 1542 2
1206
1208
286 72 2
1754
1756
1030 784 2
262
264
556 1846 2
624
626
918 518 2
1122
1124
1064 462 2
1102
1104
1272 20 2
1306
1308
264 1814 2
248
250
1170 1388 1
1172
1400 1364 1
2
140 224 2
1364
1366
738 310 2
766
768
1332 192 2
1358
1360
1352 1826 1
84
1928 1820 2
1916
1918
1302 11...

output:

1208
1756
264
626
1124
1104
1308
248
1172
2
1364
768
1360
84
1916
1310
656
84
2
1562
1326
1630
738
586
1502
84
1918
606
676
1798
1842
262
300
458
1080
1704
1140
436
1112
1674
1894
1602
48
2
560
44
838
0
1854
310
1290
24
524
990
372
84
1840
1242
832
822
1856
2
1880
382
84
66
804
1306
544
312
798
1444...

result:

ok 

Test #29:

score: 16
Accepted
time: 34ms
memory: 3784kb

input:

0
10
1000 1000000
1 433
265 863
766 305
237 422
591 33
588 87
33 868
33 328
110 458
718 791
891 33
22 576
773 795
489 357
104 33
33 829
308 726
592 865
651 179
591 508
264 792
274 367
219 33
67 600
419 406
583 183
716 211
4 709
983 33
672 928
648 689
679 497
321 874
711 585
758 518
223 702
440 618
7...

output:

1000
0
1194
1020
852
576
918
762
1424
100
786
1718
1178
338
1432
1736
1148
1546
1914
788
1668
500
1202
1740
640
1936
1170
1024
1932
1320
222
982
1598
864
1994
1542
1042
440
1394
1676
1706
880
1230
706
1724
1344
1510
1752
198
162
726
1008
1792
344
964
276
1326
1828
1888
580
1322
1450
1642
264
1514
48...

input:

1
51513
1422 1120 2
956
958
636 62 2
714
716
830 1234 1
1998
970 1488 1
1998
1452 1018 2
1440
1442
962 300 2
968
970
612 1086 2
10
12
610 1354 2
448
450
1210 154 2
1172
1174
980 772 1
1998
1778 612 2
26
28
1790 632 2
1798
1800
1168 1324 2
10
1138
1150 1820 2
1124
1126
1664 1950 2
1134
1136
18 352 2
...

output:

958
716
1998
1998
1440
970
10
448
1172
1998
28
1800
10
1124
1134
1682
1994
888
1260
498
214
1628
10
894
1630
1984
1998
1870
92
410
1984
1562
474
1014
1554
1636
1000
494
210
1998
564
558
46
1190
694
1998
76
1998
1348
222
1998
1998
1296
1768
1998
1566
1998
1176
288
1614
858
236
912
1826
268
1574
750
7...

result:

ok 

Test #30:

score: 16
Accepted
time: 34ms
memory: 3784kb

input:

0
1
1000 1000000
394 768
598 218
369 360
414 385
909 666
948 524
272 868
110 348
723 672
225 409
312 213
865 469
207 711
779 480
303 958
946 880
22 137
265 787
595 9
193 865
661 869
680 238
708 770
389 82
828 35
881 49
138 749
220 975
452 201
641 269
734 497
155 159
324 778
105 650
882 621
519 319
4...

output:

1000
0
564
1810
404
106
644
1770
1996
398
552
16
1274
32
220
148
638
722
1114
422
360
1948
1004
522
284
306
614
1074
1920
1160
444
38
242
1592
490
1304
1052
1298
1444
132
1266
1562
1658
166
1568
278
1776
392
582
864
66
606
160
1888
1720
964
1230
36
270
52
1068
1994
540
742
718
482
478
376
728
1558
5...

input:

1
49931
1968 1410 2
1962
1964
688 1436 2
628
630
1932 868 30
0
2
66
146
204
244
302
352
426
490
544
616
702
752
820
876
928
1000
1080
1134
1216
1280
1346
1406
1472
1548
1606
1696
1776
1844
490 1412 2
542
1932
838 1778 2
856
858
1186 1176 2
1162
1164
1464 938 2
1412
1414
1890 982 2
1884
1886
606 1636...

output:

1962
628
820
1932
858
1164
1412
1884
552
1690
154
978
16
692
1932
114
764
1984
1772
678
1090
280
1548
984
1520
274
1042
958
1914
768
1932
1998
1538
1444
1208
0
1592
1390
1036
472
110
568
1948
1064
1550
1220
1130
1542
884
1436
1230
1572
1128
490
806
1214
1158
792
42
1342
274
170
1458
924
510
1264
165...

result:

ok 

Test #31:

score: 16
Accepted
time: 12ms
memory: 4084kb

input:

0
10
96 1000000
0 36
27 0
95 0
7 0
0 70
59 0
72 0
83 0
22 0
25 0
18 0
92 0
0 88
87 0
0 75
0 68
39 0
0 84
0 43
0 24
28 0
19 0
5 0
0 80
37 0
0 33
77 0
15 0
0 38
3 0
0 60
11 0
74 0
89 0
52 0
79 0
0 73
81 0
44 0
76 0
41 0
21 0
57 0
0 85
40 0
49 0
0 45
0 46
16 0
14 0
0 66
29 0
20 0
32 0
0 1
0 51
0 47
0 3...

output:

96
0
110
172
60
184
46
166
8
152
128
154
64
188
182
100
56
98
144
22
44
106
84
18
148
40
20
142
4
42
104
124
116
108
52
130
120
2
50
58
34
90
82
150
38
78
94
96
114
180
92
118
112
70
174
158
186
132
86
136
12
62
126
164
138
190
146
102
156
32
170
10
162
14
74
66
30
80
54
176
72
48
76
122
16
36
88
17...

input:

1
4026
132 188 1
0
32 154 1
190
68 168 1
0
100 88 1
0
140 154 1
0
0 34 95
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
102
104
106
108
110
112
114
116
118
120
122
124
126
128
130
132
134
136
138
140...

output:

0
190
0
0
0
34
0
190
190
190
190
0
0
190
48
190
0
0
162
0
0
190
0
190
132
0
190
122
190
190
190
0
54
0
0
0
190
0
0
0
190
0
0
190
52
0
190
190
0
190
150
92
38
190
40
190
0
0
190
190
190
0
190
0
0
20
190
0
90
190
16
0
190
0
0
190
0
110
190
0
190
0
190
0
0
188
190
190
0
190
0
190
50
168
0
18
106
78
186...

result:

ok 

Test #32:

score: 16
Accepted
time: 12ms
memory: 3824kb

input:

0
10
541 1000000
540 23
540 21
40 540
150 540
540 291
540 34
3 540
540 416
428 540
347 540
60 540
140 540
540 216
411 540
57 540
540 214
271 540
439 540
400 540
379 540
195 540
540 167
152 540
540 254
251 540
399 540
540 185
420 540
540 154
534 540
540 160
540 194
247 540
540 11
342 540
540 257
454 ...

output:

541
0
116
294
14
514
82
510
100
770
762
508
68
1004
654
1052
1026
882
458
324
546
414
4
452
2
922
772
180
166
1068
1006
1030
244
936
412
12
108
642
690
204
274
6
86
122
500
130
740
516
422
492
430
638
796
228
476
696
706
656
30
938
1044
22
96
250
420
312
224
1010
652
478
404
1048
438
160
254
200
798...

input:

1
5675
470 336 1
0
402 752 1
0
382 934 1
1080
412 116 1
1080
1080 804 540
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
102
104
106
108
110
112
114
116
118
120
122
124
126
128
130
132
134
136
138
1...

output:

0
0
1080
1080
804
1080
1080
1080
1080
0
0
1080
0
1080
0
1080
0
0
1080
0
0
1080
0
1080
0
1080
1080
1080
0
1080
1080
1080
1080
1080
0
0
1080
1080
0
1080
1080
1080
1080
0
0
1080
0
0
1080
1080
1080
1080
0
1080
0
0
0
1080
1080
1080
0
1080
1080
1080
0
1080
1080
0
1080
1080
0
1080
1080
1080
0
1080
1080
0
0...

result:

ok 

Test #33:

score: 16
Accepted
time: 14ms
memory: 3796kb

input:

0
10
1000 1000000
989 0
0 294
783 0
474 0
831 0
397 0
0 538
626 0
554 0
837 0
954 0
0 694
343 0
883 0
0 957
0 24
0 688
0 17
406 0
472 0
929 0
22 0
0 412
0 195
150 0
0 518
0 255
35 0
381 0
751 0
0 928
0 555
0 241
0 590
454 0
373 0
0 72
389 0
455 0
327 0
0 917
572 0
0 164
335 0
0 59
0 809
0 182
0 123
...

output:

1000
0
982
1756
1042
1812
936
904
880
200
1220
846
320
694
686
1210
196
1688
36
488
422
1946
1378
44
1194
32
1402
1542
116
1742
1148
1136
640
920
458
108
56
410
860
848
520
1144
1430
864
280
1202
452
1500
654
470
1268
834
1912
1702
522
1622
784
1416
1180
416
90
420
428
344
1624
924
1654
1944
994
316...

input:

1
10180
142 774 1
1998
92 668 1
1998
112 678 1
1998
244 1828 1
1998
392 1436 1
0
1940 1534 1
1998
1474 1180 1
0
804 1214 1
1998
1226 510 1
1998
210 638 1
0
550 1610 1
0
1548 378 1
1998
56 1334 1
0
476 654 1
0
214 344 1
0
150 474 1
1998
562 1128 1
1998
364 1422 1
0
382 1964 1
1998
784 1660 1
1998
102...

output:

1998
1998
1998
1998
0
1998
0
1998
1998
0
0
1998
0
0
0
1998
1998
0
1998
1998
1998
1998
1998
0
1680
0
0
1998
1998
0
1998
0
1998
0
1998
1998
1998
1998
1998
1998
1998
1998
0
1998
0
0
1998
1998
1998
1998
1998
1998
1998
480
1998
1998
1998
1998
1998
1998
0
1998
0
1998
0
1998
1998
1998
1998
0
0
1998
1998
19...

result:

ok 

Subtask #4:

score: 10
Accepted

Test #34:

score: 10
Accepted
time: 48ms
memory: 4040kb

input:

0
10
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1

output:

2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2

input:

1
100000
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
0 2 1
2
2 0...

output:

0
2
2
0
2
0
0
0
0
0
2
0
2
0
2
2
2
0
0
2
0
2
2
0
0
2
2
0
2
2
0
0
0
0
0
2
0
2
0
0
0
2
2
0
2
2
2
2
0
0
2
2
0
0
0
2
2
0
2
2
0
2
2
0
0
0
2
0
2
2
2
2
2
2
0
2
0
2
2
2
0
0
0
0
2
0
0
2
0
2
2
0
2
2
2
0
0
0
2
2
2
0
2
0
0
2
0
2
0
2
2
0
0
2
0
0
0
2
2
2
0
0
0
2
2
0
0
2
2
2
0
2
0
2
0
2
2
2
2
0
0
0
0
2
0
0
2
0
0
0
...

result:

ok 

Test #35:

score: 10
Accepted
time: 40ms
memory: 3788kb

input:

0
10
3 1000000000
2 1
2 0
3 1000000000
1 0
2 0
3 1000000000
2 0
0 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
1 0
2 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
0 2
1 0
3 1000000000
2 0
1 2

output:

3
0
2
4
3
0
2
4
3
0
4
2
3
0
2
4
3
0
4
2
3
0
4
2
3
0
2
4
3
0
4
2
3
0
4
2
3
0
2
4

input:

1
75069
4 2 2
0
2
0 2 2
2
4
0 2 1
4
0 2 1
4
2 0 1
0
0 2 1
4
2 4 1
4
4 0 2
0
2
2 4 1
0
4 2 2
0
2
4 2 2
0
2
2 0 1
4
4 2 2
0
2
4 2 2
0
2
2 0 1
4
0 2 1
4
4 0 2
0
2
0 2 2
2
4
0 4 1
4
2 4 1
4
4 2 2
0
2
4 2 2
0
2
2 0 1
0
2 4 1
4
0 4 1
4
2 0 1
4
0 4 1
4
2 0 1
0
2 0 1
4
4 0 2
0
2
4 2 2
0
2
0 2 2
2
4
4 0 2
0
...

output:

2
2
4
4
0
4
4
0
0
2
2
4
2
2
4
4
0
2
4
4
2
2
0
4
4
4
4
0
4
0
2
2
0
4
0
4
0
2
4
0
4
4
0
4
0
0
4
4
0
0
4
2
0
4
4
4
4
4
0
4
2
4
4
2
0
2
0
4
2
4
2
4
4
4
2
4
0
0
0
2
0
0
4
0
0
0
2
4
4
0
4
4
2
2
2
4
2
0
2
4
0
0
4
0
0
2
0
2
4
0
2
4
4
0
4
4
0
4
4
4
4
0
2
2
0
4
4
4
2
0
4
0
4
0
2
4
4
2
4
4
0
4
2
4
0
0
0
4
4
4
...

result:

ok 

Test #36:

score: 10
Accepted
time: 38ms
memory: 3888kb

input:

0
10
4 1000000000
3 1
2 0
1 0
4 1000000000
0 3
1 2
3 1
4 1000000000
3 1
0 2
0 1
4 1000000000
2 1
2 3
1 0
4 1000000000
3 1
0 1
2 3
4 1000000000
0 1
3 0
2 3
4 1000000000
2 0
3 0
1 2
4 1000000000
0 2
2 3
1 3
4 1000000000
3 2
2 1
3 0
4 1000000000
2 3
3 0
0 1

output:

4
0
6
2
4
4
0
2
4
6
4
0
6
2
4
4
0
6
2
4
4
0
6
4
2
4
0
2
4
6
4
0
2
4
6
4
0
4
6
2
4
0
4
2
6
4
0
6
2
4

input:

1
66804
0 2 2
4
6
0 2 2
4
6
6 0 2
0
4
0 6 1
6
0 4 2
2
6
6 4 2
0
4
2 4 2
4
6
6 2 2
0
2
0 2 1
6
4 6 2
0
2
0 6 2
2
6
6 0 2
0
4
2 6 2
4
6
2 0 1
0
6 0 2
0
2
2 4 1
0
2 0 1
0
6 4 2
0
4
2 6 2
4
6
4 2 1
2
2 4 2
4
6
6 0 1
0
0 6 1
6
6 4 2
0
2
4 2 1
2
6 2 2
0
4
6 0 2
0
2
4 2 1
2
4 2 1
2
0 2 2
2
6
6 4 2
0
4
4 6 ...

output:

4
4
0
6
6
4
4
2
6
0
6
0
6
0
0
0
0
4
6
2
4
0
6
2
2
0
0
2
2
2
4
2
2
0
6
6
6
6
6
2
0
2
6
2
6
0
6
6
6
2
4
4
2
4
4
2
2
6
4
0
6
0
6
4
2
0
6
2
6
6
6
0
6
6
4
0
4
0
0
2
2
6
6
6
0
0
2
6
2
2
0
2
2
0
6
6
6
2
0
6
2
0
4
2
2
6
2
6
6
2
4
0
6
0
0
0
6
2
0
4
6
2
6
6
4
2
2
2
0
6
4
0
6
6
2
6
4
2
4
0
4
6
6
0
0
0
2
0
6
6
...

result:

ok 

Test #37:

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

input:

0
10
4 1000000000
0 1
1 2
2 3
4 1000000000
0 1
1 3
3 2
4 1000000000
0 2
2 1
1 3
4 1000000000
0 2
2 3
3 1
4 1000000000
0 3
3 1
1 2
4 1000000000
0 3
3 2
2 1
4 1000000000
1 0
0 2
2 3
4 1000000000
1 0
0 3
3 2
4 1000000000
1 2
2 0
0 3
4 1000000000
1 3
3 0
0 2

output:

4
0
6
2
4
4
0
6
4
2
4
0
2
6
4
4
0
4
6
2
4
0
2
4
6
4
0
4
2
6
4
0
2
6
4
4
0
2
4
6
4
0
2
4
6
4
0
2
6
4

input:

1
120
2 6 2
4
6
2 4 1
4
4 2 1
2
0 4 1
6
2 4 1
0
6 2 2
0
2
6 2 1
0
0 2 1
6
0 6 1
6
4 6 1
2
2 0 2
4
6
4 6 1
6
0 6 2
2
6
2 4 2
4
6
6 0 2
0
2
2 6 1
4
2 0 2
4
6
2 0 1
0
4 6 1
2
6 4 1
0
4 6 1
2
0 6 2
4
6
0 6 2
2
6
4 0 1
6
6 0 2
0
2
0 4 2
4
6
4 0 1
2
6 0 2
0
4
2 0 1
4
4 2 1
2
0 4 1
6
6 4 2
0
2
6 2 2
0
2
0 ...

output:

6
4
2
6
0
2
0
6
6
2
6
6
6
4
0
4
6
0
2
0
2
6
6
6
0
4
2
0
4
2
6
2
2
6
6
0
6
6
6
6
6
2
4
2
2
4
6
4
2
2
2
6
0
0
4
0
6
6
2
2
4
6
4
0
4
6
0
6
4
0
2
6
2
0
2
0
2
6
0
2
2
6
6
6
0
0
6
4
2
6
6
2
6
0
2
0
2
6
4
6
2
2
0
2
2
6
2
4
0
6
6
4
0
2
2
6
6
0
4
0

result:

ok 

Test #38:

score: 10
Accepted
time: 0ms
memory: 3784kb

input:

0
10
6 1000000000
0 1
1 2
2 3
3 4
4 5
6 1000000000
0 1
1 2
2 3
3 5
5 4
6 1000000000
0 1
1 2
2 4
4 3
3 5
6 1000000000
0 1
1 2
2 4
4 5
5 3
6 1000000000
0 1
1 2
2 5
5 3
3 4
6 1000000000
0 1
1 2
2 5
5 4
4 3
6 1000000000
0 1
1 3
3 2
2 4
4 5
6 1000000000
0 1
1 3
3 2
2 5
5 4
6 1000000000
0 1
1 3
3 4
4 2
2 ...

output:

6
0
10
2
8
4
6
6
0
10
2
8
6
4
6
0
10
2
4
8
6
6
0
10
2
6
8
4
6
0
10
2
4
6
8
6
0
10
2
6
4
8
6
0
10
8
2
4
6
6
0
10
8
2
6
4
6
0
10
4
2
8
6
6
0
10
6
2
8
4

input:

1
300
0 6 1
10
10 6 2
0
2
2 10 2
8
10
4 6 2
6
8
8 0 2
2
4
0 10 1
10
10 0 2
0
2
0 10 1
10
0 10 1
10
10 8 2
0
2
8 4 2
2
4
0 4 1
10
6 2 1
4
8 6 2
2
4
0 10 1
10
2 6 2
8
10
0 6 1
10
2 4 2
8
10
0 4 1
10
6 0 1
4
4 10 2
6
8
10 2 2
0
2
2 4 2
8
10
8 10 2
2
4
8 4 2
2
4
10 6 2
0
2
4 2 2
6
8
0 2 1
10
0 4 1
10
10...

output:

10
2
10
6
2
10
0
10
10
2
4
10
4
4
10
8
10
8
10
4
8
2
8
2
4
2
8
10
10
2
10
8
0
4
0
4
0
2
4
2
2
2
10
2
6
10
4
8
8
4
10
10
8
4
8
8
10
2
10
8
4
4
4
10
4
10
4
4
4
2
4
4
6
8
8
10
8
10
8
6
2
2
2
10
8
10
10
4
8
8
6
4
4
0
4
8
4
8
4
10
4
2
2
6
2
0
10
8
8
8
8
4
2
8
4
8
10
4
4
4
2
10
8
10
2
2
4
4
4
2
2
2
8
10
4...

result:

ok 

Test #39:

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

input:

0
3
3 1000000000
0 1
1 2
3 1000000000
0 2
2 1
3 1000000000
1 0
0 2

output:

3
0
4
2
3
0
2
4
3
0
2
4

input:

1
18
4 2 2
0
2
4 0 2
0
2
4 0 2
0
2
2 0 1
4
4 0 1
0
2 0 1
0
2 4 1
4
4 2 1
0
4 2 2
0
2
0 2 2
2
4
2 4 1
0
0 2 1
4
0 2 1
4
0 4 1
4
2 4 1
4
2 0 1
4
0 4 1
4
0 4 2
2
4

output:

2
0
0
4
0
0
4
0
2
2
0
4
4
4
4
4
4
4

result:

ok 

Test #40:

score: 10
Accepted
time: 36ms
memory: 4076kb

input:

0
10
4 1000000000
1 3
1 2
0 1
4 1000000000
2 3
3 0
1 3
4 1000000000
2 0
1 3
0 1
4 1000000000
1 2
3 1
1 0
4 1000000000
3 1
0 2
3 2
4 1000000000
2 0
2 1
2 3
4 1000000000
1 2
1 3
2 0
4 1000000000
0 2
2 3
2 1
4 1000000000
2 1
2 0
3 0
4 1000000000
3 0
3 2
1 0

output:

4
0
6
4
2
4
0
4
2
6
4
0
6
2
4
4
0
6
2
4
4
0
4
6
2
4
0
2
6
4
4
0
2
6
4
4
0
4
6
2
4
0
2
4
6
4
0
6
2
4

input:

1
66674
2 4 1
4
2 4 1
6
6 2 3
0
2
4
2 4 1
6
6 4 2
0
2
6 2 3
0
2
4
0 2 2
2
6
6 0 3
0
2
4
6 2 3
0
2
4
6 2 2
0
2
4 2 1
2
6 2 2
0
4
0 4 1
6
4 0 1
6
6 2 1
0
6 2 1
0
0 6 1
6
4 6 2
0
2
2 0 1
6
4 2 1
6
2 6 2
4
6
4 2 1
6
4 6 2
0
2
2 6 2
4
6
6 2 1
0
2 4 2
4
6
4 6 1
6
2 4 1
6
4 0 1
6
2 4 2
4
6
0 2 2
4
6
0 4 2
...

output:

4
6
2
6
2
2
2
0
2
2
2
0
6
6
0
0
6
0
6
6
6
6
0
6
0
4
6
6
6
4
4
4
6
4
0
6
0
6
6
6
6
6
6
2
6
4
6
6
6
4
0
0
6
6
0
6
0
6
4
6
2
6
6
6
6
6
0
2
0
4
6
2
6
0
6
4
6
4
0
4
6
6
0
6
0
0
2
0
6
4
0
6
0
4
6
6
6
0
2
6
6
4
6
6
2
6
6
4
2
2
2
4
2
6
6
6
6
0
4
0
6
6
2
4
6
6
6
4
4
4
4
2
0
0
2
6
6
4
6
4
6
0
6
6
6
6
6
6
0
6
...

result:

ok 

Test #41:

score: 10
Accepted
time: 48ms
memory: 4084kb

input:

0
10
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1

output:

2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2

input:

1
100000
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
2 0...

output:

0
0
2
0
2
2
2
0
2
0
0
2
2
0
0
2
2
2
2
0
0
0
0
2
0
2
2
0
0
2
2
2
2
2
0
0
0
0
0
0
2
0
2
2
0
2
0
2
0
2
2
2
0
0
0
0
2
0
0
0
2
0
2
0
0
2
2
0
0
0
2
2
0
2
2
0
0
0
0
2
0
2
2
2
0
2
2
0
0
0
2
2
0
0
0
0
0
2
2
0
2
2
2
0
2
2
0
0
2
2
2
0
2
2
2
0
0
2
2
0
2
0
0
0
0
2
2
0
2
2
2
0
0
2
2
2
0
2
0
2
0
0
0
0
0
0
0
0
0
0
...

result:

ok 

Test #42:

score: 10
Accepted
time: 38ms
memory: 3784kb

input:

0
10
3 1000000000
0 1
0 2
3 1000000000
0 1
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
0 1
0 2

output:

3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4

input:

1
75040
4 2 1
0
4 0 1
0
2 0 1
0
0 4 2
2
4
2 4 1
0
2 0 1
0
0 4 2
2
4
4 0 1
0
2 4 1
0
0 4 2
2
4
2 4 1
0
0 2 2
2
4
0 4 2
2
4
0 4 2
2
4
0 2 2
2
4
2 4 1
0
4 2 1
0
0 4 2
2
4
4 0 1
0
4 0 1
0
2 4 1
0
0 4 2
2
4
0 4 2
2
4
2 4 1
0
0 2 2
2
4
2 0 1
0
4 2 1
0
4 0 1
0
4 0 1
0
4 2 1
0
2 4 1
0
0 4 2
2
4
4 0 1
0
4 0 ...

output:

0
0
0
4
0
0
4
0
0
4
0
2
4
4
2
0
0
4
0
0
0
4
4
0
2
0
0
0
0
0
0
4
0
0
0
0
4
2
0
2
0
0
2
0
0
2
4
0
0
2
2
0
0
2
0
2
2
4
0
0
0
2
2
2
2
0
0
4
0
0
4
0
2
4
4
0
0
0
0
0
0
0
4
4
4
0
0
0
0
2
0
0
4
2
0
0
0
0
4
0
0
0
0
0
0
0
4
0
0
0
0
0
2
0
0
0
0
0
0
0
4
0
0
0
0
0
2
4
2
0
2
2
0
4
2
0
2
0
0
0
0
2
2
0
4
0
2
0
4
0
...

result:

ok 

Test #43:

score: 10
Accepted
time: 36ms
memory: 4080kb

input:

0
10
4 1000000000
0 1
2 0
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
1 0
0 2
1 3
4 1000000000
0 1
2 0
3 1

output:

4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2

input:

1
66554
4 2 2
0
2
0 2 2
4
6
6 4 1
0
2 4 1
4
6 2 1
0
0 6 2
4
6
2 4 1
4
4 2 2
0
2
6 0 1
0
6 4 1
0
2 4 1
4
2 4 1
4
4 0 2
0
2
4 0 2
0
2
4 6 2
0
2
6 4 1
0
6 4 1
0
4 0 2
0
2
6 2 1
0
0 6 2
4
6
0 2 2
4
6
4 6 2
0
2
4 0 2
0
2
4 2 2
0
2
6 4 1
0
0 2 2
4
6
6 4 1
0
0 2 2
4
6
0 6 2
4
6
0 2 2
4
6
0 2 2
4
6
6 4 1
0
...

output:

2
4
0
4
0
6
4
2
0
0
4
4
0
0
0
0
0
0
0
6
4
0
0
2
0
4
0
4
6
4
4
0
0
0
4
2
4
2
0
0
0
4
0
4
0
4
4
4
0
6
4
0
6
4
0
6
2
4
4
0
0
4
0
0
4
0
0
6
4
4
6
4
4
4
4
6
0
2
0
0
4
4
4
4
2
0
4
4
0
4
4
4
0
0
6
0
0
0
4
4
6
0
4
4
4
0
4
4
4
0
4
4
4
4
4
2
0
0
0
4
6
0
0
4
2
0
0
4
4
0
2
4
4
4
4
0
4
2
4
4
4
0
0
6
0
4
0
0
4
0
...

result:

ok 

Test #44:

score: 10
Accepted
time: 0ms
memory: 3792kb

input:

0
10
7 1000000000
5 3
6 3
0 3
4 3
1 3
2 3
7 1000000000
3 0
4 0
5 0
1 0
2 0
6 0
7 1000000000
4 0
2 0
3 0
6 0
1 0
5 4
7 1000000000
4 1
0 1
5 1
3 1
2 1
6 4
7 1000000000
3 1
2 1
5 1
4 1
6 1
0 3
7 1000000000
6 3
1 3
0 3
2 3
4 6
5 6
7 1000000000
5 0
4 0
3 0
2 0
6 5
1 5
7 1000000000
0 1
6 1
5 1
3 1
4 0
2 0...

output:

7
0
8
10
12
6
2
4
7
0
8
10
2
4
6
12
7
0
12
6
8
4
2
10
7
0
12
10
8
2
6
4
7
0
2
4
12
8
6
10
7
0
8
10
12
4
6
2
7
0
4
12
10
8
6
2
7
0
8
12
6
10
4
2
7
0
6
8
12
4
10
2
7
0
12
4
6
8
10
2

input:

1
420
2 10 3
4
6
12
10 2 1
12
4 8 2
0
2
8 0 1
12
8 12 1
0
2 12 1
6
4 6 1
8
6 12 1
2
6 8 1
12
2 10 5
4
6
8
10
12
6 0 1
12
0 12 1
12
12 0 5
0
2
6
8
10
2 10 1
4
2 4 1
8
2 10 1
12
8 4 1
12
8 12 1
2
4 0 1
0
6 10 1
8
10 8 1
0
12 8 2
0
2
12 2 1
0
0 2 5
4
6
8
10
12
2 8 1
0
6 2 1
2
6 4 1
12
0 4 1
12
4 6 2
0
...

output:

12
12
0
12
0
6
8
2
12
10
12
12
0
4
8
12
12
2
0
8
0
2
0
4
0
2
12
12
0
12
0
8
12
0
2
0
6
0
4
2
12
8
2
4
8
0
2
0
8
0
2
2
8
0
0
0
2
0
0
2
12
2
0
12
0
0
0
12
4
12
2
0
2
12
2
8
0
12
0
12
2
2
2
8
8
0
0
12
6
12
2
2
12
0
8
6
0
0
8
0
12
12
0
12
0
12
2
0
8
0
0
12
2
10
0
6
6
0
0
0
12
2
6
0
2
4
2
10
0
4
2
2
8
6
...

result:

ok 

Test #45:

score: 10
Accepted
time: 0ms
memory: 3792kb

input:

0
10
7 1000000000
5 6
3 6
1 6
0 6
4 5
2 4
7 1000000000
1 0
2 0
6 0
4 0
5 1
3 5
7 1000000000
1 6
4 6
3 6
2 1
5 1
0 4
7 1000000000
6 5
0 5
3 5
4 6
1 6
2 0
7 1000000000
3 1
0 1
5 1
4 3
2 3
6 0
7 1000000000
3 0
1 0
2 0
5 3
4 3
6 1
7 1000000000
4 0
3 0
2 0
1 4
5 3
6 2
7 1000000000
2 0
5 0
1 0
6 2
3 5
4 6...

output:

7
0
10
4
8
6
2
12
7
0
6
8
4
12
2
10
7
0
8
4
10
12
6
2
7
0
6
12
8
4
10
2
7
0
10
6
2
4
8
12
7
0
10
12
6
4
2
8
7
0
2
12
8
4
6
10
7
0
12
6
8
4
10
2
7
0
6
12
2
4
8
10
7
0
2
4
6
10
12
8

input:

1
420
6 2 3
0
2
4
6 2 1
2
8 10 3
2
4
6
10 12 2
0
8
10 6 1
2
6 2 1
8
12 2 1
0
8 0 1
10
0 6 1
12
10 6 3
0
2
8
8 0 1
10
0 10 2
10
12
10 0 3
0
2
8
6 8 1
4
10 12 2
0
8
2 4 2
6
12
6 8 2
2
4
4 2 1
2
8 0 1
0
2 8 2
4
6
4 10 1
8
2 8 2
10
12
6 0 1
8
2 0 3
8
10
12
6 12 2
0
2
8 10 1
10
0 8 1
12
12 0 1
0
8 12 3
2...

output:

2
2
2
0
2
8
0
10
12
2
10
10
0
4
0
6
2
2
0
6
8
10
8
12
0
10
12
0
2
0
2
0
2
0
6
12
12
2
0
2
12
8
10
4
8
2
10
0
0
4
10
10
12
2
0
10
10
0
8
10
10
2
2
0
12
10
0
0
4
10
2
8
6
2
6
12
6
10
10
0
6
10
10
0
0
0
6
10
12
4
2
2
2
2
10
10
6
4
0
6
12
4
8
6
4
2
10
8
2
8
6
12
2
8
0
12
12
10
10
0
6
10
12
0
6
12
2
2
2
...

result:

ok 

Test #46:

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

input:

0
10
7 1000000000
0 4
1 4
5 4
3 0
6 3
2 6
7 1000000000
1 4
3 4
0 4
5 1
6 5
2 6
7 1000000000
6 4
1 4
5 6
0 1
3 5
2 0
6 1000000000
3 4
5 4
1 4
0 4
2 4
6 1000000000
3 4
0 4
2 4
1 4
5 4
6 1000000000
2 0
5 0
3 0
4 0
1 2
6 1000000000
4 0
1 0
5 0
3 0
2 4
6 1000000000
2 1
4 1
5 1
3 1
0 2
6 1000000000
5 4
0 ...

output:

7
0
2
10
12
6
4
8
7
0
2
6
10
12
8
4
7
0
10
12
6
2
4
8
6
0
6
8
2
10
4
6
0
6
4
2
10
8
6
0
2
4
8
10
6
6
0
6
2
10
4
8
6
0
2
10
8
4
6
6
0
8
6
4
10
2
6
0
10
4
8
2
6

input:

1
336
0 10 4
4
6
8
10
10 0 5
0
2
4
6
8
8 4 2
2
4
4 10 2
0
2
4 6 2
6
8
0 10 1
10
10 4 2
0
2
2 10 4
4
6
8
10
12 8 2
0
8
4 2 1
10
0 10 1
10
4 6 1
10
10 4 5
0
2
4
6
8
10 2 2
0
2
2 8 3
6
8
10
0 10 2
6
12
8 2 2
10
12
4 8 2
0
2
10 12 1
12
8 10 1
2
0 4 2
10
12
10 0 1
0
6 12 1
4
2 12 2
8
10
2 8 2
8
12
0 4 4
...

output:

10
0
4
0
6
10
2
10
8
10
10
10
4
2
8
12
12
0
12
2
10
0
4
10
8
4
0
0
2
10
6
2
12
10
10
4
10
2
2
2
12
12
10
0
6
4
2
2
2
2
12
12
2
2
0
6
10
2
4
6
10
2
0
0
0
2
2
2
6
10
0
4
2
10
4
4
8
10
10
4
0
2
4
6
10
12
4
10
4
4
0
0
12
6
8
0
2
0
0
8
8
4
4
0
10
8
4
10
0
10
2
6
0
10
12
0
10
2
0
2
0
8
10
2
0
0
2
8
4
2
10...

result:

ok 

Test #47:

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

input:

0
10
6 1000000000
4 0
1 0
3 0
5 4
2 1
6 1000000000
0 3
4 3
1 3
5 0
2 5
6 1000000000
4 2
3 2
1 2
0 4
5 0
6 1000000000
2 1
5 1
0 2
3 5
4 0
5 1000000000
0 4
2 4
3 4
1 4
5 1000000000
4 2
3 2
1 2
0 2
5 1000000000
0 2
4 2
1 2
3 0
5 1000000000
4 2
3 2
1 2
0 4
5 1000000000
3 4
1 4
0 4
2 3
5 1000000000
2 1
4...

output:

6
0
8
6
10
4
2
6
0
4
8
6
2
10
6
0
6
2
4
8
10
6
0
2
8
4
10
6
5
0
6
2
4
8
5
0
6
8
4
2
5
0
4
6
8
2
5
0
6
2
4
8
5
0
6
4
2
8
5
0
2
6
4
8

input:

1
240
4 0 1
2
0 2 1
8
2 0 2
6
8
6 2 2
2
4
0 8 2
8
10
0 4 1
8
6 8 3
0
2
4
4 2 1
8
6 10 1
8
4 6 1
6
2 6 1
8
6 2 1
8
0 6 1
8
8 6 2
0
2
10 6 1
0
8 4 2
0
6
6 4 3
0
2
4
6 8 1
2
10 8 2
0
8
6 8 1
8
4 8 1
6
0 2 1
8
10 4 1
0
10 0 1
0
10 0 2
0
8
8 6 2
0
2
6 4 1
8
2 0 2
4
8
2 6 2
6
8
4 0 1
6
0 8 1
8
0 2 2
6
8
6...

output:

2
8
8
2
8
8
0
8
8
6
8
8
8
2
0
0
4
2
8
8
6
8
0
0
0
2
8
8
6
6
8
6
0
2
0
8
6
0
4
8
0
0
2
0
10
8
8
0
0
2
6
8
0
8
2
4
0
2
0
0
8
2
0
4
8
6
8
2
0
8
8
6
6
8
2
8
2
8
6
2
6
4
8
4
6
8
8
6
2
8
8
2
0
4
0
6
8
2
10
2
8
2
0
8
6
0
2
6
8
6
8
0
4
0
6
4
6
2
8
8
6
6
10
0
2
8
2
8
8
0
0
2
8
8
8
8
0
6
6
0
8
0
6
0
10
6
2
4
...

result:

ok 

Test #48:

score: 10
Accepted
time: 0ms
memory: 3788kb

input:

0
6
4 1000000000
3 2
1 2
0 2
4 1000000000
1 0
2 0
3 0
4 1000000000
2 3
1 3
0 2
3 1000000000
2 1
0 1
3 1000000000
1 0
2 0
2 1000000000
0 1

output:

4
0
4
6
2
4
0
2
4
6
4
0
4
6
2
3
0
4
2
3
0
2
4
2
0
2

input:

1
50
6 0 1
0
2 4 1
0
4 2 1
2
2 0 1
0
0 2 1
6
0 4 2
2
4
4 2 1
0
2 4 1
6
6 4 2
0
2
0 2 2
2
4
6 0 3
0
2
4
2 0 1
0
4 6 1
6
2 6 1
6
4 0 1
0
0 4 1
6
4 0 1
2
4 2 2
0
2
2 0 1
0
6 2 2
0
2
2 6 1
0
2 4 2
4
6
0 2 1
2
4 0 1
0
0 2 1
4
6 4 3
0
2
4
2 0 2
4
6
2 0 1
6
0 2 3
2
4
6
4 2 1
6
0 4 3
2
4
6
6 0 2
0
2
0 6 1
6...

output:

0
0
2
0
6
4
0
6
2
2
0
0
6
6
0
6
2
2
0
2
0
4
2
0
4
4
6
6
2
6
4
0
6
6
0
0
6
0
0
0
6
6
4
2
2
6
4
4
6
0

result:

ok 

Test #49:

score: 10
Accepted
time: 34ms
memory: 4088kb

input:

0
10
8 1000000000
5 6
4 7
5 1
7 2
0 3
2 1
6 0
8 1000000000
7 6
4 7
7 2
3 7
7 5
1 3
7 0
8 1000000000
0 1
2 0
1 3
4 1
5 2
6 2
7 3
8 1000000000
4 2
6 0
0 1
4 7
1 4
4 3
4 5
8 1000000000
6 0
6 2
6 5
7 6
6 3
6 4
6 1
8 1000000000
7 2
5 7
7 6
1 7
4 7
7 3
7 0
8 1000000000
6 5
7 3
1 2
2 7
0 1
5 3
4 5
8 100000...

output:

8
0
12
6
2
8
4
14
10
8
0
10
6
8
4
12
2
14
8
0
8
14
2
6
10
12
4
8
0
14
6
10
4
12
2
8
8
0
12
2
8
10
4
14
6
8
0
8
2
12
10
4
6
14
8
0
14
2
4
8
10
6
12
8
0
12
10
14
8
4
6
2
8
0
8
6
10
14
4
2
12
8
0
14
2
12
4
10
6
8

input:

1
57240
12 4 1
4
14 8 2
0
2
14 6 2
0
4
8 14 1
10
12 10 1
4
10 12 1
14
10 8 1
12
10 4 1
4
8 0 1
6
6 2 1
14
12 14 1
14
0 14 1
14
10 14 3
4
6
8
0 10 1
14
12 4 2
2
4
2 10 1
14
2 0 2
4
8
8 14 1
10
6 8 1
10
10 8 1
14
2 14 1
14
12 14 2
4
6
4 12 1
14
14 8 7
0
2
4
6
8
10
12
10 0 2
4
6
12 2 3
0
2
10
6 8 1
4
1...

output:

4
2
4
10
4
14
12
4
6
14
14
14
4
14
4
14
8
10
10
14
14
4
14
8
4
2
4
4
2
10
4
12
14
4
14
6
4
8
14
10
14
14
14
4
14
14
14
14
14
14
4
0
8
10
2
4
14
4
14
14
6
14
2
0
12
14
14
4
14
8
8
0
10
8
0
14
14
6
14
10
14
14
4
12
0
12
4
14
8
0
14
14
14
12
2
14
4
10
8
2
12
2
14
12
14
14
14
6
4
12
14
4
0
14
2
14
10
10...

result:

ok 

Test #50:

score: 10
Accepted
time: 34ms
memory: 4072kb

input:

0
10
8 1000000000
1 3
4 1
0 1
6 1
1 2
1 7
5 1
8 1000000000
4 0
2 0
5 4
3 5
7 2
1 6
0 1
8 1000000000
0 5
6 2
0 6
3 6
4 5
1 4
4 7
8 1000000000
5 1
5 7
3 0
2 3
3 1
7 4
3 6
8 1000000000
2 4
0 1
5 3
1 2
7 0
4 3
5 6
8 1000000000
6 5
1 2
0 3
6 1
2 4
3 4
7 0
8 1000000000
3 6
5 0
4 0
0 6
7 0
1 3
2 0
8 100000...

output:

8
0
14
8
2
4
12
6
10
8
0
14
10
4
6
2
12
8
8
0
4
10
12
2
8
14
6
8
0
4
2
14
8
10
12
6
8
0
12
2
4
10
8
6
14
8
0
4
10
12
2
6
8
14
8
0
8
14
6
4
2
10
12
8
0
10
12
2
14
4
6
8
8
0
10
8
14
12
6
2
4
8
0
14
12
8
6
4
10
2

input:

1
56820
12 10 1
14
6 2 1
14
14 2 1
0
2 10 6
4
6
8
10
12
14
14 12 3
0
10
12
0 6 1
14
2 6 3
4
6
8
4 2 2
8
10
8 0 1
14
12 4 1
14
8 10 1
10
6 2 1
14
6 10 1
8
10 6 1
14
8 4 1
2
0 4 2
12
14
6 10 1
2
12 0 1
14
14 6 1
0
12 2 1
14
10 14 1
14
8 0 2
4
6
0 4 1
14
8 10 1
14
12 4 2
0
2
2 12 3
4
6
8
12 2 1
14
2 12...

output:

14
14
0
10
12
14
6
10
14
14
10
14
8
14
2
12
2
14
0
14
14
4
14
14
2
8
14
14
6
6
8
10
2
14
10
6
0
10
10
2
14
14
14
8
12
12
0
14
0
14
12
14
12
14
8
14
14
4
14
14
0
12
0
4
0
14
10
8
14
14
14
0
0
10
4
0
0
0
0
10
14
2
0
2
6
12
14
0
2
8
6
14
4
14
6
14
8
14
12
6
12
10
6
14
14
8
0
2
8
14
12
14
14
0
6
0
8
0
1...

result:

ok 

Test #51:

score: 10
Accepted
time: 26ms
memory: 4084kb

input:

0
10
8 1000000000
2 7
4 2
5 3
1 6
0 1
1 4
3 7
8 1000000000
4 2
0 4
4 5
4 1
4 6
4 7
4 3
8 1000000000
0 7
5 3
5 1
2 3
1 4
0 6
6 4
8 1000000000
6 4
5 4
4 0
4 1
2 0
7 4
4 3
8 1000000000
0 6
4 0
1 7
5 7
7 2
6 3
4 2
8 1000000000
3 1
3 6
5 0
4 7
2 4
2 5
1 0
8 1000000000
4 7
6 5
7 5
5 3
0 7
1 5
2 7
8 100000...

output:

8
0
14
12
10
4
8
2
6
8
0
6
2
12
14
4
8
10
8
0
12
8
10
4
6
14
2
8
0
6
14
10
12
4
2
8
8
0
8
6
2
14
10
4
12
8
0
14
2
10
6
8
12
4
8
0
10
12
8
2
4
6
14
8
0
10
2
4
14
8
12
6
8
0
6
14
2
8
4
10
12
8
0
14
2
12
8
10
4
6

input:

1
57000
10 2 1
14
0 10 2
8
14
8 6 1
2
2 0 2
6
8
12 4 1
14
10 8 1
14
14 2 3
0
2
4
14 12 4
0
2
10
12
12 6 3
6
8
10
4 10 2
0
2
2 12 1
14
4 10 2
0
2
4 6 1
12
0 4 1
14
8 6 1
12
8 0 2
0
2
12 6 3
6
8
10
8 6 1
12
4 10 2
0
2
6 12 1
12
10 2 1
14
6 4 2
12
14
4 12 1
6
0 14 1
14
10 0 2
6
8
0 8 2
8
14
12 8 1
14
1...

output:

14
14
2
8
14
14
2
12
6
0
14
0
12
14
12
0
6
12
0
12
14
14
6
14
6
8
14
0
12
0
0
2
2
14
14
14
6
10
14
0
14
2
6
6
2
8
14
14
2
2
6
14
12
8
6
14
2
12
14
12
14
8
0
4
14
14
0
12
6
14
4
12
4
14
6
14
14
12
2
14
14
10
4
14
2
0
4
6
0
14
12
6
14
10
14
14
14
0
14
12
14
12
12
10
14
2
4
14
12
14
8
6
14
14
14
12
4
1...

result:

ok 

Test #52:

score: 10
Accepted
time: 34ms
memory: 3792kb

input:

0
10
8 1000000000
2 7
4 2
5 3
1 6
0 1
1 4
3 7
8 1000000000
4 2
0 4
4 5
4 1
4 6
4 7
4 3
8 1000000000
0 7
5 3
5 1
2 3
1 4
0 6
6 4
8 1000000000
6 4
5 4
4 0
4 1
2 0
7 4
4 3
8 1000000000
0 6
4 0
1 7
5 7
7 2
6 3
4 2
8 1000000000
3 1
3 6
5 0
4 7
2 4
2 5
1 0
8 1000000000
4 7
6 5
7 5
5 3
0 7
1 5
2 7
8 100000...

output:

8
0
14
12
10
4
8
2
6
8
0
6
2
12
14
4
8
10
8
0
12
8
10
4
6
14
2
8
0
6
14
10
12
4
2
8
8
0
8
6
2
14
10
4
12
8
0
14
2
10
6
8
12
4
8
0
10
12
8
2
4
6
14
8
0
10
2
4
14
8
12
6
8
0
6
14
2
8
4
10
12
8
0
14
2
12
8
10
4
6

input:

1
57000
10 2 1
14
0 10 2
8
14
8 6 1
2
2 0 2
6
8
12 4 1
14
10 8 1
14
14 2 3
0
2
4
14 12 4
0
2
10
12
12 6 3
6
8
10
4 10 2
0
2
2 12 1
14
4 10 2
0
2
4 6 1
12
0 4 1
14
8 6 1
12
8 0 2
0
2
12 6 3
6
8
10
8 6 1
12
4 10 2
0
2
6 12 1
12
10 2 1
14
6 4 2
12
14
4 12 1
6
0 14 1
14
10 0 2
6
8
0 8 2
8
14
12 8 1
14
1...

output:

14
14
2
8
14
14
2
12
6
0
14
0
12
14
12
0
6
12
0
12
14
14
6
14
6
8
14
0
12
0
0
2
2
14
14
14
6
10
14
0
14
2
6
6
2
8
14
14
2
2
6
14
12
8
6
14
2
12
14
12
14
8
0
4
14
14
0
12
6
14
4
12
4
14
6
14
14
12
2
14
14
10
4
14
2
0
4
6
0
14
12
6
14
10
14
14
14
0
14
12
14
12
12
10
14
2
4
14
12
14
8
6
14
14
14
12
4
1...

result:

ok 

Test #53:

score: 10
Accepted
time: 34ms
memory: 4044kb

input:

0
10
8 1000000000
2 7
4 2
5 3
1 6
0 1
1 4
3 7
8 1000000000
4 2
0 4
4 5
4 1
4 6
4 7
4 3
8 1000000000
0 7
5 3
5 1
2 3
1 4
0 6
6 4
8 1000000000
6 4
5 4
4 0
4 1
2 0
7 4
4 3
8 1000000000
0 6
4 0
1 7
5 7
7 2
6 3
4 2
8 1000000000
3 1
3 6
5 0
4 7
2 4
2 5
1 0
8 1000000000
4 7
6 5
7 5
5 3
0 7
1 5
2 7
8 100000...

output:

8
0
14
12
10
4
8
2
6
8
0
6
2
12
14
4
8
10
8
0
12
8
10
4
6
14
2
8
0
6
14
10
12
4
2
8
8
0
8
6
2
14
10
4
12
8
0
14
2
10
6
8
12
4
8
0
10
12
8
2
4
6
14
8
0
10
2
4
14
8
12
6
8
0
6
14
2
8
4
10
12
8
0
14
2
12
8
10
4
6

input:

1
57000
10 2 1
14
0 10 2
8
14
8 6 1
2
2 0 2
6
8
12 4 1
14
10 8 1
14
14 2 3
0
2
4
14 12 4
0
2
10
12
12 6 3
6
8
10
4 10 2
0
2
2 12 1
14
4 10 2
0
2
4 6 1
12
0 4 1
14
8 6 1
12
8 0 2
0
2
12 6 3
6
8
10
8 6 1
12
4 10 2
0
2
6 12 1
12
10 2 1
14
6 4 2
12
14
4 12 1
6
0 14 1
14
10 0 2
6
8
0 8 2
8
14
12 8 1
14
1...

output:

14
14
2
8
14
14
2
12
6
0
14
0
12
14
12
0
6
12
0
12
14
14
6
14
6
8
14
0
12
0
0
2
2
14
14
14
6
10
14
0
14
2
6
6
2
8
14
14
2
2
6
14
12
8
6
14
2
12
14
12
14
8
0
4
14
14
0
12
6
14
4
12
4
14
6
14
14
12
2
14
14
10
4
14
2
0
4
6
0
14
12
6
14
10
14
14
14
0
14
12
14
12
12
10
14
2
4
14
12
14
8
6
14
14
14
12
4
1...

result:

ok 

Subtask #5:

score: 50
Acceptable Answer

Test #54:

score: 50
Acceptable Answer
time: 36ms
memory: 3808kb

input:

0
10
3 1000000000
1 0
2 1
998 1000000000
928 443
90 795
55 379
957 417
759 300
960 136
309 858
833 370
228 827
876 955
619 365
15 108
243 388
54 925
141 894
272 634
0 989
600 346
380 277
350 113
326 613
975 946
660 98
34 538
220 864
9 585
185 860
458 424
509 14
22 275
109 872
153 233
76 834
972 736
...

output:

3
0
4
2
998
0
538
1882
1484
1278
140
1568
1136
1982
730
182
888
1962
918
834
1318
174
128
1124
52
588
318
1450
1638
1624
62
222
1250
1834
1564
1940
1252
1578
1382
740
460
642
922
1402
1916
12
702
1164
1338
1656
758
1142
986
458
316
480
76
630
54
410
498
976
1664
358
398
1822
858
656
896
552
74
1572
...

input:

1
59797
2 4 2
4
6
532 626 2
986
988
2 0 1
0
128 64 2
96
98
214 1564 2
760
762
6 0 2
0
2
6 4 2
0
2
524 820 2
1876
1878
1540 1942 2
1430
1432
1564 1414 2
720
722
0 2 1
2
1016 1008 2
502
504
1122 394 2
396
398
1948 1754 2
452
454
4 0 2
0
2
1810 1208 2
474
476
1484 1082 2
514
516
38 52 2
186
188
10 12 2...

output:

4
986
0
96
762
0
2
1876
1430
722
2
504
396
454
0
476
516
186
12
176
1058
0
6
1048
218
1094
1652
1810
1546
2
0
214
376
4
1502
44
94
1746
144
0
4
2
1228
1864
0
872
1304
626
1030
10
2
106
980
0
16
1244
1074
2
1778
6
2
676
6
18
600
108
6
1250
232
4
10
1818
198
842
1824
1350
2
922
1182
1368
4
132
4
6
14
...

result:

points 0.81967213110 max label = 1998

Test #55:

score: 50
Acceptable Answer
time: 34ms
memory: 3872kb

input:

0
10
997 1000000000
210 799
337 790
66 160
541 810
854 650
948 726
189 923
593 566
649 647
907 215
598 271
78 173
820 920
364 470
435 553
634 846
276 104
203 761
874 954
20 983
946 834
365 933
37 641
811 497
970 551
42 389
59 52
747 45
35 291
534 616
284 677
215 83
741 600
549 680
58 500
495 489
664...

output:

997
0
246
286
592
1122
1852
1340
588
58
1904
1286
112
242
1434
1696
1662
6
1858
1502
1382
1570
470
186
948
920
1078
1352
1926
1332
1900
792
870
1402
604
832
1504
1218
1386
1892
106
1380
1870
744
1542
128
426
1196
708
1124
752
676
152
732
1802
1282
278
936
1146
1610
1790
422
1530
562
618
1094
1810
15...

input:

1
50045
1120 1570 2
434
436
634 670 2
874
876
686 1186 2
1544
1546
766 490 2
1678
1680
1482 1910 2
1040
1042
1130 596 2
378
380
1034 682 2
474
476
764 680 2
1610
1612
838 1856 2
344
346
260 1724 2
946
948
818 898 2
1412
1414
344 350 2
1164
1166
1066 528 2
1378
1380
1454 1088 2
920
922
988 1368 2
145...

output:

434
874
1544
1680
1040
380
476
1612
344
948
1412
1164
1380
922
1456
1812
1714
1492
636
752
922
394
1374
1590
1112
270
552
1254
286
1602
514
466
252
490
1062
120
152
104
722
758
1084
0
1348
1866
796
1598
382
1450
1186
1816
446
122
890
856
1780
348
1834
226
242
906
1820
1182
1336
450
848
1668
720
1408...

result:

points 0.81967213110 max label = 1998

Test #56:

score: 61
Accepted
time: 48ms
memory: 3872kb

input:

0
10
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0

output:

2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2

input:

1
100000
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
0 2...

output:

2
2
2
0
2
2
2
2
2
2
0
2
0
2
0
0
2
2
0
2
2
2
0
0
0
0
0
0
2
2
0
2
2
2
2
0
2
0
2
2
0
2
0
2
0
2
2
2
2
2
0
2
0
0
2
2
0
2
0
2
2
2
2
2
2
2
2
0
0
0
0
0
0
2
0
2
2
2
2
0
2
0
2
0
2
0
0
0
2
0
0
2
2
2
0
2
0
2
2
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
2
0
0
2
0
0
0
0
2
0
2
2
2
2
2
0
2
0
2
0
2
2
2
0
2
0
0
0
0
2
2
2
0
0
...

result:

ok 

Test #57:

score: 61
Accepted
time: 40ms
memory: 3788kb

input:

0
10
3 1000000000
0 2
1 0
3 1000000000
1 0
2 1
3 1000000000
2 1
0 1
3 1000000000
2 0
0 1
3 1000000000
0 1
2 1
3 1000000000
1 2
0 2
3 1000000000
0 2
2 1
3 1000000000
1 0
2 1
3 1000000000
0 2
0 1
3 1000000000
2 0
1 0

output:

3
0
4
2
3
0
4
2
3
0
4
2
3
0
4
2
3
0
4
2
3
0
2
4
3
0
2
4
3
0
4
2
3
0
4
2
3
0
4
2

input:

1
74928
0 2 1
4
0 2 1
4
4 0 2
0
2
2 4 1
4
2 0 1
4
2 0 1
4
2 4 1
0
2 4 1
4
0 4 2
2
4
4 0 1
0
4 2 1
0
0 4 1
4
2 0 1
4
4 2 2
0
2
4 2 1
0
2 0 1
4
0 2 1
4
0 4 2
2
4
2 0 1
0
2 0 1
0
2 0 1
4
0 4 2
2
4
4 2 2
0
2
0 4 1
4
2 0 1
0
0 2 1
4
0 2 1
4
0 2 1
4
0 4 2
2
4
0 4 1
4
0 2 2
2
4
2 0 1
4
0 4 1
4
2 0 1
4
2 0 ...

output:

4
4
0
4
4
4
0
4
4
0
0
4
4
2
0
4
4
4
0
0
4
4
2
4
0
4
4
4
4
4
2
4
4
4
0
0
4
4
4
2
4
4
0
4
4
4
4
0
4
4
4
0
4
2
0
0
4
4
0
4
4
4
2
4
4
0
4
4
4
4
4
2
4
0
0
4
0
2
0
4
0
0
0
4
4
2
4
4
4
2
0
4
2
2
0
4
0
4
4
0
4
4
0
0
0
2
4
0
4
4
0
4
0
4
0
4
0
0
0
4
2
4
4
4
0
2
2
4
0
4
0
4
0
4
0
2
0
2
2
4
0
0
0
2
0
2
0
4
0
4
...

result:

ok 

Test #58:

score: 61
Accepted
time: 36ms
memory: 3808kb

input:

0
10
4 1000000000
1 2
0 2
1 3
4 1000000000
3 0
1 2
0 1
4 1000000000
2 3
3 0
0 1
4 1000000000
2 3
1 2
0 3
4 1000000000
1 3
0 3
2 0
4 1000000000
3 0
3 2
1 0
4 1000000000
3 1
0 1
2 3
4 1000000000
1 0
3 0
1 2
4 1000000000
3 1
2 3
1 0
4 1000000000
0 1
3 0
1 2

output:

4
0
2
6
4
4
0
6
4
2
4
0
6
2
4
4
0
4
2
6
4
0
2
6
4
4
0
6
2
4
4
0
6
4
2
4
0
4
2
6
4
0
6
4
2
4
0
4
2
6

input:

1
66734
2 0 1
4
2 6 2
4
6
4 2 2
0
2
6 0 2
0
4
4 2 2
0
2
2 0 2
4
6
4 0 2
0
2
2 6 2
4
6
0 2 2
4
6
2 6 1
4
2 0 1
4
0 4 2
4
6
2 4 1
4
0 2 2
4
6
6 2 2
0
4
6 0 1
0
4 6 1
6
4 0 1
2
0 6 1
6
6 4 2
0
2
6 0 2
0
4
2 0 1
4
0 2 2
4
6
6 0 1
0
4 0 1
2
2 0 1
4
6 2 1
0
0 6 1
6
0 6 2
4
6
4 0 2
0
2
4 2 1
6
6 0 2
0
2
2 ...

output:

4
6
2
0
2
6
0
6
4
4
4
4
4
4
0
0
6
2
6
2
0
4
4
0
2
4
0
6
6
0
6
0
6
6
0
2
2
4
0
0
0
4
0
6
2
0
0
0
4
0
4
6
0
2
2
0
6
0
2
0
2
6
6
2
2
0
0
0
2
2
2
2
4
2
0
2
0
2
2
6
0
0
6
2
4
6
2
6
4
4
0
0
2
0
2
0
0
0
0
2
0
6
0
6
2
6
6
0
4
0
4
4
2
4
0
0
0
0
4
0
4
0
4
2
2
2
2
2
0
6
6
6
4
0
6
6
4
0
0
0
2
2
4
0
0
2
4
6
2
4
...

result:

ok 

Test #59:

score: 50
Acceptable Answer
time: 26ms
memory: 3784kb

input:

0
10
1000 1000000000
313 401
316 54
721 11
679 942
681 467
84 472
977 306
285 19
891 45
654 702
294 627
927 124
583 515
700 300
401 460
521 643
911 738
818 7
895 746
370 781
405 64
904 359
22 187
609 408
363 713
768 965
345 943
512 10
149 608
438 998
642 108
680 783
648 653
592 351
79 477
759 16
430...

output:

1000
0
1222
388
1186
1056
1012
1392
448
122
386
1548
1868
56
464
862
1316
1008
1820
1462
596
1824
528
1508
736
1036
294
272
1606
1876
1664
378
104
1424
1570
232
1106
366
1016
536
1210
1956
800
784
1000
1942
156
914
28
1262
1658
1654
876
1244
174
624
1460
336
1286
494
1538
1276
1556
1156
1004
260
183...

input:

1
50038
802 1552 2
1564
1566
930 1542 2
1572
1574
1824 516 2
82
84
918 1200 2
1080
1082
334 1930 2
1572
1574
1188 786 2
718
720
1448 1710 2
1352
1354
622 1850 2
1562
1564
484 438 2
1700
1702
1892 60 2
1112
1114
1042 412 2
1962
1964
1572 1964 2
794
796
1346 1674 2
1410
1412
1686 1100 2
312
314
28 105...

output:

1564
1572
84
1082
1574
720
1352
1564
1702
1112
1964
794
1412
314
478
24
270
1020
1572
1498
1710
1482
356
304
1296
522
160
1992
46
1332
232
1218
502
1686
1342
1590
1180
1560
376
1592
818
350
1460
1064
462
604
120
298
1664
1990
96
1160
1666
116
188
1874
972
1612
766
1100
488
370
1298
1702
378
84
614
1...

result:

points 0.81967213110 max label = 1998

Test #60:

score: 50
Acceptable Answer
time: 26ms
memory: 4072kb

input:

0
1
1000 1000000000
165 608
217 371
579 924
67 365
865 568
258 7
999 657
669 881
268 354
140 308
76 139
428 750
616 661
178 737
179 1
705 411
437 759
119 472
353 50
549 581
327 276
319 864
662 404
619 776
651 890
153 938
580 396
501 193
560 607
786 871
291 760
898 722
511 542
743 74
742 918
431 774
...

output:

1000
0
1062
956
58
1538
376
398
1098
1438
1976
1544
862
872
350
200
1958
1306
1206
1048
698
906
1698
250
1010
452
954
1780
370
1392
330
314
10
1528
290
622
1480
266
316
262
1458
1874
588
450
1726
984
1100
1810
668
1058
866
1256
1558
1904
1344
128
732
14
208
1820
1126
788
1870
1798
1368
820
964
1772
...

input:

1
50048
1100 70 2
14
16
1776 608 2
1336
1338
780 1960 2
334
336
718 1090 2
396
398
1122 476 2
1990
1992
692 630 2
422
424
1296 1056 2
1816
1818
40 1704 2
1074
1076
4 572 2
1110
1112
1224 1398 2
1888
1890
930 1564 2
184
186
716 1196 2
398
400
1266 868 2
1846
1848
914 1522 2
200
202
588 472 2
526
528
...

output:

16
1336
334
396
1992
424
1818
1076
1110
1888
184
398
1848
200
526
748
952
396
1870
1676
444
228
1630
1242
2
492
76
702
1534
602
440
1868
1846
1000
1416
548
892
924
1512
1794
1600
1940
1418
1376
774
584
1460
1282
1288
1820
744
990
196
1636
782
1198
508
252
1742
50
228
1356
170
108
1318
1300
1972
260
...

result:

points 0.81967213110 max label = 1998

Test #61:

score: 61
Accepted
time: 0ms
memory: 3788kb

input:

0
10
4 1000000000
0 1
1 2
2 3
4 1000000000
0 1
1 3
3 2
4 1000000000
0 2
2 1
1 3
4 1000000000
0 2
2 3
3 1
4 1000000000
0 3
3 1
1 2
4 1000000000
0 3
3 2
2 1
4 1000000000
1 0
0 2
2 3
4 1000000000
1 0
0 3
3 2
4 1000000000
1 2
2 0
0 3
4 1000000000
1 3
3 0
0 2

output:

4
0
6
2
4
4
0
6
4
2
4
0
2
6
4
4
0
4
6
2
4
0
2
4
6
4
0
4
2
6
4
0
2
6
4
4
0
2
4
6
4
0
2
4
6
4
0
2
6
4

input:

1
120
4 2 1
6
6 4 2
0
2
4 6 1
2
0 2 1
6
4 6 1
2
0 6 2
4
6
6 2 2
0
2
4 2 2
0
2
2 0 1
0
4 0 1
2
0 4 1
6
2 6 2
4
6
6 2 2
0
2
6 2 2
0
4
0 6 1
6
6 0 2
0
2
0 6 1
6
2 0 2
4
6
6 0 1
0
0 4 1
6
0 4 2
4
6
2 6 1
0
0 2 1
6
0 2 1
6
2 4 1
0
2 0 1
4
4 0 2
0
2
6 2 2
0
4
2 4 2
4
6
0 2 2
2
6
6 4 2
0
2
4 2 1
2
2 4 1
0
...

output:

6
2
2
6
2
6
2
2
0
2
6
6
2
0
6
0
6
6
0
6
4
0
6
6
0
4
0
0
4
2
2
2
0
4
4
6
2
2
2
6
6
2
0
2
0
2
2
6
2
6
6
0
6
4
4
0
6
0
6
4
6
6
0
2
0
6
0
2
4
4
4
6
2
0
2
2
2
6
6
2
6
6
4
0
6
2
4
2
2
4
0
4
6
2
4
6
6
2
6
6
6
2
2
4
2
6
6
6
0
0
0
6
6
0
2
0
6
6
4
0

result:

ok 

Test #62:

score: 61
Accepted
time: 0ms
memory: 4024kb

input:

0
10
6 1000000000
0 1
1 2
2 3
3 4
4 5
6 1000000000
0 1
1 2
2 3
3 5
5 4
6 1000000000
0 1
1 2
2 4
4 3
3 5
6 1000000000
0 1
1 2
2 4
4 5
5 3
6 1000000000
0 1
1 2
2 5
5 3
3 4
6 1000000000
0 1
1 2
2 5
5 4
4 3
6 1000000000
0 1
1 3
3 2
2 4
4 5
6 1000000000
0 1
1 3
3 2
2 5
5 4
6 1000000000
0 1
1 3
3 4
4 2
2 ...

output:

6
0
10
2
8
4
6
6
0
10
2
8
6
4
6
0
10
2
4
8
6
6
0
10
2
6
8
4
6
0
10
2
4
6
8
6
0
10
2
6
4
8
6
0
10
8
2
4
6
6
0
10
8
2
6
4
6
0
10
4
2
8
6
6
0
10
6
2
8
4

input:

1
300
0 8 1
10
4 10 2
6
8
10 8 2
0
2
2 0 2
8
10
0 6 1
10
6 2 1
4
4 2 2
6
8
10 8 2
0
2
6 8 1
4
4 0 2
6
8
0 2 1
10
4 0 2
6
8
4 0 2
6
8
10 4 2
0
2
2 4 2
8
10
4 0 2
6
8
6 10 1
4
4 6 2
6
8
2 10 2
8
10
2 10 2
8
10
4 0 2
6
8
6 4 1
4
0 4 1
10
0 8 1
10
0 2 1
10
10 6 2
0
2
0 6 1
10
6 0 1
4
2 10 2
8
10
2 4 2
8...

output:

10
8
2
10
10
4
8
2
4
8
10
8
8
2
8
8
4
6
10
10
8
4
10
10
10
2
10
4
10
8
4
8
2
10
8
4
8
4
10
10
8
4
10
4
4
0
2
4
0
8
10
10
2
10
8
2
2
4
2
2
8
8
10
10
2
2
2
2
0
2
8
4
6
10
2
2
10
8
4
4
0
4
10
8
4
2
2
2
10
8
4
4
4
8
8
4
8
2
4
4
10
4
4
8
4
2
2
4
8
4
6
4
2
8
10
4
10
4
10
4
8
4
4
2
4
8
10
10
2
6
0
10
2
2
4...

result:

ok 

Test #63:

score: 61
Accepted
time: 0ms
memory: 3788kb

input:

0
3
3 1000000000
0 1
1 2
3 1000000000
0 2
2 1
3 1000000000
1 0
0 2

output:

3
0
4
2
3
0
2
4
3
0
2
4

input:

1
18
4 0 2
0
2
2 0 1
0
4 2 2
0
2
0 4 1
4
2 0 1
4
0 4 1
4
0 2 2
2
4
4 0 2
0
2
2 4 1
4
4 0 1
0
4 2 2
0
2
2 4 1
0
0 2 1
4
0 2 1
4
2 4 1
4
0 4 2
2
4
2 0 1
4
4 2 1
0

output:

0
0
2
4
4
4
2
0
4
0
2
0
4
4
4
4
4
0

result:

ok 

Test #64:

score: 50
Acceptable Answer
time: 34ms
memory: 3744kb

input:

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

output:

997
0
1022
1992
2
512
1024
1534
256
510
766
1020
1278
1532
1788
1990
4
130
258
384
514
640
768
894
1026
1152
1280
1406
1536
1662
1790
1916
66
128
192
254
320
382
446
508
576
638
702
764
830
892
956
1018
1088
1150
1214
1276
1342
1404
1468
1530
1598
1660
1724
1786
1852
1914
1958
1988
6
36
68
98
132
16...

input:

1
49888
1408 780 3
1422
1436
1468
358 742 1
354
1542 406 1
1540
1494 798 1
1492
942 1378 3
944
946
954
956 1592 3
894
896
926
440 1634 1
438
1918 1134 3
1932
1942
1958
1890 564 1
1886
1080 1862 3
1082
1084
1086
980 284 3
982
984
986
1162 168 3
1164
1166
1168
1780 788 1
1778
1662 664 3
1724
1786
1788...

output:

1468
354
1540
1492
954
894
438
1958
1886
1086
986
1168
1778
1788
1284
1716
960
66
910
38
1004
830
1960
1876
608
1492
1406
1822
1136
1790
336
1956
544
128
1906
476
898
1784
1024
476
918
1568
380
1360
366
1026
1538
134
382
338
1334
1156
486
1748
748
592
860
1120
1372
1184
1142
350
892
1918
726
1290
17...

result:

points 0.81967213110 max label = 1998

Test #65:

score: 50
Acceptable Answer
time: 28ms
memory: 4088kb

input:

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

output:

512
0
512
1022
2
258
514
768
130
256
384
510
640
766
894
1020
4
68
132
194
260
322
386
448
516
578
642
704
770
832
896
958
36
66
98
128
162
192
224
254
290
320
352
382
416
446
478
508
546
576
608
638
672
702
734
764
800
830
862
892
926
956
988
1018
6
22
38
52
70
84
100
114
134
148
164
178
196
210
22...

input:

1
59652
14 46 1
16
488 816 1
492
2 6 1
4
0 2 1
2
180 36 1
182
4 2 2
0
2
0 2 1
2
2 0 1
0
0 2 1
2
986 448 3
956
958
972
600 938 3
594
596
598
2 154 3
34
64
128
4 0 1
0
1276 996 3
1152
1216
1246
180 176 1
184
10 50 1
14
0 2 1
2
68 250 1
72
192 176 3
222
252
254
248 954 1
246
196 100 1
200
0 4 2
4
6
4 0...

output:

16
492
4
2
182
2
2
0
2
956
594
128
0
1152
184
14
2
72
254
246
200
4
0
772
2
258
34
58
30
2
578
0
2
2
506
0
2
18
288
0
250
124
40
1326
812
4
0
114
2
4
4
142
22
0
56
2
0
30
2
2
464
2
2
0
0
0
34
22
48
36
888
0
200
224
350
46
0
234
2
138
4
4
4
24
118
2
2
16
970
310
16
48
0
190
2
0
988
24
0
2
32
220
162
...

result:

points 0.81967213110 max label = 1998

Test #66:

score: 61
Accepted
time: 48ms
memory: 3740kb

input:

0
10
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0

output:

2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2
2
0
2

input:

1
100000
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
0 2 1
2
0 2 1
2
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
2 0 1
0
0 2 1
2
2 0 1
0
2 0 1
0
2 0...

output:

0
0
2
2
2
2
2
2
0
0
2
2
2
2
2
2
0
0
2
0
0
2
0
0
2
0
2
2
0
2
0
0
0
2
0
0
0
2
2
0
0
2
0
2
0
0
0
0
2
2
0
2
2
2
0
0
2
0
2
0
2
2
2
0
2
0
2
2
2
0
2
0
0
2
0
2
0
0
2
2
0
0
2
2
2
2
2
2
2
2
2
2
2
0
2
2
0
2
0
0
2
0
2
0
0
2
2
0
2
0
2
0
0
2
2
0
2
0
0
2
0
0
0
2
2
0
2
2
0
2
0
0
0
2
2
0
2
0
2
2
2
0
0
2
2
0
2
2
2
0
...

result:

ok 

Test #67:

score: 61
Accepted
time: 38ms
memory: 3812kb

input:

0
10
3 1000000000
1 0
2 0
3 1000000000
0 1
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
0 1
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
0 1
0 2
3 1000000000
1 0
0 2

output:

3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4
3
0
2
4

input:

1
74942
2 0 1
0
2 0 1
0
0 4 2
2
4
0 4 2
2
4
2 0 1
0
2 0 1
0
4 0 1
0
2 0 1
0
2 0 1
0
2 4 1
0
2 0 1
0
2 4 1
0
4 0 1
0
0 2 2
2
4
0 2 2
2
4
4 0 1
0
0 2 2
2
4
0 4 2
2
4
4 2 1
0
0 2 2
2
4
4 0 1
0
4 2 1
0
2 4 1
0
2 4 1
0
4 2 1
0
0 4 2
2
4
0 4 2
2
4
4 2 1
0
4 2 1
0
2 4 1
0
4 2 1
0
4 0 1
0
4 2 1
0
4 0 1
0
0 ...

output:

0
0
4
4
0
0
0
0
0
0
0
0
0
2
2
0
2
4
0
2
0
0
0
0
0
4
4
0
0
0
0
0
0
0
2
0
0
4
0
2
2
0
2
0
4
0
0
4
4
0
0
0
0
2
4
0
0
2
2
2
2
0
0
4
0
2
4
0
0
4
0
4
0
4
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
4
4
0
0
0
4
4
0
0
0
0
0
0
0
0
4
4
4
0
0
4
0
2
4
0
0
0
4
0
2
2
2
0
0
0
0
0
0
0
0
2
0
4
0
2
0
0
0
0
0
2
0
4
2
0
0
0
0
0
0
4
...

result:

ok 

Test #68:

score: 61
Accepted
time: 36ms
memory: 3804kb

input:

0
10
4 1000000000
1 0
2 0
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
2 0
3 1
4 1000000000
0 1
2 0
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
1 0
2 0
1 3
4 1000000000
1 0
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
1 0
0 2
3 1
4 1000000000
1 0
2 0
3 1

output:

4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2
4
0
4
6
2

input:

1
66795
0 4 2
4
6
6 0 1
0
4 0 2
0
2
0 4 2
4
6
4 6 2
0
2
6 4 1
0
0 6 2
4
6
0 4 2
4
6
0 6 2
4
6
0 2 2
4
6
2 6 1
4
0 2 2
4
6
2 0 1
4
4 6 2
0
2
6 0 1
0
0 4 2
4
6
2 4 1
4
2 4 1
4
6 2 1
0
0 4 2
4
6
6 4 1
0
0 4 2
4
6
4 0 2
0
2
2 0 1
4
2 4 1
4
4 2 2
0
2
4 2 2
0
2
0 4 2
4
6
6 2 1
0
6 2 1
0
6 0 1
0
6 2 1
0
4 ...

output:

4
0
0
4
0
0
6
4
6
4
4
4
4
0
0
4
4
4
0
4
0
4
0
4
4
2
2
4
0
0
0
0
2
4
4
4
4
4
6
0
2
4
2
4
0
4
6
0
0
0
0
4
4
4
6
4
0
0
6
4
4
4
0
0
4
4
4
4
0
4
0
0
0
6
0
4
0
4
4
4
4
0
2
0
0
4
4
2
0
4
0
4
2
0
0
0
4
2
4
6
4
4
0
0
0
0
0
4
4
0
0
6
4
2
4
0
0
0
4
0
4
2
0
4
4
6
0
0
4
0
4
0
4
0
6
0
4
4
0
0
0
4
6
0
2
0
0
4
4
0
...

result:

ok 

Test #69:

score: 50
Acceptable Answer
time: 24ms
memory: 3816kb

input:

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

output:

1000
0
1022
1998
2
512
1024
1534
256
510
766
1020
1278
1532
1788
1996
4
130
258
384
514
640
768
894
1026
1152
1280
1406
1536
1662
1790
1916
66
128
192
254
320
382
446
508
576
638
702
764
830
892
956
1018
1088
1150
1214
1276
1342
1404
1468
1530
1598
1660
1724
1786
1852
1914
1964
1994
6
36
68
98
132
1...

input:

1
50098
1438 848 3
1452
1466
1468
1082 1670 1
1080
1504 552 1
1502
376 1520 1
374
334 1474 1
330
1940 1418 3
1942
1944
1946
1132 1816 1
1128
1604 714 1
1602
144 528 1
140
4 1202 3
66
128
256
1144 730 1
1142
852 924 1
848
484 1010 1
480
1278 1514 3
1024
1026
1152
1708 1310 3
1694
1696
1702
266 1108 1...

output:

1468
1080
1502
374
330
1946
1128
1602
140
256
1142
848
480
1024
1694
262
896
126
1016
38
480
942
1664
210
1454
1478
1992
1886
1244
1118
1424
658
1024
1438
1246
82
414
546
864
576
260
1296
538
1152
1996
134
798
1502
1980
606
1728
1320
1820
1600
640
1708
1986
1460
290
226
1112
848
1152
686
1742
282
19...

result:

points 0.81967213110 max label = 1998

Test #70:

score: 61
Accepted
time: 36ms
memory: 3788kb

input:

0
10
4 1000000000
1 0
0 3
0 2
4 1000000000
2 0
3 1
3 2
4 1000000000
1 2
2 3
2 0
4 1000000000
2 3
0 3
1 2
4 1000000000
2 0
1 2
3 2
4 1000000000
1 0
2 3
0 3
4 1000000000
3 2
2 1
3 0
4 1000000000
2 3
1 3
0 3
4 1000000000
0 2
0 1
3 2
4 1000000000
0 2
1 2
3 2

output:

4
0
2
6
4
4
0
4
6
2
4
0
2
6
4
4
0
4
2
6
4
0
2
6
4
4
0
2
4
6
4
0
4
2
6
4
0
4
2
6
4
0
6
4
2
4
0
2
6
4

input:

1
66444
2 6 2
4
6
6 4 2
0
2
4 2 1
6
0 4 1
6
6 0 3
0
2
4
2 4 2
4
6
4 6 1
6
4 0 1
2
4 2 1
2
6 2 3
0
2
4
0 2 1
6
0 6 2
4
6
4 2 1
0
4 2 1
2
4 2 1
0
4 2 2
0
2
6 2 1
0
0 6 1
6
4 2 2
0
2
4 0 1
6
0 2 2
2
6
0 6 1
6
0 6 1
6
6 2 3
0
2
4
4 2 1
6
4 6 1
6
0 2 1
6
4 0 1
2
2 4 1
0
0 4 1
6
4 0 1
6
6 2 1
0
0 6 1
6
6 ...

output:

6
2
6
6
0
4
6
2
2
2
6
6
0
2
0
2
0
6
2
6
2
6
6
2
6
6
6
2
0
6
6
0
6
0
4
0
2
2
2
6
4
6
2
0
6
0
6
6
6
0
6
6
6
4
2
6
6
6
0
6
6
6
2
6
6
6
6
6
4
6
2
6
6
2
6
6
2
0
6
6
6
6
6
2
4
0
0
6
6
6
6
2
2
0
0
2
6
0
6
6
2
6
2
6
6
6
2
6
2
2
4
6
6
6
6
6
6
2
0
2
6
0
6
2
4
0
6
0
6
0
6
6
0
4
2
2
0
0
2
6
6
4
6
0
0
6
6
6
6
2
...

result:

ok 

Test #71:

score: 50
Acceptable Answer
time: 34ms
memory: 3792kb

input:

0
10
1000 1000000000
496 136
370 247
359 252
743 278
85 499
522 547
6 780
330 416
815 429
942 361
275 290
113 753
471 15
720 896
514 482
631 513
981 760
525 601
600 637
263 572
292 229
556 489
46 504
199 953
354 801
91 181
742 119
495 647
940 396
272 230
291 130
763 639
467 709
945 171
96 610
726 96...

output:

1000
0
752
1774
476
870
790
1886
314
8
1872
912
554
414
792
1574
80
1672
1894
1806
1784
638
1224
340
1518
200
1288
702
1208
1496
510
276
1322
1836
876
812
746
1912
1900
1366
1568
1156
1164
1492
1504
1080
508
124
480
1260
6
948
84
286
1228
1642
514
484
1740
260
882
1858
1062
448
1440
1794
1086
1738
1...

input:

1
50431
1158 228 2
1496
1498
670 926 2
710
712
1868 1118 1
42
528 1298 2
128
130
1200 1806 1
1874
1540 1572 2
1310
1312
1612 1496 2
1590
1592
2 1344 2
850
852
1202 338 2
1216
1218
1850 398 2
1870
1872
48 1160 2
762
764
1412 1096 2
1438
1440
1514 1634 2
1140
1142
986 1236 2
1822
1824
1480 1936 1
1874...

output:

1498
712
42
128
1874
1310
1590
852
1218
1872
764
1440
1140
1822
1874
1874
1174
1388
1484
690
266
1874
534
1874
1510
700
594
1288
778
1856
1672
1848
800
1228
1394
1848
2
718
1914
1300
1244
1200
64
676
1284
110
1378
938
378
104
1922
876
1392
1312
326
1266
254
256
1660
1098
2
630
42
958
1642
1638
832
1...

result:

points 0.81967213110 max label = 1998

Test #72:

score: 50
Acceptable Answer
time: 34ms
memory: 3824kb

input:

0
10
1000 1000000000
812 935
596 175
369 401
625 709
470 249
715 901
665 497
296 591
732 817
698 374
352 216
787 19
831 844
896 420
700 895
533 363
872 36
58 930
48 897
321 154
391 351
993 950
392 990
585 323
565 739
818 926
103 89
912 432
706 259
359 608
218 33
146 201
16 769
230 885
945 377
41 131...

output:

1000
0
484
48
998
1126
874
350
22
638
922
1238
188
654
1500
848
1376
240
454
626
1676
510
124
570
516
1888
1184
1262
506
702
800
1372
1706
1650
560
1614
910
1870
1408
226
900
1044
1122
1042
776
960
68
1082
452
940
806
1522
996
1678
50
1530
332
1068
530
1626
1034
1064
164
1056
1652
494
328
968
682
19...

input:

1
51725
1634 882 2
1770
1772
1668 122 2
474
476
752 800 2
772
774
1622 718 1
1624
28 590 1
1998
394 126 2
1012
1014
596 1754 2
600
602
970 952 2
714
716
1190 582 2
1156
1158
1536 44 2
1494
1496
22 1582 1
1998
964 1388 2
1178
1180
586 1228 2
820
822
1960 976 1
1998
816 1126 2
1326
1328
1590 1826 2
14...

output:

1772
474
774
1624
1998
1014
602
716
1156
1494
1998
1180
822
1998
1326
1492
1014
1988
1016
1416
1104
1944
1248
1998
1998
1440
564
1480
1998
300
66
1116
1504
1694
712
990
256
944
1200
1628
1494
840
1618
1920
1906
1998
824
1704
1778
1998
40
32
1512
572
1084
562
1994
742
1896
410
286
1296
1010
546
1930
...

result:

points 0.81967213110 max label = 1998

Test #73:

score: 50
Acceptable Answer
time: 34ms
memory: 3876kb

input:

0
1
1000 1000000000
584 325
759 912
536 411
310 503
386 643
125 683
587 211
331 908
866 671
790 38
346 846
813 567
297 574
42 196
443 23
467 767
797 820
134 746
465 907
815 88
161 453
467 788
793 875
656 320
847 290
725 194
372 594
909 185
120 5
845 895
292 421
56 804
634 565
41 22
144 402
616 552
1...

output:

1000
0
300
1268
722
716
604
456
652
972
998
612
442
634
710
264
1714
1876
174
1490
154
1300
1814
1350
34
962
1042
1056
1960
698
766
240
540
1398
1074
600
1710
658
768
880
642
1544
1302
640
866
192
1904
1984
388
474
790
1712
592
1998
332
256
812
1018
1212
1910
936
438
1314
124
1426
632
1674
516
1234
...

input:

1
49651
1774 1236 2
1762
1764
1708 870 1
1706
516 880 2
492
494
850 1338 1
852
1582 558 1
1580
1264 1126 2
1260
1262
860 1894 2
840
842
526 1952 2
482
484
164 578 2
190
192
930 100 2
910
912
812 724 2
744
746
44 140 2
38
40
1026 1874 2
1064
1066
548 1090 2
608
610
254 316 2
248
250
1272 1964 2
1252
...

output:

1762
1706
492
852
1580
1260
840
482
192
910
744
38
1066
610
248
1252
1922
1626
1378
18
1794
1342
276
964
18
1896
1758
520
640
916
364
624
300
120
598
746
1676
1830
1296
1236
1548
18
792
750
250
288
1660
1648
708
18
1336
1702
1734
228
1886
1694
156
1152
4
1400
1512
336
136
1312
1092
1584
1450
1690
10...

result:

points 0.81967213110 max label = 1998

Test #74:

score: 61
Accepted
time: 12ms
memory: 3816kb

input:

0
10
96 1000000000
95 4
95 32
13 95
49 95
76 95
95 73
95 10
95 42
63 95
17 95
95 52
95 84
95 11
95 2
95 14
95 85
91 95
57 95
24 95
46 95
95 23
77 95
54 95
95 40
33 95
34 95
95 26
95 51
95 89
59 95
82 95
95 28
95 25
95 81
3 95
95 45
95 29
71 95
95 94
95 21
95 22
8 95
92 95
15 95
95 55
56 95
6 95
95 7...

output:

96
0
150
28
70
2
182
94
156
84
134
14
26
122
6
30
88
178
20
164
132
142
80
82
42
38
66
54
152
64
74
184
124
4
50
52
98
162
104
110
140
48
170
16
176
130
72
40
188
148
8
114
56
22
118
46
90
92
36
158
60
116
126
108
18
112
166
186
102
174
154
180
76
136
12
96
168
10
44
144
128
160
68
62
120
24
32
100
...

input:

1
4308
6 106 1
190
94 178 1
190
190 96 95
0
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
102
104
106
108
110
112
114
116
118
120
122
124
126
128
130
132
134
136
138
140
142
144
146
148
150
152
154
1...

output:

190
190
96
0
190
74
190
190
0
190
190
190
190
190
190
56
0
190
0
190
190
0
190
190
190
190
0
190
0
190
190
190
0
190
190
190
190
190
190
190
178
190
190
0
100
190
190
190
190
190
164
0
76
164
104
190
138
100
190
190
0
190
0
190
190
190
190
190
190
0
190
84
102
34
120
0
190
190
114
190
0
190
0
190
19...

result:

ok 

Test #75:

score: 50
Acceptable Answer
time: 12ms
memory: 3796kb

input:

0
10
541 1000000000
0 527
0 72
0 176
0 246
0 323
190 0
74 0
0 110
518 0
259 0
0 293
0 51
0 59
149 0
0 232
327 0
0 136
0 503
0 142
0 248
64 0
0 398
379 0
0 156
0 265
406 0
84 0
0 49
522 0
0 413
0 513
429 0
170 0
163 0
319 0
233 0
490 0
0 187
0 270
273 0
0 17
471 0
437 0
0 154
276 0
63 0
378 0
0 38
42...

output:

541
0
980
500
108
124
624
642
738
126
114
474
774
502
998
844
732
762
82
932
544
196
968
166
284
406
150
952
338
248
1018
498
1072
322
658
870
470
770
424
96
364
722
156
570
366
340
710
876
852
572
56
356
24
434
896
846
294
534
688
292
26
100
226
898
92
42
788
1050
464
978
950
620
672
4
348
14
800
6...

input:

1
6214
970 942 1
0
868 434 1
1080
116 1006 1
1080
616 664 1
1080
972 604 1
0
622 966 1
0
90 130 1
0
708 186 1
0
320 60 1
0
842 280 1
0
224 424 1
0
344 800 1
1080
768 706 1
0
720 508 1
0
804 476 1
0
878 598 1
0
324 852 1
1080
532 628 1
0
474 262 1
1080
732 442 1
1080
1000 0 1
0
870 68 1
1080
528 200 ...

output:

0
1080
1080
1080
0
0
0
0
0
0
0
1080
0
0
0
0
1080
0
1080
1080
0
1080
0
1080
0
1080
0
708
0
0
0
0
0
1080
0
0
1080
1080
1080
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1080
0
0
1080
0
0
0
1080
1080
308
0
0
1080
0
1080
1080
0
0
0
1080
1080
1080
0
0
0
0
0
1080
0
0
0
0
0
0
0
0
1080
1080
1080
0
0
1080
0
1080
0
0
...

result:

points 0.81967213110 max label = 1080

Test #76:

score: 50
Acceptable Answer
time: 14ms
memory: 3748kb

input:

0
10
1000 1000000000
999 444
999 412
999 312
999 906
999 990
999 616
999 554
718 999
999 228
494 999
999 726
999 728
55 999
370 999
190 999
999 230
999 64
944 999
358 999
999 189
65 999
500 999
457 999
480 999
414 999
999 820
999 29
331 999
999 693
239 999
132 999
999 918
527 999
999 534
145 999
999...

output:

1000
0
1630
312
778
130
884
1364
1912
1792
194
876
228
1086
186
1914
462
716
1624
1286
98
726
982
1392
1538
1262
934
1868
410
816
54
1750
960
248
636
340
1338
1324
502
1888
1810
88
532
946
290
1442
550
992
1076
1886
1142
192
794
1032
1528
836
26
1974
270
528
1908
1342
1688
1978
264
34
42
1606
1146
6...

input:

1
10180
36 1602 1
0
8 850 1
0
1236 42 1
0
406 572 1
1998
942 1724 1
0
1064 1566 1
0
266 1816 1
1998
426 1218 1
0
1936 1742 1
0
1104 1146 1
0
1956 1494 1
1998
1718 710 1
1998
1336 1378 1
1998
1566 794 1
0
300 644 1
1998
1356 1026 1
0
576 1828 1
0
574 1580 1
1998
100 202 1
0
794 52 1
0
580 1752 1
0
15...

output:

0
0
0
1998
0
0
1998
0
0
0
1998
1998
1998
0
1998
0
0
1998
0
0
0
0
0
1998
0
1998
0
1998
0
1998
0
1998
0
1998
0
1998
1998
0
1998
1998
1998
1998
1998
0
1998
1998
1998
0
0
0
1998
0
1998
1998
0
0
0
1998
1998
0
0
0
1998
1998
1998
0
0
0
0
0
1998
0
0
0
0
0
1998
1998
1998
1998
0
0
1998
0
0
0
1998
1998
1998
0
...

result:

points 0.81967213110 max label = 1998

Test #77:

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

input:

0
10
7 1000000000
1 6
0 6
3 6
5 6
4 6
2 6
7 1000000000
5 3
0 3
6 3
4 3
1 3
2 3
7 1000000000
1 5
2 5
4 5
3 5
0 5
6 1
7 1000000000
2 5
4 5
1 5
0 5
6 5
3 2
7 1000000000
0 4
1 4
6 4
2 4
5 4
3 0
7 1000000000
5 0
4 0
6 0
3 0
1 5
2 5
7 1000000000
1 5
4 5
6 5
3 5
2 1
0 1
7 1000000000
5 1
3 1
6 1
0 1
4 5
2 5...

output:

7
0
2
10
4
8
6
12
7
0
8
10
12
6
2
4
7
0
2
6
10
8
12
4
7
0
8
2
4
6
12
10
7
0
2
6
12
10
8
4
7
0
2
4
12
8
6
10
7
0
12
10
8
4
2
6
7
0
12
6
8
4
2
10
7
0
6
8
2
10
4
12
7
0
10
4
2
12
8
6

input:

1
420
6 12 3
0
2
4
10 2 1
12
2 8 2
4
12
8 10 1
0
8 0 1
12
10 8 1
12
10 0 1
12
4 0 1
6
6 8 1
12
10 8 5
0
2
4
6
8
8 6 1
12
6 12 1
12
12 6 5
0
2
6
8
10
4 6 1
2
8 10 1
12
2 10 1
12
8 0 1
12
6 0 1
10
0 12 1
12
0 4 1
12
10 8 1
12
6 8 2
2
4
0 4 1
12
12 4 5
0
2
6
8
10
2 6 1
12
4 10 1
10
6 0 1
12
12 2 1
0
2 ...

output:

0
12
12
0
12
12
12
6
12
8
12
12
6
2
12
12
12
10
12
12
12
2
12
2
12
10
12
0
12
0
2
12
12
2
10
10
12
2
0
2
12
8
2
2
12
12
6
12
12
2
2
2
0
12
12
10
8
12
12
10
12
10
12
0
10
2
2
0
2
12
10
12
2
12
6
0
12
12
10
0
6
2
2
12
12
12
12
12
12
6
10
10
12
2
8
4
2
2
12
12
12
6
12
0
2
12
10
12
0
12
2
12
2
10
12
12
...

result:

ok 

Test #78:

score: 61
Accepted
time: 0ms
memory: 3788kb

input:

0
10
7 1000000000
3 6
1 6
0 6
5 6
2 3
4 2
7 1000000000
4 6
0 6
5 6
3 6
1 4
2 1
7 1000000000
5 1
4 1
6 1
2 5
0 5
3 4
7 1000000000
0 5
6 5
2 5
1 0
4 0
3 6
7 1000000000
2 4
0 4
3 4
1 2
5 2
6 0
7 1000000000
2 5
4 5
3 5
0 2
1 2
6 4
7 1000000000
1 5
4 5
6 5
0 1
3 4
2 6
7 1000000000
3 0
4 0
2 0
5 3
6 4
1 5...

output:

7
0
8
6
2
4
10
12
7
0
6
4
10
2
8
12
7
0
2
10
4
6
12
8
7
0
10
6
4
12
8
2
7
0
4
2
8
10
6
12
7
0
10
12
8
6
2
4
7
0
12
8
4
6
2
10
7
0
4
12
6
10
2
8
7
0
6
12
2
10
4
8
7
0
10
8
4
12
6
2

input:

1
420
12 0 3
0
2
10
12 0 1
0
12 8 3
0
2
10
6 8 2
2
4
8 0 1
2
4 0 1
6
12 2 1
0
4 2 1
6
10 6 1
12
10 6 3
0
2
8
6 2 1
8
2 8 2
4
8
8 2 3
0
2
6
6 8 1
4
10 12 2
0
8
2 4 2
6
12
6 8 2
2
4
4 2 1
2
0 12 1
12
2 8 2
4
6
10 8 1
12
8 10 2
2
4
0 4 1
12
2 4 3
6
8
12
2 10 2
6
12
8 10 1
10
10 8 1
12
12 0 1
0
12 6 3
0...

output:

0
0
2
2
2
6
0
6
12
2
8
8
2
4
0
6
2
2
12
6
12
2
12
6
12
10
12
0
2
0
2
0
2
2
6
8
4
0
2
0
12
10
2
4
8
6
6
12
0
12
2
2
12
2
4
10
10
12
12
10
8
2
2
2
12
10
2
2
4
8
2
12
2
0
12
12
2
8
10
2
12
2
2
0
0
12
0
8
4
12
2
2
2
2
8
8
6
12
0
2
12
12
12
12
12
0
10
12
0
12
4
12
2
12
12
4
10
10
10
2
12
6
10
12
0
6
8
0
...

result:

ok 

Test #79:

score: 61
Accepted
time: 0ms
memory: 4044kb

input:

0
10
7 1000000000
2 5
0 5
1 5
6 2
3 6
4 3
7 1000000000
6 3
4 3
5 3
1 6
0 1
2 0
7 1000000000
0 4
1 4
3 0
6 1
5 3
2 6
6 1000000000
3 0
1 0
2 0
4 0
5 0
6 1000000000
4 1
0 1
3 1
2 1
5 1
6 1000000000
0 5
1 5
3 5
2 5
4 0
6 1000000000
0 1
5 1
3 1
2 1
4 0
6 1000000000
5 1
0 1
4 1
3 1
2 5
6 1000000000
3 1
2 ...

output:

7
0
10
2
4
6
12
8
7
0
10
12
8
4
6
2
7
0
2
4
12
8
10
6
6
0
4
6
2
8
10
6
0
10
6
4
2
8
6
0
2
6
4
10
8
6
0
8
6
4
10
2
6
0
10
4
8
6
2
6
0
2
4
10
8
6
6
0
2
6
8
4
10

input:

1
336
8 6 4
0
2
4
6
10 0 5
0
2
4
6
8
0 12 2
8
12
0 6 2
8
10
12 10 2
0
10
4 2 1
2
4 6 2
0
2
10 2 4
0
2
6
8
8 4 2
2
4
4 2 1
10
8 0 1
0
4 6 1
0
0 4 5
2
4
6
8
10
2 8 2
6
8
0 10 3
4
8
10
2 6 2
8
12
4 0 2
6
8
0 4 2
8
10
4 8 1
8
10 4 1
0
6 12 2
2
4
6 8 1
8
10 4 1
12
8 4 2
0
2
2 10 2
8
10
8 0 4
0
2
4
6
8 0 ...

output:

6
0
12
8
10
2
0
2
4
10
0
0
4
8
10
8
8
8
8
0
2
8
12
2
10
0
2
8
8
10
8
10
8
2
10
0
10
10
10
2
8
8
2
8
8
0
10
2
0
10
8
8
0
8
6
6
2
2
12
2
0
10
6
8
8
0
10
10
12
0
8
12
2
0
0
0
10
0
10
0
8
10
0
8
4
8
12
0
0
0
8
8
8
8
0
6
10
4
2
10
4
0
12
8
2
8
0
2
8
2
10
12
2
2
8
6
2
10
8
10
8
8
2
2
8
6
10
10
0
10
10
8
1...

result:

ok 

Test #80:

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

input:

0
10
6 1000000000
5 0
4 0
1 0
3 5
2 4
6 1000000000
1 4
3 4
5 4
0 1
2 0
6 1000000000
2 3
4 3
1 3
0 2
5 0
6 1000000000
1 2
4 2
0 1
3 4
5 0
5 1000000000
1 0
3 0
4 0
2 0
5 1000000000
0 3
4 3
2 3
1 3
5 1000000000
1 2
0 2
4 2
3 1
5 1000000000
1 3
2 3
4 3
0 1
5 1000000000
2 3
4 3
1 3
0 2
5 1000000000
4 1
0...

output:

6
0
10
6
2
8
4
6
0
8
10
4
2
6
6
0
6
8
2
4
10
6
0
8
2
4
6
10
5
0
2
8
4
6
5
0
6
4
8
2
5
0
2
8
4
6
5
0
8
4
2
6
5
0
6
8
2
4
5
0
6
4
8
2

input:

1
240
0 6 1
8
6 0 1
8
2 0 2
6
8
2 6 2
4
6
0 8 2
8
10
8 4 1
0
8 4 3
0
2
6
6 4 1
0
6 10 1
8
6 8 1
8
0 4 1
8
8 4 1
0
2 8 1
0
8 6 2
0
2
10 6 1
0
8 4 2
0
6
2 6 3
4
6
8
6 8 1
2
0 10 2
8
10
6 8 1
8
4 8 1
6
8 6 1
0
10 4 1
0
10 0 1
0
0 8 2
8
10
8 6 2
0
2
6 4 1
8
8 6 2
0
2
2 6 2
6
8
6 2 1
8
6 8 1
8
2 0 2
4
8
...

output:

8
8
8
6
8
0
2
0
8
8
8
0
0
2
0
0
6
2
10
8
6
0
0
0
8
2
8
2
6
8
8
8
8
6
2
2
8
0
2
0
0
8
0
8
0
8
8
0
0
2
2
8
0
8
2
4
0
2
0
0
8
2
0
4
0
2
8
6
0
8
8
6
2
8
0
0
2
0
8
8
6
4
8
4
2
8
8
4
2
2
8
2
8
6
0
2
8
2
10
2
8
2
0
0
6
2
2
6
0
6
8
0
4
0
2
6
2
4
0
8
2
8
0
0
8
0
2
0
8
0
2
2
8
8
8
8
6
6
8
2
8
0
6
0
0
2
6
4
8
...

result:

ok 

Test #81:

score: 61
Accepted
time: 0ms
memory: 3792kb

input:

0
6
4 1000000000
2 3
0 3
1 3
4 1000000000
0 3
2 3
1 3
4 1000000000
2 0
1 0
3 2
3 1000000000
0 2
1 2
3 1000000000
1 0
2 0
2 1000000000
1 0

output:

4
0
4
2
6
4
0
4
2
6
4
0
6
4
2
3
0
2
4
3
0
2
4
2
0
2

input:

1
50
4 6 1
6
2 4 1
0
6 0 1
0
2 0 1
0
4 2 1
6
0 4 2
2
4
4 2 1
0
2 0 1
6
4 6 2
0
2
0 2 2
2
4
6 4 3
0
2
4
0 6 1
6
0 6 1
6
2 6 1
6
2 6 1
6
4 0 1
6
6 2 1
0
4 0 2
0
2
0 2 1
2
4 0 2
0
2
0 4 1
6
0 6 2
4
6
2 0 1
0
4 0 1
0
2 0 1
4
6 0 3
0
2
4
0 2 2
4
6
2 4 1
6
6 0 3
0
2
4
0 2 1
6
6 2 3
0
2
4
4 2 2
0
2
2 4 1
4...

output:

6
0
0
0
6
4
0
6
0
2
4
6
6
6
6
6
0
0
2
0
6
6
0
0
4
0
4
6
0
6
2
2
4
4
6
6
6
6
6
6
6
4
4
2
0
4
4
4
4
2

result:

ok 

Test #82:

score: 61
Accepted
time: 34ms
memory: 3744kb

input:

0
10
8 1000000000
2 1
4 7
6 0
7 3
1 5
6 5
4 0
8 1000000000
3 2
3 4
4 5
7 6
5 6
0 1
2 1
8 1000000000
0 6
4 7
3 6
3 1
2 5
5 1
4 0
8 1000000000
0 1
2 0
1 3
1 4
2 5
2 6
3 7
8 1000000000
5 1
5 0
6 5
5 7
3 5
5 2
4 5
8 1000000000
0 6
0 3
0 4
7 0
2 0
1 0
5 0
8 1000000000
7 0
1 2
1 5
6 0
4 3
6 3
5 7
8 100000...

output:

8
0
6
4
12
14
2
8
10
8
0
14
2
12
4
10
6
8
8
0
8
6
2
14
4
10
12
8
0
8
14
2
6
10
12
4
8
0
2
10
8
12
14
4
6
8
0
12
10
4
6
14
2
8
8
0
6
4
10
12
2
14
8
8
0
12
14
8
4
2
10
6
8
0
4
14
6
2
10
8
12
8
0
6
4
14
8
12
10
2

input:

1
57266
6 2 1
8
12 10 2
2
4
6 2 1
4
4 8 1
14
10 0 1
14
2 6 2
6
8
0 4 2
8
14
12 6 1
14
0 12 1
14
8 0 2
2
4
14 6 2
0
12
14 2 3
0
10
12
12 4 1
10
14 4 3
0
10
12
2 0 2
8
10
4 10 2
6
8
0 12 1
14
6 2 2
8
10
0 10 2
8
14
4 10 2
6
8
10 8 1
0
2 0 2
8
10
2 0 1
14
4 12 1
6
0 4 2
12
14
0 14 2
8
14
14 12 2
0
10
1...

output:

8
4
4
14
14
6
8
14
14
2
0
0
10
0
10
8
14
10
14
8
0
10
14
6
12
14
10
0
0
0
14
4
0
0
0
0
12
0
0
0
12
6
4
2
10
4
0
0
10
12
4
4
0
6
14
0
0
2
2
4
4
4
12
14
14
4
10
0
6
8
14
12
2
8
0
10
10
6
14
10
14
2
14
6
14
2
8
0
12
12
2
8
0
12
14
14
4
0
12
12
14
8
14
0
8
2
4
2
0
8
6
0
14
0
14
6
14
12
6
0
10
0
14
0
10
...

result:

ok 

Test #83:

score: 61
Accepted
time: 34ms
memory: 3796kb

input:

0
10
8 1000000000
4 0
3 4
4 6
6 2
1 4
4 5
7 4
8 1000000000
1 3
3 5
3 7
2 3
0 3
3 6
4 2
8 1000000000
0 4
3 2
2 5
7 2
0 2
2 6
3 1
8 1000000000
0 6
6 1
3 1
7 3
7 4
4 2
0 5
8 1000000000
0 4
3 4
6 5
0 2
7 0
5 1
6 2
8 1000000000
2 4
5 2
4 0
6 1
7 6
5 3
0 1
8 1000000000
5 3
0 1
0 5
2 0
7 6
6 5
4 2
8 100000...

output:

8
0
8
6
2
14
10
4
12
8
0
2
8
14
10
4
12
6
8
0
6
14
4
2
8
12
10
8
0
2
6
10
8
14
12
4
8
0
8
12
2
4
10
6
14
8
0
14
2
4
8
6
10
12
8
0
2
14
4
12
10
6
8
8
0
6
14
12
8
4
10
2
8
0
10
8
2
14
6
4
12
8
0
2
14
12
10
8
6
4

input:

1
57297
2 4 1
14
10 14 1
14
8 6 2
12
14
12 0 2
8
10
0 6 3
2
10
14
12 8 2
8
10
2 0 1
14
8 6 2
12
14
6 4 2
10
12
2 14 2
6
8
8 12 1
14
4 10 1
10
6 10 2
0
2
0 14 3
4
12
14
2 14 4
4
10
12
14
4 2 1
14
10 2 2
12
14
6 2 2
8
10
6 10 1
14
8 0 2
0
2
6 2 1
8
0 4 3
2
10
14
4 14 1
2
0 2 1
14
0 8 2
6
14
6 14 2
8
1...

output:

14
14
14
8
10
8
14
14
12
8
14
10
0
14
14
14
14
10
14
0
8
10
2
14
14
10
6
14
8
0
14
14
2
14
14
6
0
8
12
2
0
8
14
0
14
2
12
14
14
10
8
10
2
14
2
14
14
14
10
14
14
14
4
4
14
6
0
14
14
14
14
14
12
4
14
4
14
14
4
14
14
2
2
8
4
14
2
14
12
10
14
14
14
10
8
0
14
2
14
12
14
0
0
14
12
0
14
6
14
6
10
14
2
14
1...

result:

ok 

Test #84:

score: 61
Accepted
time: 34ms
memory: 3788kb

input:

0
10
8 1000000000
3 7
0 3
3 6
3 2
4 3
3 5
3 1
8 1000000000
2 1
6 3
3 0
0 2
1 4
5 7
3 5
8 1000000000
6 2
6 7
1 6
0 7
0 4
5 6
1 3
8 1000000000
5 3
6 1
0 2
0 4
7 3
6 4
2 5
8 1000000000
2 0
4 0
4 7
3 6
3 5
1 6
3 2
8 1000000000
3 2
2 6
3 5
1 3
3 4
1 0
7 3
8 1000000000
4 1
2 1
0 6
7 4
3 7
6 3
2 5
8 100000...

output:

8
0
12
6
14
8
10
4
2
8
0
10
14
8
12
4
2
6
8
0
8
4
6
14
10
2
12
8
0
12
8
6
14
2
10
4
8
0
4
10
2
14
8
6
12
8
0
14
6
2
10
8
4
12
8
0
10
6
2
4
8
14
12
8
0
14
4
2
12
10
8
6
8
0
8
14
4
10
6
2
12
8
0
14
6
8
4
10
2
12

input:

1
57195
4 12 1
14
0 10 1
14
2 4 4
4
8
10
12
0 10 1
14
12 4 1
14
2 0 1
14
0 10 1
14
4 2 1
6
8 2 2
2
6
0 14 1
14
12 4 1
14
8 12 1
14
8 14 1
2
2 8 1
14
4 2 1
14
8 2 1
10
10 0 2
12
14
4 12 1
6
12 4 1
14
2 14 1
8
6 4 2
2
4
2 0 1
14
10 14 1
2
14 8 2
0
2
4 8 1
6
0 4 2
8
14
14 10 2
0
10
8 14 1
6
10 2 2
0
2
...

output:

14
14
4
14
14
14
14
6
2
14
14
14
2
14
14
10
14
6
14
8
4
14
2
2
6
8
10
6
2
4
2
2
6
12
2
2
2
2
2
8
2
2
6
6
4
4
2
0
14
2
4
14
2
2
6
12
10
14
4
10
10
0
10
6
6
12
14
8
10
14
4
10
12
14
2
4
2
14
8
4
14
14
14
12
14
10
4
2
14
14
8
14
14
2
8
4
14
10
8
2
2
14
14
2
6
12
2
6
2
8
10
10
14
8
2
4
14
12
10
2
8
2
10...

result:

ok 

Test #85:

score: 61
Accepted
time: 34ms
memory: 3820kb

input:

0
10
8 1000000000
3 7
0 3
3 6
3 2
4 3
3 5
3 1
8 1000000000
2 1
6 3
3 0
0 2
1 4
5 7
3 5
8 1000000000
6 2
6 7
1 6
0 7
0 4
5 6
1 3
8 1000000000
5 3
6 1
0 2
0 4
7 3
6 4
2 5
8 1000000000
2 0
4 0
4 7
3 6
3 5
1 6
3 2
8 1000000000
3 2
2 6
3 5
1 3
3 4
1 0
7 3
8 1000000000
4 1
2 1
0 6
7 4
3 7
6 3
2 5
8 100000...

output:

8
0
12
6
14
8
10
4
2
8
0
10
14
8
12
4
2
6
8
0
8
4
6
14
10
2
12
8
0
12
8
6
14
2
10
4
8
0
4
10
2
14
8
6
12
8
0
14
6
2
10
8
4
12
8
0
10
6
2
4
8
14
12
8
0
14
4
2
12
10
8
6
8
0
8
14
4
10
6
2
12
8
0
14
6
8
4
10
2
12

input:

1
57195
4 12 1
14
0 10 1
14
2 4 4
4
8
10
12
0 10 1
14
12 4 1
14
2 0 1
14
0 10 1
14
4 2 1
6
8 2 2
2
6
0 14 1
14
12 4 1
14
8 12 1
14
8 14 1
2
2 8 1
14
4 2 1
14
8 2 1
10
10 0 2
12
14
4 12 1
6
12 4 1
14
2 14 1
8
6 4 2
2
4
2 0 1
14
10 14 1
2
14 8 2
0
2
4 8 1
6
0 4 2
8
14
14 10 2
0
10
8 14 1
6
10 2 2
0
2
...

output:

14
14
4
14
14
14
14
6
2
14
14
14
2
14
14
10
14
6
14
8
4
14
2
2
6
8
10
6
2
4
2
2
6
12
2
2
2
2
2
8
2
2
6
6
4
4
2
0
14
2
4
14
2
2
6
12
10
14
4
10
10
0
10
6
6
12
14
8
10
14
4
10
12
14
2
4
2
14
8
4
14
14
14
12
14
10
4
2
14
14
8
14
14
2
8
4
14
10
8
2
2
14
14
2
6
12
2
6
2
8
10
10
14
8
2
4
14
12
10
2
8
2
10...

result:

ok 

Test #86:

score: 61
Accepted
time: 34ms
memory: 3792kb

input:

0
10
8 1000000000
3 7
0 3
3 6
3 2
4 3
3 5
3 1
8 1000000000
2 1
6 3
3 0
0 2
1 4
5 7
3 5
8 1000000000
6 2
6 7
1 6
0 7
0 4
5 6
1 3
8 1000000000
5 3
6 1
0 2
0 4
7 3
6 4
2 5
8 1000000000
2 0
4 0
4 7
3 6
3 5
1 6
3 2
8 1000000000
3 2
2 6
3 5
1 3
3 4
1 0
7 3
8 1000000000
4 1
2 1
0 6
7 4
3 7
6 3
2 5
8 100000...

output:

8
0
12
6
14
8
10
4
2
8
0
10
14
8
12
4
2
6
8
0
8
4
6
14
10
2
12
8
0
12
8
6
14
2
10
4
8
0
4
10
2
14
8
6
12
8
0
14
6
2
10
8
4
12
8
0
10
6
2
4
8
14
12
8
0
14
4
2
12
10
8
6
8
0
8
14
4
10
6
2
12
8
0
14
6
8
4
10
2
12

input:

1
57195
4 12 1
14
0 10 1
14
2 4 4
4
8
10
12
0 10 1
14
12 4 1
14
2 0 1
14
0 10 1
14
4 2 1
6
8 2 2
2
6
0 14 1
14
12 4 1
14
8 12 1
14
8 14 1
2
2 8 1
14
4 2 1
14
8 2 1
10
10 0 2
12
14
4 12 1
6
12 4 1
14
2 14 1
8
6 4 2
2
4
2 0 1
14
10 14 1
2
14 8 2
0
2
4 8 1
6
0 4 2
8
14
14 10 2
0
10
8 14 1
6
10 2 2
0
2
...

output:

14
14
4
14
14
14
14
6
2
14
14
14
2
14
14
10
14
6
14
8
4
14
2
2
6
8
10
6
2
4
2
2
6
12
2
2
2
2
2
8
2
2
6
6
4
4
2
0
14
2
4
14
2
2
6
12
10
14
4
10
10
0
10
6
6
12
14
8
10
14
4
10
12
14
2
4
2
14
8
4
14
14
14
12
14
10
4
2
14
14
8
14
14
2
8
4
14
10
8
2
2
14
14
2
6
12
2
6
2
8
10
10
14
8
2
4
14
12
10
2
8
2
10...

result:

ok 

Test #87:

score: 50
Acceptable Answer
time: 24ms
memory: 4084kb

input:

0
10
978 1000000000
201 44
44 320
320 907
907 278
278 477
477 755
755 461
461 235
235 83
83 919
919 38
38 443
443 629
629 42
42 13
13 208
208 898
898 205
205 924
924 887
887 170
170 326
326 255
255 684
684 301
301 909
909 161
161 621
621 130
130 587
587 530
530 334
334 700
700 771
771 722
722 712
71...

output:

978
0
1158
166
1096
894
1142
1168
370
654
1896
688
1800
806
1734
912
338
544
1930
1024
1232
380
352
1694
498
1928
1046
868
436
910
1584
1202
330
1540
668
464
1188
1424
46
1730
680
982
1386
1482
42
1720
1706
898
1156
462
1546
1598
96
1222
22
466
280
558
244
472
708
1666
1672
110
1088
1570
1228
1772
5...

input:

1
35090
736 838 2
302
304
1772 836 2
1420
1422
1530 1794 2
1522
1524
1848 1964 2
404
406
304 586 2
60
62
944 884 2
1350
1352
272 1134 2
40
42
774 572 2
832
834
848 388 2
638
640
1404 1678 2
890
892
1562 1426 2
1652
1654
940 356 2
534
536
762 1292 2
1766
1768
358 1140 2
1868
1870
342 1290 2
696
698
1...

output:

302
1420
1522
404
60
1352
40
834
638
890
1654
534
1766
1868
698
2
1066
350
382
138
1556
24
1774
1486
1812
1600
366
796
1714
1336
534
440
572
1656
1368
612
752
48
1176
1302
1074
334
1758
494
832
972
762
432
962
1824
1842
346
888
1614
190
550
1534
1470
1892
1436
1078
1604
1272
558
332
156
1200
798
600...

result:

points 0.81967213110 max label = 1990

Test #88:

score: 50
Acceptable Answer
time: 34ms
memory: 3896kb

input:

0
10
1000 1000000000
897 448
897 517
583 297
897 748
84 650
402 690
131 583
583 601
464 897
336 674
189 897
897 246
843 421
432 742
529 877
812 209
103 109
842 931
795 84
289 103
103 579
84 603
926 897
70 897
183 901
448 647
111 513
646 689
84 949
191 485
745 12
124 578
133 689
423 755
767 124
897 8...

output:

1000
0
1682
1750
1082
1108
1724
1650
810
78
1400
792
326
250
1224
1214
944
1790
1796
680
1634
666
366
1596
290
1660
1340
126
700
956
494
1432
1800
836
1074
476
1992
992
1306
1590
542
188
1072
1826
70
1272
1738
1274
208
350
530
1358
1506
1396
770
274
436
60
382
1478
1798
396
1188
1864
1190
1772
1852
...

input:

1
47617
1540 1286 2
1542
1544
1644 528 3
1630
1632
1638
1394 1842 1
1388
84 516 3
86
88
96
16 1672 1
1854
796 816 1
794
1176 284 2
1954
1956
1056 678 2
1052
1054
94 1702 2
418
420
1210 1550 6
1212
1214
1218
1228
1230
1242
1016 982 1
996
1006 1560 2
126
128
714 748 1
1998
1258 1938 2
1262
1270
134 16...

output:

1544
1630
1388
96
1854
794
1956
1052
420
1242
996
126
1998
1270
146
1998
8
356
1998
1602
1404
706
1998
6
1686
1904
386
368
508
1354
696
892
1836
1582
1636
1972
1362
122
360
262
1980
1738
1998
128
1264
1842
1702
808
1586
1696
6
1580
328
1998
1594
128
1300
1022
1684
632
8
1998
1998
1404
940
34
860
822...

result:

points 0.81967213110 max label = 1998

Test #89:

score: 50
Acceptable Answer
time: 34ms
memory: 4084kb

input:

0
10
991 1000000000
454 800
702 960
660 644
108 499
445 776
921 520
184 252
730 588
97 163
465 448
361 58
227 250
577 112
191 405
394 157
830 296
589 428
814 830
531 947
161 797
490 127
145 911
858 49
935 552
600 543
138 501
850 916
602 242
114 606
516 650
573 988
121 41
617 723
680 173
619 709
620 ...

output:

991
0
1844
538
574
1104
500
772
1780
1566
1590
788
1076
1424
1130
920
1564
1574
950
1386
136
464
586
1920
1502
1522
1864
780
1318
1614
762
1488
216
1922
742
1588
1212
1300
1750
1964
1912
276
1392
1792
198
1172
1830
1500
298
300
1102
1032
1122
668
1476
1608
1312
324
1952
774
1058
1836
1894
1038
312
1...

input:

1
49922
1424 316 2
1420
1422
1404 126 1
1420
960 524 2
978
980
1906 362 2
1392
1394
780 1694 2
1158
1160
1264 1422 2
1192
1194
472 1828 2
1872
1874
722 1842 3
710
716
718
744 1788 2
576
578
1498 94 2
1472
1474
1378 934 2
1392
1394
220 1068 2
170
172
1926 806 2
418
420
1318 1802 1
1320
108 1030 1
126...

output:

1420
1420
980
1392
1160
1192
1872
710
576
1472
1394
170
420
1320
126
1240
812
1672
1068
1946
1402
894
736
1512
1420
246
636
6
1630
670
970
286
1418
456
350
914
1472
990
484
1068
456
586
1276
606
426
1280
1880
1582
1748
1354
946
114
248
778
402
1086
650
1260
488
1660
1458
950
398
274
1062
720
1044
12...

result:

points 0.81967213110 max label = 1996

Test #90:

score: 50
Acceptable Answer
time: 34ms
memory: 3828kb

input:

0
10
993 1000000000
659 162
695 292
133 492
301 424
380 243
646 631
297 394
653 704
220 522
825 939
861 883
602 802
939 903
875 50
576 279
343 778
734 393
665 687
340 125
189 579
672 873
201 476
715 325
846 119
682 482
362 218
694 968
463 785
402 585
985 957
207 215
887 618
859 317
871 214
655 459
3...

output:

993
0
1044
166
462
474
1266
1918
1570
1254
1564
1132
232
1744
708
522
1892
1274
612
1086
150
1452
1058
1642
1864
1230
640
1340
942
692
14
192
1436
976
1176
1882
1466
1258
554
1980
1774
548
386
218
1404
530
1052
872
972
1300
308
1710
1104
1638
1272
682
1482
1516
110
1070
1946
510
968
918
674
586
1224...

input:

1
50698
796 818 3
798
802
804
48 1574 1
38
1916 130 1
1998
1272 134 3
1286
1782
1784
414 108 2
418
420
1526 260 1
1528
1228 1214 1
1230
1124 714 1
250
428 864 3
480
482
492
56 942 2
706
708
1834 1434 1
1998
1406 212 2
1398
1404
1228 898 1
1230
320 1102 2
282
316
1980 1758 2
1982
1986
1508 1200 1
149...

output:

804
38
1998
1784
420
1528
1230
250
492
708
1998
1398
1230
282
1986
1494
1372
1412
1524
58
180
94
1936
528
474
1862
1518
866
316
422
154
830
534
734
972
1658
94
1642
1196
474
108
1802
1222
94
1952
422
954
94
1216
728
286
884
1552
582
94
1682
584
1794
1346
1222
20
994
1406
426
440
1922
1108
650
194
11...

result:

points 0.81967213110 max label = 1998

Test #91:

score: 50
Acceptable Answer
time: 34ms
memory: 3796kb

input:

0
10
993 1000000000
659 162
695 292
133 492
301 424
380 243
646 631
297 394
653 704
220 522
825 939
861 883
602 802
939 903
875 50
576 279
343 778
734 393
665 687
340 125
189 579
672 873
201 476
715 325
846 119
682 482
362 218
694 968
463 785
402 585
985 957
207 215
887 618
859 317
871 214
655 459
3...

output:

993
0
1044
166
462
474
1266
1918
1570
1254
1564
1132
232
1744
708
522
1892
1274
612
1086
150
1452
1058
1642
1864
1230
640
1340
942
692
14
192
1436
976
1176
1882
1466
1258
554
1980
1774
548
386
218
1404
530
1052
872
972
1300
308
1710
1104
1638
1272
682
1482
1516
110
1070
1946
510
968
918
674
586
1224...

input:

1
50698
796 818 3
798
802
804
48 1574 1
38
1916 130 1
1998
1272 134 3
1286
1782
1784
414 108 2
418
420
1526 260 1
1528
1228 1214 1
1230
1124 714 1
250
428 864 3
480
482
492
56 942 2
706
708
1834 1434 1
1998
1406 212 2
1398
1404
1228 898 1
1230
320 1102 2
282
316
1980 1758 2
1982
1986
1508 1200 1
149...

output:

804
38
1998
1784
420
1528
1230
250
492
708
1998
1398
1230
282
1986
1494
1372
1412
1524
58
180
94
1936
528
474
1862
1518
866
316
422
154
830
534
734
972
1658
94
1642
1196
474
108
1802
1222
94
1952
422
954
94
1216
728
286
884
1552
582
94
1682
584
1794
1346
1222
20
994
1406
426
440
1922
1108
650
194
11...

result:

points 0.81967213110 max label = 1998

Test #92:

score: 50
Acceptable Answer
time: 34ms
memory: 4084kb

input:

0
10
992 1000000000
274 302
761 266
243 116
753 556
69 885
191 771
127 476
904 335
735 660
798 382
116 771
973 331
753 437
318 813
250 127
64 904
929 494
127 885
318 538
135 116
822 415
894 258
187 322
874 759
574 890
379 812
988 653
332 331
572 244
215 346
825 401
510 519
517 777
958 897
911 176
40...

output:

992
0
6
32
1522
1976
1398
842
1434
1440
226
1110
1326
1750
1472
782
306
1242
1726
1566
1898
1162
1364
1128
900
1900
682
664
364
350
1334
564
120
720
122
1506
770
1974
142
1420
48
296
1002
1170
586
1048
756
858
404
1146
636
754
216
1534
752
436
112
718
1462
346
102
1072
1314
1390
1102
902
430
948
376...

input:

1
49569
1550 1282 1
1552
1074 1090 2
1076
1080
284 630 1
282
100 2 2
96
98
1164 392 3
450
452
1162
1940 704 1
1968
1814 526 4
1742
1808
1810
1812
1714 568 1
1716
1170 40 3
1048
1050
1168
196 48 1
198
1850 976 1
1840
604 232 1
602
990 1952 1
988
870 1430 1
700
62 266 1
20
418 1866 2
420
448
1772 0 4
...

output:

1552
1080
282
96
450
1968
1742
1716
1048
198
1840
602
988
700
20
448
1804
100
1854
890
1814
1774
1790
650
1270
748
1978
1318
46
902
1692
918
1360
478
748
510
290
1550
350
78
248
798
1360
672
1280
1802
1482
498
222
1832
700
1006
1154
1978
844
1212
886
402
20
700
402
254
1270
1978
1752
1348
752
2
1404...

result:

points 0.81967213110 max label = 1996

Test #93:

score: 50
Acceptable Answer
time: 34ms
memory: 4092kb

input:

0
10
992 1000000000
274 302
761 266
243 116
753 556
69 885
191 771
127 476
904 335
735 660
798 382
116 771
973 331
753 437
318 813
250 127
64 904
929 494
127 885
318 538
135 116
822 415
894 258
187 322
874 759
574 890
379 812
988 653
332 331
572 244
215 346
825 401
510 519
517 777
958 897
911 176
40...

output:

992
0
6
32
1522
1976
1398
842
1434
1440
226
1110
1326
1750
1472
782
306
1242
1726
1566
1898
1162
1364
1128
900
1900
682
664
364
350
1334
564
120
720
122
1506
770
1974
142
1420
48
296
1002
1170
586
1048
756
858
404
1146
636
754
216
1534
752
436
112
718
1462
346
102
1072
1314
1390
1102
902
430
948
376...

input:

1
49569
1550 1282 1
1552
1074 1090 2
1076
1080
284 630 1
282
100 2 2
96
98
1164 392 3
450
452
1162
1940 704 1
1968
1814 526 4
1742
1808
1810
1812
1714 568 1
1716
1170 40 3
1048
1050
1168
196 48 1
198
1850 976 1
1840
604 232 1
602
990 1952 1
988
870 1430 1
700
62 266 1
20
418 1866 2
420
448
1772 0 4
...

output:

1552
1080
282
96
450
1968
1742
1716
1048
198
1840
602
988
700
20
448
1804
100
1854
890
1814
1774
1790
650
1270
748
1978
1318
46
902
1692
918
1360
478
748
510
290
1550
350
78
248
798
1360
672
1280
1802
1482
498
222
1832
700
1006
1154
1978
844
1212
886
402
20
700
402
254
1270
1978
1752
1348
752
2
1404...

result:

points 0.81967213110 max label = 1996

Test #94:

score: 50
Acceptable Answer
time: 34ms
memory: 4092kb

input:

0
10
1000 1000000000
880 197
507 738
947 24
750 375
785 686
514 578
885 51
988 286
813 807
384 826
436 909
304 273
322 772
368 921
802 592
951 168
937 494
937 450
667 703
62 981
618 350
800 460
668 12
126 532
723 262
525 741
950 567
220 587
477 326
212 582
160 788
772 225
754 196
553 741
471 31
332 ...

output:

1000
0
472
898
262
1518
1444
506
1422
1696
1666
1510
1914
508
1350
632
1954
1512
1678
1154
1116
538
810
1630
1346
1278
1556
524
1274
1072
960
1210
890
1776
1366
1762
1902
202
426
390
602
406
96
1616
204
162
182
1946
928
1974
700
834
198
288
1864
504
1534
1334
438
1482
852
572
24
1698
1312
1542
1610
...

input:

1
50684
814 1930 1
778
320 1750 1
318
32 1548 2
2
4
1202 148 1
1196
1366 552 1
1932
1076 116 1
1090
1508 302 1
1516
1818 1734 3
1810
1812
1814
430 1872 2
432
540
1372 1100 1
1296
790 676 2
792
836
108 524 10
110
112
114
116
118
120
124
136
138
524
870 1016 2
216
868
1784 612 3
330
1748
1780
1714 318...

output:

778
318
2
1196
1932
1090
1516
1810
540
1296
836
524
216
330
1750
1998
1998
128
536
970
338
912
58
1280
1204
1278
830
288
1752
1552
1300
48
1122
566
612
1274
1998
614
690
732
1900
190
1828
48
1384
1504
1858
36
234
1048
1914
854
1118
612
1890
1340
1470
1530
36
642
1486
602
1652
1486
148
36
1974
218
72...

result:

points 0.81967213110 max label = 1998

Test #95:

score: 50
Acceptable Answer
time: 6ms
memory: 4080kb

input:

0
10
731 1000000000
730 284
530 730
304 730
730 104
730 252
48 730
615 730
472 730
730 414
730 441
64 730
150 730
351 730
86 730
730 542
730 207
416 730
730 145
45 730
730 159
409 730
603 730
730 353
690 730
71 730
730 579
730 684
730 93
730 88
38 730
730 419
22 730
595 730
730 675
730 633
730 183
4...

output:

731
0
1046
428
1384
188
80
838
726
908
1204
932
660
360
152
186
1404
414
272
1048
750
1234
244
64
1114
1396
1244
1156
222
92
640
746
420
1168
374
480
584
1346
1376
60
550
1378
284
462
790
1434
38
1182
446
12
488
958
326
1112
96
656
1088
82
1014
154
122
1352
1106
430
1000
22
544
1402
138
1194
732
616...

input:

1
5230
422 402 1
0
500 682 1
0
538 1074 1
1460
518 1206 1
0
96 1216 1
1460
1118 470 1
0
1344 1206 1
1460
494 18 1
0
1158 1232 1
0
596 1376 1
0
1152 1308 1
1460
190 812 1
0
1152 758 1
1460
1244 860 1
0
652 1068 1
1460
188 548 1
0
1054 898 1
1460
1454 1384 1
0
968 346 1
0
990 888 1
1460
204 1204 1
146...

output:

0
0
1460
0
1460
0
1460
0
0
0
1460
0
1460
0
1460
0
1460
0
0
1460
1460
1460
1460
0
0
0
1460
1460
0
0
130
0
0
0
0
1460
0
1460
0
1460
0
0
1438
0
0
0
1460
1460
0
0
1460
0
0
1460
0
0
0
0
1460
0
0
0
1460
0
0
1460
1460
1460
0
0
0
1460
1460
0
0
1460
0
1460
0
1460
0
1460
0
1460
0
0
1460
1460
0
1460
0
0
1460
1...

result:

points 0.81967213110 max label = 1460

Test #96:

score: 50
Acceptable Answer
time: 14ms
memory: 3892kb

input:

0
10
1000 1000000000
999 515
999 808
389 999
137 999
936 999
887 999
287 999
999 299
999 704
14 999
999 937
387 999
841 999
78 999
894 999
757 999
691 999
71 999
779 999
999 676
838 999
999 524
999 359
999 19
29 999
405 999
192 999
17 999
136 999
31 999
999 952
999 735
696 999
942 999
999 223
530 99...

output:

1000
0
1586
524
336
554
906
1174
1774
858
672
1994
982
1222
1444
20
1300
1036
56
1334
48
896
1438
566
1810
120
1878
180
624
346
50
1172
60
1928
380
1768
1056
118
1824
298
766
966
1590
1108
1910
604
1186
1778
1106
994
854
922
622
1180
936
372
1330
1832
1008
570
1678
978
164
498
1062
406
1502
320
526
...

input:

1
10180
1400 778 1
0
0 554 1
1998
1434 356 1
0
1438 270 1
1998
248 484 1
1998
1266 240 1
0
1280 516 1
1998
1182 686 1
0
1290 582 1
0
1520 1650 1
0
1130 58 1
1998
848 506 1
0
1470 154 1
0
1852 636 1
0
1914 1328 1
0
540 1564 1
0
1790 664 1
1998
274 198 1
1998
1322 176 1
1998
932 980 1
0
248 1022 1
0
1...

output:

0
1998
0
1998
1998
0
1998
0
0
0
1998
0
0
0
0
0
1998
1998
1998
0
0
1998
0
1998
0
1998
0
1998
1998
1998
0
1998
1998
1998
1998
1998
0
0
1998
0
0
1126
1998
0
0
0
0
1998
0
0
1998
1998
1998
0
0
0
1998
0
1998
0
1998
1998
0
0
1998
1998
1998
1998
1998
0
1998
0
0
0
1998
1998
1998
1998
0
0
1998
1998
1998
1998
...

result:

points 0.81967213110 max label = 1998

Test #97:

score: 50
Acceptable Answer
time: 18ms
memory: 3788kb

input:

0
10
892 1000000000
606 640
172 727
509 98
109 640
296 474
23 332
782 57
427 887
57 179
720 206
766 218
884 395
110 412
188 813
801 345
131 824
359 689
686 789
274 346
167 842
429 845
249 550
273 798
588 61
631 364
120 266
296 213
819 110
10 420
401 438
286 261
813 61
454 67
824 59
174 859
252 271
3...

output:

892
0
1584
746
1566
1094
550
1000
920
1602
422
796
1078
310
366
76
1224
568
1254
922
344
546
1124
1326
1482
488
788
904
1162
446
1660
1290
720
1742
394
382
332
1126
288
1686
384
1478
554
322
1286
830
216
102
752
1324
1514
1704
806
178
1524
1372
478
1736
1282
96
38
1034
640
1740
644
532
6
1186
210
57...

input:

1
13208
1762 726 8
12
1748
1750
1752
1754
1756
1758
1760
1118 102 11
986
1098
1100
1102
1104
1106
1108
1110
1112
1114
1116
1764 618 10
2
1746
1748
1750
1752
1754
1756
1758
1760
1762
182 446 10
22
164
166
168
170
172
174
176
178
180
1710 320 10
8
1692
1694
1696
1698
1700
1702
1704
1706
1708
146 194 1...

output:

12
986
2
22
8
186
448
140
392
54
1046
1632
178
1452
1120
1392
1452
1110
1566
92
1440
396
1098
1440
872
342
4
54
1622
1440
1772
1102
1562
1238
1562
712
1366
738
2
824
1154
342
642
1238
752
392
914
652
1780
1680
538
138
1674
270
114
12
914
1258
372
764
700
128
310
1452
538
138
1452
1772
1290
1076
986
...

result:

points 0.81967213110 max label = 1782

Test #98:

score: 50
Acceptable Answer
time: 18ms
memory: 3812kb

input:

0
10
1000 1000000000
180 624
132 59
664 556
950 732
810 7
7 911
627 313
332 648
703 375
220 710
922 375
812 676
664 387
725 759
223 711
329 138
536 671
316 235
182 116
65 893
948 116
521 965
728 495
502 950
521 460
103 682
574 331
89 865
490 979
530 125
980 65
176 190
308 702
308 597
309 107
523 566...

output:

1000
0
178
284
682
802
1728
1940
92
668
1632
640
84
618
128
372
892
1938
42
1634
878
1152
212
1804
662
944
1714
1028
538
330
606
182
122
998
316
400
276
420
1106
1904
180
1058
116
614
1304
1930
1308
1294
1332
1416
582
500
1724
1890
1520
1524
810
1410
1744
532
930
1460
1766
170
1036
578
1142
1972
302...

input:

1
16365
822 1872 9
824
826
828
830
832
834
836
838
858
442 1594 8
444
446
448
450
452
454
456
490
1748 236 8
1764
1780
1796
1812
1828
1844
1860
1976
110 1244 9
256
402
548
646
792
1670
1816
1962
1982
1074 1400 3
1062
1070
1072
918 1744 8
854
904
906
908
910
912
914
916
1656 350 6
1470
1596
1608
1620...

output:

858
490
1976
1670
1062
854
1470
940
34
1164
1768
298
920
1220
996
548
1010
684
18
790
1784
518
720
794
34
1972
376
1570
624
356
968
1428
1816
1604
490
1404
402
1948
824
1352
206
1336
566
1708
206
924
908
1568
646
226
910
928
1402
1652
1012
218
18
1620
1130
340
1130
472
1298
594
1156
842
1670
1736
96...

result:

points 0.81967213110 max label = 1998

Test #99:

score: 50
Acceptable Answer
time: 20ms
memory: 3784kb

input:

0
10
712 1000000000
165 500
293 270
484 552
3 324
308 190
621 104
561 389
581 286
154 188
251 457
223 99
633 660
446 540
160 610
150 323
93 265
273 380
268 297
38 376
670 568
653 209
253 291
384 187
434 193
422 131
96 418
625 325
72 325
299 590
645 552
486 384
28 153
37 246
309 566
91 686
468 464
57...

output:

712
0
1368
1180
1414
1144
116
1008
916
174
592
230
582
234
284
1004
896
450
440
850
226
606
1348
816
316
100
1322
540
1052
20
848
1086
1288
314
972
1402
1058
692
1344
362
976
1186
1270
1126
794
812
1090
1376
836
538
1122
658
1160
252
382
800
1024
998
80
964
808
648
1034
1206
418
1268
452
1042
1176
1...

input:

1
33400
1230 996 3
494
496
498
618 932 3
216
220
222
248 4 3
1100
1102
1106
218 710 3
66
68
70
94 182 3
1094
1096
1098
1064 780 3
688
690
1062
782 754 3
60
64
780
692 624 3
148
150
690
678 364 3
1010
1012
1016
458 454 3
460
756
760
880 1332 3
834
838
840
1054 732 3
876
880
1052
1016 902 3
476
478
10...

output:

498
216
1106
66
1094
690
64
150
1016
760
834
876
478
362
976
1026
296
542
750
300
56
1184
136
1120
144
510
590
882
464
1142
1304
1074
1304
364
946
528
104
1066
934
600
450
1080
1368
608
104
350
362
846
264
1256
684
198
1314
518
1116
518
998
1016
816
1176
732
284
84
472
128
890
940
910
1026
534
1084
...

result:

points 0.81967213110 max label = 1422

Test #100:

score: 50
Acceptable Answer
time: 26ms
memory: 3796kb

input:

0
10
1000 1000000000
339 519
436 552
9 671
650 693
652 769
640 509
384 65
726 126
261 226
444 449
419 177
123 140
813 825
4 483
859 484
506 423
273 852
939 263
891 108
985 3
299 95
490 816
846 130
963 551
714 667
771 311
856 316
515 601
647 905
2 877
612 372
163 540
642 602
717 169
699 632
854 124
5...

output:

1000
0
1048
148
350
1912
1568
1296
788
1548
398
1686
1440
1752
772
1968
1312
868
340
736
682
1290
12
664
1562
542
1828
974
1208
1646
1352
182
1330
268
668
578
1466
992
388
1796
804
1374
598
1126
1606
1174
1098
648
454
266
1750
1272
444
1014
356
936
990
1780
244
806
1300
1728
324
994
1002
248
722
173...

input:

1
33377
1014 280 3
1658
1660
1664
432 410 3
434
1450
1452
1180 1820 3
642
646
648
1482 500 3
392
396
1480
1602 1972 3
98
100
102
828 1006 3
272
274
276
1690 596 3
518
520
522
1794 1092 3
902
904
1792
66 1016 3
1030
1032
1034
1096 414 3
1340
1342
1344
318 540 3
76
80
316
1756 164 3
100
102
104
496 73...

output:

1664
1452
642
396
98
272
522
904
1030
1344
76
104
1186
972
1106
584
188
140
444
1874
482
420
1904
944
260
330
1530
12
282
982
680
1072
1528
1428
824
1552
1678
390
470
212
1350
438
944
918
1030
152
1918
36
1634
1012
1414
12
1628
1394
1602
1828
8
1012
504
238
1842
784
196
1706
534
876
288
570
776
730
...

result:

points 0.81967213110 max label = 1998

Test #101:

score: 50
Acceptable Answer
time: 12ms
memory: 3896kb

input:

0
10
905 1000000000
149 541
744 692
648 655
441 692
692 263
648 156
754 161
20 648
538 541
285 648
843 541
720 541
692 791
648 167
357 648
533 648
196 541
626 754
692 511
754 485
56 754
893 541
796 541
19 692
541 110
471 541
833 541
754 508
541 593
406 692
355 754
541 777
618 648
648 760
754 121
294...

output:

905
0
1472
1006
542
982
1232
1052
1250
1362
784
96
1710
1652
658
1418
252
322
36
1482
12
872
804
1664
1256
392
578
1736
1304
212
616
300
1616
1376
742
1630
1680
1066
1568
1782
1416
1196
162
634
1690
612
342
730
1032
420
224
422
1030
204
1082
806
1400
62
712
822
1248
290
1504
86
492
1468
966
1552
716...

input:

1
4502
746 1788 42
630
664
666
668
670
672
674
676
678
680
682
684
686
688
690
692
694
696
698
700
702
704
706
708
710
712
714
716
718
720
722
724
726
728
730
732
734
736
738
740
742
744
1388 996 1
840
1322 718 1
1330
260 672 69
262
264
266
1360
1362
1364
1366
1368
1370
1372
1374
1376
1378
1380
1382...

output:

630
840
1330
1360
848
316
206
528
182
222
1808
1364
246
1274
18
840
1808
1344
1808
706
28
338
260
618
146
1704
206
1360
1808
1060
98
246
788
1248
1808
1258
824
34
206
1590
1384
840
1808
1094
1094
222
1330
1094
740
1350
1662
1808
1592
1360
260
1808
54
606
1416
260
944
338
754
1808
62
182
416
1210
180...

result:

points 0.81967213110 max label = 1808

Test #102:

score: 50
Acceptable Answer
time: 12ms
memory: 3916kb

input:

0
10
1000 1000000000
864 948
95 883
976 573
252 601
415 95
95 514
601 388
573 857
666 136
535 95
751 666
605 541
666 971
289 541
69 501
601 321
370 573
438 601
681 515
541 795
948 668
948 827
515 14
515 94
478 601
319 95
69 342
461 186
573 704
69 706
573 301
573 16
772 601
788 666
948 537
666 530
51...

output:

1000
0
1332
1738
1158
800
1102
1334
8
852
1142
792
1014
1862
100
432
426
1552
1232
636
1908
1490
502
1776
1920
846
832
1702
1692
1176
1460
128
1944
866
724
1062
1414
66
902
1806
1740
1344
416
1212
1756
664
1296
616
1818
586
1112
710
152
1800
98
1726
1098
968
1816
890
58
728
376
1538
226
1416
966
678...

input:

1
4293
484 460 1
428
1090 848 1
1020
1552 1586 1
1930
718 4 1
198
394 328 44
396
398
400
402
404
406
408
410
412
414
416
418
420
422
424
426
428
430
432
434
436
438
440
442
444
446
448
450
452
454
456
458
460
462
464
466
468
470
472
474
476
478
480
764
1602 1732 1
1712
338 490 1
696
1692 546 1
1620
...

output:

428
1020
1930
198
764
1712
696
1620
774
256
22
1542
1712
1622
1542
1036
1998
1998
256
1556
1998
1020
22
1422
1036
1542
870
116
886
1266
22
774
830
22
1128
34
796
1622
734
1390
576
120
1020
198
486
1998
1998
1804
256
436
22
1256
1586
202
1784
1046
1998
1248
116
1586
436
1998
1334
1020
870
1036
198
24...

result:

points 0.81967213110 max label = 1998