QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#498938#1139. StationsDan4Life#52.320549 54ms4164kbC++231.0kb2024-07-30 21:58:072024-07-30 21:58:07

Judging History

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

  • [2024-07-30 21:58:07]
  • 评测
  • 测评结果:52.320549
  • 用时:54ms
  • 内存:4164kb
  • [2024-07-30 21:58:07]
  • 提交

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;
vi labels;
int dfs_timer = 0;
vi adj[mxN];

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

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);
	return labels;
}

int isAnc(int s, int t){
	int stS = s/1000, enS = s%1000;
	int stT = t/1000, enT = t%1000;
	return stS<=stT and enS>=enT;
}

int find_next_station(int s, int t, vi c) {
	for(auto u : c) if(u==t) return u;
	int par;
	for(int i = 0; i < sz(c); i++){
		if(isAnc(c[i],s)){
			par=c[i]; continue;
		}
		if(isAnc(c[i],t)) return c[i];
	}
	return par;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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
9
6009
3009
8009
5009
4009
2009
9009
7009
1001
3
2
1002
2002
998
997
223997
53218
207218
508997
816997
365997
369997
86218
104218
329997
529997
138218
787997
608997
152218
447997
270997
680997
519997
863997
579997
434997
687997
402997
709997
718997
962997
818997
320997
11218
839997
801997
701997
...

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: 3704kb

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
995
1511
512995
2256
257511
513767
768995
3129
130256
258384
385511
514640
641767
769895
896995
4066
67129
131193
194256
259321
322384
386448
449511
515577
578640
642704
705767
770832
833895
897959
960995
5035
36066
68098
99129
132162
163193
195225
226256
260290
291321
323353
354384
387417
41844...

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: 42ms
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
1
1001
997
996
251863
427863
578863
71863
300863
525863
291863
380863
36863
659863
114863
886996
630863
484863
456863
936996
880996
45863
947996
161863
485863
182863
437863
172863
970996
670863
788863
620863
399863
891996
22863
75863
340863
605863
375863
396863
226863
82863
706863
950996
157863
60...

input:

1
59859
1005 5005 2
9
2005
1001 1 1
1
1001 1 1
1
31999 85999 2
30999
32999
293998 395998 2
292998
294998
265997 863997 2
264997
266997
1 1001 1
1001
7009 9 2
6009
8009
122999 328999 2
121999
123999
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1002 2002 2
2
2002
897996 174863 2
896996
898996
371999 213999 ...

output:

2005
1
1
32999
294998
266997
1001
6009
123999
1001
1001
1
2002
896996
370999
510999
2005
1002
294863
30099
556997
385998
974996
977996
2002
715887
526887
696887
1002
2003
642887
9
541997
1003
1
2003
628997
326999
791997
2002
374863
700887
989999
642999
4005
1003
918998
455863
976998
2002
227998
1003...

result:

ok 

Test #18:

score: 16
Accepted
time: 38ms
memory: 3852kb

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
998
987998
629800
723800
546800
226800
341800
197800
749800
806998
415800
820998
952998
347800
880998
206800
317800
249800
802998
721800
610800
256800
736800
769800
526800
608800
542800
689800
374800
516800
979998
41800
902998
744800
510800
461800
951998
285800
507800
663800
792800
509800
54800
...

input:

1
50048
149930 561930 2
148930
150930
342743 487743 2
341743
343743
812995 856995 2
811995
813995
589930 169930 2
588930
590930
476800 929998 2
475800
477800
276800 583800 2
275800
277800
967990 183930 2
966990
968990
865930 655930 2
864930
866930
550743 971995 2
549743
551743
8961 430961 2
7961
996...

output:

150930
343743
813995
588930
475800
277800
966990
864930
549743
9961
529800
225996
982992
848961
502743
509604
473743
618684
653992
305991
616961
197961
379993
314996
129991
355684
236743
118604
261800
99604
808961
186991
313604
266604
966995
577991
864999
354604
188743
275604
55106
342993
804961
802...

result:

ok 

Test #19:

score: 16
Accepted
time: 52ms
memory: 3764kb

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
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001

input:

1
100000
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001...

output:

1001
1001
1
1001
1
1001
1001
1001
1
1001
1
1001
1
1
1
1
1001
1
1
1001
1001
1001
1001
1
1001
1001
1001
1
1001
1001
1
1
1001
1001
1001
1001
1
1
1001
1001
1001
1
1001
1001
1
1001
1
1
1
1001
1
1001
1
1
1
1001
1
1
1001
1
1
1
1
1
1
1
1001
1
1001
1001
1
1001
1001
1
1001
1
1001
1001
1001
1
1001
1
1
1001
1
1...

result:

ok 

Test #20:

score: 16
Accepted
time: 44ms
memory: 4080kb

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
2
1001
2002
3
2
2002
1001
3
2
2002
1002
3
2
2002
1002
3
2
1002
2002
3
2
1002
2002
3
2
2002
1002
3
2
1002
2002
3
2
1002
2002
3
2
2002
1002

input:

1
74899
2 2002 1
1002
2002 2 1
1002
2002 1002 1
1002
1001 2 1
2
2002 1001 1
2
2 1001 2
1001
2002
1002 2 2
2
2002
2 1002 1
1002
2 2002 1
1002
1002 2002 2
2
2002
2 2002 2
1001
2002
2 1002 1
1002
2 1002 1
1002
2002 2 1
1002
2002 1002 1
1002
2 2002 1
1002
2 2002 1
1002
2 2002 1
1002
2002 2 1
2
1002 2 2
...

output:

1002
1002
1002
2
2
1001
2
1002
1002
2002
2002
1002
1002
1002
1002
1002
1002
1002
2
2
2002
1002
1002
1002
1002
2002
2002
1002
2
2
1002
1002
1002
2
1002
1002
1002
1002
2002
2
2002
1002
2
1002
1002
1002
2002
1002
2
2
1002
1002
2
1002
2002
2002
2
2002
1002
2002
2
1002
1001
1002
1001
1002
2
2002
2
1002
1...

result:

ok 

Test #21:

score: 16
Accepted
time: 42ms
memory: 3856kb

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
3
1001
2003
3003
4
3
2003
1003
3003
4
3
2003
3003
1003
4
3
2003
1003
3003
4
3
2003
3003
1003
4
3
1002
2002
3003
4
3
3003
2003
1001
4
3
1002
3003
2002
4
3
3003
1002
2002
4
3
2003
3003
1003

input:

1
66495
2003 3003 2
3
3003
2003 1003 2
1003
3003
2002 3 1
1002
1001 3 1
3
1001 2003 1
3
3003 1003 1
2003
2002 3 1
1002
1002 3 2
3
2002
3003 2003 1
2003
3003 1003 1
2003
3003 1001 1
2003
2003 3 2
1003
3003
2003 3 2
3
3003
3003 3 1
3
3003 1003 1
2003
3003 3 1
2003
3003 1002 1
3
2003 1003 2
1003
3003
2...

output:

3003
1003
1002
3
3
2003
1002
3
2003
2003
2003
1003
3
3
2003
2003
3
1003
3003
2003
2002
1003
2003
3
3
2003
3
1003
3
2003
2003
3
3
1003
3
1002
1003
1002
3
1002
2003
3
1003
2003
1002
3
2003
3
1001
3003
2003
1003
1001
1002
2003
1002
2002
2003
1003
2003
2003
1003
3
1003
3
3
1003
3003
2003
2003
1001
1002
...

result:

ok 

Test #22:

score: 16
Accepted
time: 38ms
memory: 4116kb

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
999
356723
347723
111723
710723
275723
686723
774999
84723
927999
116723
524723
220723
215723
965999
888999
113723
393723
286723
820999
41723
247723
370723
101723
669723
642723
903999
908999
806999
942999
823999
874999
993999
90723
752999
127723
924999
136723
255723
438723
151723
711723
28723
3...

input:

1
50050
77293 275293 2
76293
78293
108339 110339 2
107339
109339
823999 433723 2
822999
824999
909999 225999 2
908999
910999
997999 29322 2
996999
998999
362999 425999 2
361999
363999
836999 420723 2
835999
837999
312999 183230 2
311999
313999
617999 462999 2
616999
618999
459723 995999 2
458723
460...

output:

78293
109339
822999
908999
996999
363999
835999
311999
616999
458723
692999
848999
734999
829999
602999
457999
672999
313999
740999
176293
455999
299999
846999
732999
566999
131723
120723
486723
502999
663999
264339
925999
257293
936999
106723
310999
678999
394999
184293
741999
414999
654999
947999
...

result:

ok 

Test #23:

score: 16
Accepted
time: 30ms
memory: 3884kb

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
999
956999
370999
138234
66234
564999
925999
824999
4234
111234
759999
11234
805999
875999
932999
996999
190234
656999
511999
89234
92234
796999
249999
900999
789999
533999
387999
326999
63234
722999
312999
634999
176234
7234
841999
882999
712999
979999
259999
184234
188234
39234
858999
333999
...

input:

1
50053
445999 346999 2
444999
446999
619999 812999 2
618999
620999
52234 203234 2
51234
53234
877999 522999 2
876999
878999
568999 667999 2
567999
569999
896999 784999 2
895999
897999
195234 832999 2
194234
196234
490999 523999 2
489999
491999
693999 388999 2
692999
694999
410999 575999 2
409999
41...

output:

444999
620999
53234
876999
569999
895999
194234
491999
692999
411999
214234
793999
839999
44234
759999
108234
8234
916999
920999
439999
393999
646999
751999
616999
612999
518999
134234
669999
149234
292999
260999
799999
958999
700999
885999
403999
746999
483999
758999
187234
709999
59234
844999
9859...

result:

ok 

Test #24:

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

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
3
1003
2003
3003
4
3
1003
3003
2003
4
3
2003
1003
3003
4
3
3003
1003
2003
4
3
2003
3003
1003
4
3
3003
2003
1003
4
3
1001
2003
3003
4
3
1001
3003
2003
4
3
2002
1002
3003
4
3
2002
3003
1002

input:

1
120
1003 3003 2
3
2003
1003 2003 2
3
2003
1003 2003 2
3
2003
3003 2003 1
2003
2003 1003 2
1003
3003
3 1001 2
1001
2003
3 3003 2
1001
2003
3 1003 1
1003
3003 1001 1
2003
2003 1001 2
3
3003
1003 3 2
3
2003
1001 2003 1
3
1003 3 2
3
2003
2003 3003 2
1003
3003
1001 3003 1
3
3 2003 1
1003
2003 3003 2
10...

output:

2003
2003
2003
2003
1003
1001
2003
1003
2003
3
3
3
3
3003
3
1003
3003
1002
3003
1003
1003
1003
3003
2003
2003
2003
1003
2003
3
3003
2003
1001
1003
2003
3
2003
2003
1002
3
1003
2003
1003
3
2003
2003
1003
2003
1003
1003
2003
3
1002
3003
1003
3
1003
3
2003
3
2003
1003
2003
1003
3
1002
2003
2003
1003
20...

result:

ok 

Test #25:

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

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
5
1005
2005
3005
4005
5005
6
5
1005
2005
3005
5005
4005
6
5
1005
2005
4005
3005
5005
6
5
1005
2005
5005
3005
4005
6
5
1005
2005
4005
5005
3005
6
5
1005
2005
5005
4005
3005
6
5
1005
3005
2005
4005
5005
6
5
1005
3005
2005
5005
4005
6
5
1005
4005
2005
3005
5005
6
5
1005
5005
2005
3005
4005

input:

1
300
3005 2005 2
2005
4005
4005 3005 2
3005
5005
4005 5 2
3005
5005
4005 5005 2
3005
5005
1005 5005 2
5
2005
3005 5 2
2005
4005
1005 3005 2
5
2005
4005 1005 2
3005
5005
5 1005 1
1005
2005 5005 2
1005
3005
5 2005 1
1005
3005 5005 2
2005
4005
3005 4005 2
2005
4005
2005 3005 2
1005
3005
2005 4005 2
10...

output:

2005
3005
3005
5005
2005
2005
2005
3005
1005
3005
1005
4005
4005
3005
3005
5005
3005
4005
4005
3005
2005
5
2005
3005
1005
1005
1005
5005
3005
4005
3005
3005
1005
4005
3005
2005
1005
3005
4005
5005
4005
1005
4005
4005
5005
2005
1005
2005
2005
1005
3005
1005
2005
4005
5005
2005
1005
1005
3005
3005
200...

result:

ok 

Test #26:

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

input:

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

output:

3
2
1002
2002
3
2
2002
1002
3
2
1001
2002

input:

1
18
2 2002 1
1002
2 1002 1
1002
2 2002 2
1001
2002
2 2002 1
1002
2002 2 1
1002
1002 2002 2
2
2002
2002 1001 1
2
2002 2 1
1002
2 1002 1
1002
1002 2 2
2
2002
1001 2 1
2
1002 2 2
2
2002
1001 2002 1
2
2002 2 1
2
2002 1002 1
1002
2 1001 2
1001
2002
2002 1002 1
1002
1002 2002 2
2
2002

output:

1002
1002
2002
1002
1002
2002
2
1002
1002
2
2
2
2
2
1002
1001
1002
2002

result:

ok 

Test #27:

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

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
3
1003
2003
3003
4
3
1003
2002
3003
4
3
1001
2002
3003
4
3
1002
3003
2002
4
3
3003
2002
1003
4
3
1003
3003
2002
4
3
1001
3003
2003
4
3
3003
2003
1001
4
3
3003
1003
2002
4
3
3003
1002
2002

input:

1
66694
3 3003 2
1001
2003
2003 3003 2
3
3003
2002 1003 1
1003
1003 3 3
3
2002
3003
3003 1001 1
2003
1002 2002 2
3
2002
1001 2002 1
3
3003 1002 1
3
2002 1003 1
1003
3003 1001 1
2003
3 3003 1
1003
3003 1001 1
2003
1001 2002 1
3
1002 3003 2
3
2002
1003 3003 3
3
2002
3003
3 2003 1
1003
2003 1001 2
3
30...

output:

2003
3003
1003
3
2003
2002
3
3
1003
2003
1003
2003
3
3
3003
1003
3
1003
1003
1003
1003
1003
1003
3
1003
1003
1003
1002
1003
1003
3
2003
1003
2003
3
3003
2003
2002
3
1003
1003
3
3
3
3003
2003
1002
1003
3
2003
1002
3003
1003
1003
2003
3
2002
3
1003
3
1003
3003
1003
1003
1003
2003
1002
2003
1003
1003
1...

result:

ok 

Test #28:

score: 16
Accepted
time: 38ms
memory: 3880kb

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
999
271279
471512
592625
928936
836838
532625
335338
915915
957957
34999
694700
320320
509512
392392
697700
86086
820838
693700
136143
462512
522625
190190
385385
702702
468512
416416
510512
115115
388388
827838
345345
626626
383383
287289
925925
253253
300300
255255
907907
148148
27999
647647
...

input:

1
51340
298752 790999 2
297752
299752
265999 51999 2
264999
266999
263646 509646 2
262646
264646
315349 946956 2
314349
316349
897999 497999 2
896999
898999
606625 260260 2
605625
607625
683700 7013 2
682700
684700
136143 913919 2
135143
137143
609609 702702 1
608609
701701 682684 1
2999
140752 2247...

output:

297752
264999
264646
314349
896999
605625
682700
135143
608609
2999
141752
737752
673687
71999
965971
658662
331396
71999
2999
819838
724795
794833
381386
586752
794799
71999
942968
381396
655999
847999
923981
241999
161168
238246
487783
921999
569625
221286
455783
818894
857999
850999
3025
2999
560...

result:

ok 

Test #29:

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

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
999
601603
510512
429429
285290
461467
379383
715715
51053
398398
862863
593594
169171
719719
871874
578579
776780
959965
396398
836839
252258
598603
874874
320322
967970
587588
515517
970970
664664
113114
495495
802802
435436
3998
769773
525525
219223
700700
840841
853856
444445
618623
355356
...

input:

1
51513
767999 930999 2
766999
768999
437476 5033 2
436476
438476
416416 618618 1
1999
486486 745745 1
1999
740745 530533 2
739745
741745
486489 153154 2
485489
487489
11311 775999 2
10311
12311
449529 664850 2
448529
450529
600618 96108 2
599618
601618
491491 387387 1
1999
27902 612902 2
26902
2890...

output:

768999
436476
1999
1999
739745
485489
10311
448529
599618
1999
28902
914919
10997
578591
713978
19850
3998
571850
545902
260267
188253
561999
10997
583999
815820
326999
1999
922945
54069
213311
29999
792794
474902
697850
781790
169902
579978
39253
210902
1999
284290
368999
32999
654662
350351
1999
3...

result:

ok 

Test #30:

score: 16
Accepted
time: 38ms
memory: 3816kb

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
999
293308
922922
198213
73073
337351
854888
969999
204213
281308
16033
614640
32033
119122
76102
331351
372376
560567
180213
185213
982999
505540
267272
140151
156176
274308
506540
934966
594608
232245
29033
104122
788803
246272
665673
528540
659673
731736
47073
622640
789803
841848
94102
7958...

input:

1
49931
997999 708736 2
996999
998999
322351 734736 2
321351
323351
1966 418438 30
999
2033
34073
74102
103122
123151
152176
177213
214245
246272
273308
309351
352376
377410
411438
439464
465500
501540
541567
568608
609640
641673
674703
704736
737774
775803
804848
849888
889922
923966
246272 710736 ...

output:

996999
321351
411438
1966
428438
598608
710736
963966
281308
809848
82102
486500
16033
318351
1966
65073
389410
981999
852888
332351
551567
144151
775803
480500
764774
150151
538540
495500
940966
393410
1966
967999
746774
731736
575608
999
788803
689703
537540
231245
69073
297308
982999
516540
77780...

result:

ok 

Test #31:

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

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
95
55055
86086
30030
92092
23023
83083
4004
76076
64064
77077
32032
94094
91091
50050
28028
49049
72072
11011
22022
53053
42042
9009
74074
20020
10010
71071
2002
21021
52052
62062
58058
54054
26026
65065
60060
1001
25025
29029
17017
45045
41041
75075
19019
39039
47047
48048
57057
90090
46046
5905...

input:

1
4026
66066 94094 1
95
17017 78078 1
1095
34034 84084 1
95
50050 44044 1
95
70070 77077 1
95
95 17017 95
1001
2002
3003
4004
5005
6006
7007
8008
9009
10010
11011
12012
13013
14014
15015
16016
17017
18018
19019
20020
21021
22022
23023
24024
25025
26026
27027
28028
29029
30030
31031
32032
33033
34034...

output:

95
1095
95
95
95
17017
95
1095
1095
1095
1095
95
95
1095
24024
1095
95
95
82082
95
95
1095
95
1095
67067
95
1095
61061
1095
1095
1095
95
27027
95
95
95
1095
95
95
95
1095
95
95
1095
26026
95
1095
1095
95
1095
75075
46046
19019
1095
21021
1095
95
95
1095
1095
1095
95
1095
95
95
11011
1095
95
46046
10...

result:

ok 

Test #32:

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

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
540
59059
148148
8008
258258
42042
256256
51051
386386
382382
255255
35035
503503
328328
527527
514514
442442
230230
163163
274274
208208
3003
227227
2002
462462
387387
91091
84084
535535
504504
516516
123123
469469
207207
7007
55055
322322
346346
103103
138138
4004
44044
62062
251251
66066
3713...

input:

1
5675
235235 168168 1
540
201201 376376 1
540
192192 468468 1
1540
207207 59059 1
1540
1540 403403 540
540
2002
3003
4004
5005
6006
7007
8008
9009
10010
11011
12012
13013
14014
15015
16016
17017
18018
19019
20020
21021
22022
23023
24024
25025
26026
27027
28028
29029
30030
31031
32032
33033
34034
35...

output:

540
540
1540
1540
403403
1540
1540
1540
1540
540
540
1540
540
1540
540
1540
540
540
1540
540
540
1540
540
1540
540
1540
1540
1540
540
1540
1540
1540
1540
1540
540
540
1540
1540
540
1540
1540
1540
1540
540
540
1540
540
540
1540
1540
1540
1540
540
1540
540
540
540
1540
1540
1540
540
1540
1540
1540
540...

result:

ok 

Test #33:

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

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
999
491491
878878
521521
906906
468468
452452
440440
100100
610610
423423
160160
347347
343343
605605
98098
844844
18018
244244
211211
973973
689689
22022
597597
16016
701701
771771
58058
871871
574574
568568
320320
460460
229229
54054
28028
205205
430430
424424
260260
572572
715715
432432
1401...

input:

1
10180
72072 388388 1
1999
47047 335335 1
1999
57057 340340 1
1999
123123 915915 1
1999
196196 718718 1
999
971971 768768 1
1999
737737 590590 1
999
403403 608608 1
1999
614614 256256 1
1999
105105 319319 1
999
275275 805805 1
999
775775 190190 1
1999
28028 667667 1
999
238238 327327 1
999
107107 1...

output:

1999
1999
1999
1999
999
1999
999
1999
1999
999
999
1999
999
999
999
1999
1999
999
1999
1999
1999
1999
1999
999
840840
999
999
1999
1999
999
1999
999
1999
999
1999
1999
1999
1999
1999
1999
1999
1999
999
1999
999
999
1999
1999
1999
1999
1999
1999
1999
241241
1999
1999
1999
1999
1999
1999
999
1999
999
...

result:

ok 

Subtask #4:

score: 10
Accepted

Test #34:

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

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
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001

input:

1
100000
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1001 1 1
1
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1001 ...

output:

1
1001
1001
1
1001
1
1
1
1
1
1001
1
1001
1
1001
1001
1001
1
1
1001
1
1001
1001
1
1
1001
1001
1
1001
1001
1
1
1
1
1
1001
1
1001
1
1
1
1001
1001
1
1001
1001
1001
1001
1
1
1001
1001
1
1
1
1001
1001
1
1001
1001
1
1001
1001
1
1
1
1001
1
1001
1001
1001
1001
1001
1001
1
1001
1
1001
1001
1001
1
1
1
1
1001
1...

result:

ok 

Test #35:

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

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
2
2002
1002
3
2
1001
2002
3
2
2002
1001
3
2
2002
1002
3
2
1002
2002
3
2
1002
2002
3
2
2002
1002
3
2
1002
2002
3
2
2002
1001
3
2
2002
1002

input:

1
75069
1002 2002 2
2
2002
2 1001 2
1001
2002
2 2002 1
1002
2 2002 1
1002
1001 2 1
2
2 2002 1
1002
2002 1002 1
1002
1002 2 2
2
2002
1001 2002 1
2
1002 2002 2
2
2002
1002 2002 2
2
2002
2002 2 1
1002
1002 2002 2
2
2002
1002 2002 2
2
2002
2002 2 1
1002
2 2002 1
1002
1002 2 2
2
2002
2 1001 2
1001
2002
2...

output:

2002
1001
1002
1002
2
1002
1002
2
2
2002
2002
1002
2002
2002
1002
1002
2
1001
1002
1002
2002
2002
2
1002
1002
1002
1002
2
1002
2
2002
1001
2
1002
2
1002
2
1001
1002
2
1002
1002
2
1002
2
2
2002
1002
2
2
1002
2002
2
1002
2002
2002
1002
1002
2
1002
2002
1002
1002
2002
2
2002
2
1002
2002
1002
2002
1002
...

result:

ok 

Test #36:

score: 10
Accepted
time: 42ms
memory: 3856kb

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
3
2003
1001
3003
4
3
2003
3003
1003
4
3
2003
1001
3003
4
3
1003
2003
3003
4
3
1003
3003
2003
4
3
1001
3003
2003
4
3
2002
1002
3003
4
3
3003
1003
2003
4
3
3003
2003
1003
4
3
3003
2002
1002

input:

1
66804
3 2002 2
1002
3003
3 2002 2
1002
3003
2003 3 2
3
3003
3 1003 1
1003
3 3003 2
1001
2003
2003 3003 2
3
3003
2003 3003 2
1003
3003
1003 2003 2
3
2003
3 2003 1
1003
1002 3003 2
3
2002
3 2003 2
1001
2003
2003 3 2
3
3003
2003 1003 2
1003
3003
1001 3 1
3
1003 3 2
3
2003
1001 3003 1
3
1001 3 1
3
200...

output:

1002
1002
3
1003
2003
3003
3003
2003
1003
3
2003
3
1003
3
3
3
3
3003
1003
2003
3003
3
1003
2003
2003
3
3
2003
2003
1001
3003
2003
2003
3
1003
2003
1003
2003
2003
1001
3
2003
1003
2003
1003
3
2003
2003
1003
2003
1002
1002
1001
1002
1002
2003
2003
2003
3003
3
1003
3
1003
1002
2003
3
2003
1001
1003
200...

result:

ok 

Test #37:

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

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
3
1003
2003
3003
4
3
1003
3003
2003
4
3
2003
1003
3003
4
3
3003
1003
2003
4
3
2003
3003
1003
4
3
3003
2003
1003
4
3
1001
2003
3003
4
3
1001
3003
2003
4
3
2002
1002
3003
4
3
2002
3003
1002

input:

1
120
2003 1003 2
1003
3003
2002 1002 1
1002
3003 2003 1
2003
3 3003 1
1003
1001 3003 1
3
1003 2003 2
3
2003
3003 2002 1
3
3 2003 1
1003
3 1003 1
1003
3003 1003 1
2003
2003 3 2
1003
3003
3003 2003 1
2003
3 2003 2
1001
2003
2003 3003 2
1003
3003
1003 3 2
3
2003
2002 3003 1
1002
2003 3 2
1003
3003
100...

output:

1003
1002
2003
1003
3
2003
3
1003
1003
2003
1003
2003
2003
3003
3
1002
1003
3
2003
3
2003
3003
2003
2003
3
1002
2003
3
1002
2003
1003
2003
2003
1003
1003
3
1003
1003
1003
1003
2003
2002
3003
2003
2003
3003
2003
3003
2003
2003
2003
1003
3
3
1002
3
1003
1003
2003
2003
1002
1003
3003
3
3003
1003
3
1003...

result:

ok 

Test #38:

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

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
5
1005
2005
3005
4005
5005
6
5
1005
2005
3005
5005
4005
6
5
1005
2005
4005
3005
5005
6
5
1005
2005
5005
3005
4005
6
5
1005
2005
4005
5005
3005
6
5
1005
2005
5005
4005
3005
6
5
1005
3005
2005
4005
5005
6
5
1005
3005
2005
5005
4005
6
5
1005
4005
2005
3005
5005
6
5
1005
5005
2005
3005
4005

input:

1
300
5 5005 1
1005
1005 5005 2
5
2005
2005 1005 2
1005
3005
4005 5005 2
3005
5005
3005 5 2
2005
4005
5 1005 1
1005
1005 5 2
5
2005
5 1005 1
1005
5 1005 1
1005
1005 3005 2
5
2005
3005 4005 2
2005
4005
5 4005 1
1005
5005 2005 1
4005
3005 5005 2
2005
4005
5 1005 1
1005
2005 5005 2
1005
3005
5 5005 1
1...

output:

1005
2005
1005
5005
2005
1005
5
1005
1005
2005
4005
1005
4005
4005
1005
3005
1005
3005
1005
4005
3005
2005
3005
2005
4005
2005
3005
1005
1005
2005
1005
3005
5
4005
5
4005
5
2005
4005
2005
2005
2005
1005
2005
5005
1005
4005
3005
3005
4005
1005
1005
3005
4005
3005
3005
1005
2005
1005
3005
4005
4005
40...

result:

ok 

Test #39:

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

input:

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

output:

3
2
1002
2002
3
2
2002
1002
3
2
1001
2002

input:

1
18
1002 2002 2
2
2002
1002 2 2
2
2002
1002 2 2
2
2002
2002 2 1
1002
2002 2 1
2
1001 2 1
2
2002 1002 1
1002
2002 1001 1
2
1002 2002 2
2
2002
2 1001 2
1001
2002
1001 2002 1
2
2 2002 1
1002
2 2002 1
1002
2 1002 1
1002
2002 1002 1
1002
2002 2 1
1002
2 1002 1
1002
2 2002 2
1001
2002

output:

2002
2
2
1002
2
2
1002
2
2002
1001
2
1002
1002
1002
1002
1002
1002
2002

result:

ok 

Test #40:

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

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
3
1003
3003
2002
4
3
3003
2002
1003
4
3
2003
1001
3003
4
3
1003
2002
3003
4
3
3003
1003
2003
4
3
2002
1003
3003
4
3
2003
1003
3003
4
3
3003
1003
2002
4
3
2002
1002
3003
4
3
3003
2002
1002

input:

1
66674
2002 1002 1
1002
2002 3003 1
1003
1003 2002 3
3
2002
3003
2002 3003 1
1003
1003 3003 2
3
2003
1003 2002 3
3
2002
3003
3 1001 2
1001
2003
1003 3 3
3
2002
3003
1003 2002 3
3
2002
3003
1003 2003 2
3
2003
3003 2003 1
2003
2003 1001 2
3
3003
3 3003 1
1003
3003 3 1
1003
3003 2002 1
3
3003 2002 1
3...

output:

1002
1003
2002
1003
2003
2002
1001
3
2002
2003
2003
3
1003
1003
3
3
1003
3
1003
1003
1003
1003
3
1003
3
3003
1003
1003
1003
3003
1002
1002
1003
1002
3
1003
3
1003
1003
1003
1003
1003
2003
2003
1003
1002
1003
1003
1003
1002
3
3
3003
1003
3
1003
3
1003
3003
1003
2003
1003
1003
1003
1003
1003
3
2002
3
...

result:

ok 

Test #41:

score: 10
Accepted
time: 52ms
memory: 4128kb

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
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001

input:

1
100000
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1001 1 1
1
1001 1 1
1
1 100...

output:

1
1
1001
1
1001
1001
1001
1
1001
1
1
1001
1001
1
1
1001
1001
1001
1001
1
1
1
1
1001
1
1001
1001
1
1
1001
1001
1001
1001
1001
1
1
1
1
1
1
1001
1
1001
1001
1
1001
1
1001
1
1001
1001
1001
1
1
1
1
1001
1
1
1
1001
1
1001
1
1
1001
1001
1
1
1
1001
1001
1
1001
1001
1
1
1
1
1001
1
1001
1001
1001
1
1001
1001
...

result:

ok 

Test #42:

score: 10
Accepted
time: 42ms
memory: 4120kb

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
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002

input:

1
75040
2002 1001 1
2
2002 2 1
2
1001 2 1
2
2 2002 2
1001
2002
1001 2002 1
2
1001 2 1
2
2 2002 2
1001
2002
2002 2 1
2
1001 2002 1
2
2 2002 2
1001
2002
1001 2002 1
2
2 1001 2
1001
2002
2 2002 2
1001
2002
2 2002 2
1001
2002
2 1001 2
1001
2002
1001 2002 1
2
2002 1001 1
2
2 2002 2
1001
2002
2002 2 1
2
2...

output:

2
2
2
2002
2
2
2002
2
2
2002
2
1001
2002
2002
1001
2
2
2002
2
2
2
2002
2002
2
1001
2
2
2
2
2
2
2002
2
2
2
2
2002
1001
2
1001
2
2
1001
2
2
1001
2002
2
2
1001
1001
2
2
1001
2
1001
1001
2002
2
2
2
1001
1001
1001
1001
2
2
2002
2
2
2002
2
1001
2002
2002
2
2
2
2
2
2
2
2002
2002
2002
2
2
2
2
1001
2
2
2002
...

result:

ok 

Test #43:

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

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
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002

input:

1
66554
1002 2002 2
3
2002
3 2002 2
1002
3003
3003 1002 1
3
2002 1002 1
1002
3003 2002 1
3
3 3003 2
1002
3003
2002 1002 1
1002
1002 2002 2
3
2002
3003 3 1
3
3003 1002 1
3
2002 1002 1
1002
2002 1002 1
1002
1002 3 2
3
2002
1002 3 2
3
2002
1002 3003 2
3
2002
3003 1002 1
3
3003 1002 1
3
1002 3 2
3
2002
...

output:

2002
1002
3
1002
3
3003
1002
2002
3
3
1002
1002
3
3
3
3
3
3
3
3003
1002
3
3
2002
3
1002
3
1002
3003
1002
1002
3
3
3
1002
2002
1002
2002
3
3
3
1002
3
1002
3
1002
1002
1002
3
3003
1002
3
3003
1002
3
3003
2002
1002
1002
3
3
1002
3
3
1002
3
3
3003
1002
1002
3003
1002
1002
1002
1002
3003
3
2002
3
3
1002
...

result:

ok 

Test #44:

score: 10
Accepted
time: 2ms
memory: 3856kb

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
6
5005
6006
1006
4004
2002
3003
7
6
4004
5005
1001
2002
3003
6006
7
6
6006
3003
4004
1002
2002
5005
7
6
1006
6006
5005
2003
4004
3003
7
6
2006
3003
1006
5005
4004
6006
7
6
5005
6006
1006
3003
4004
2004
7
6
3003
6006
5005
4004
1003
2002
7
6
1004
6006
4004
5005
3003
2002
7
6
3004
5005
1006
4004
6006...

input:

1
420
2004 6006 3
1006
3003
4004
6006 2003 1
1006
1002 4004 2
6
2002
5005 6 1
1006
4004 6006 1
6
2002 6006 1
1003
3003 4004 1
1004
4004 1006 1
2004
4004 5005 1
1006
2006 6006 5
1006
3003
4004
5005
6006
4004 6 1
1006
6 1006 1
1006
1006 6 5
6
2003
4004
5005
6006
2002 5005 1
1002
2002 3003 1
1004
2002 ...

output:

1006
1006
6
1006
6
1003
1004
2004
1006
6006
1006
1006
6
1002
1004
1006
1006
2006
6
1004
6
2006
6
1002
6
2006
1006
1006
6
1006
6
1004
1006
6
2006
6
3004
6
3003
2003
1006
5005
2006
1002
1004
6
2004
6
1004
6
2006
2006
3004
6
6
6
2002
6
6
2006
1006
2006
6
1006
6
6
6
1006
1002
1006
2006
6
1001
1006
2004
...

result:

ok 

Test #45:

score: 10
Accepted
time: 2ms
memory: 3768kb

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
6
6006
4004
5005
3004
2004
1006
7
6
1003
4004
3003
6006
2003
5005
7
6
3005
4004
6006
1006
5005
2006
7
6
4004
6006
5005
3003
1005
2004
7
6
1005
4004
2004
3003
5005
6006
7
6
4005
6006
1003
3003
2002
5005
7
6
2002
5006
3004
1002
4004
6006
7
6
6006
1003
5005
3003
4005
2003
7
6
5005
1006
2006
4005
6006...

input:

1
420
1003 2002 3
6
2002
3003
4004 2004 1
2004
3005 6006 3
2006
4004
5005
4005 6006 2
6
5005
6006 5005 1
2006
4004 2002 1
3004
6006 2003 1
6
5005 6 1
4005
6 3004 1
1006
1005 4004 3
6
2004
5005
5005 6 1
1005
6 1005 2
1005
6006
1005 6 3
6
2004
5005
5005 6006 1
4005
4005 6006 2
6
5005
2004 4004 2
1006
...

output:

2002
2004
2006
6
2006
3004
6
4005
1006
2004
1005
1005
6
4005
6
3004
2004
2004
6
1003
3005
3006
3005
1006
6
1005
1006
6
2006
6
2003
6
2004
6
4004
6006
1006
2002
6
2004
1006
6006
3006
4005
5005
2003
4005
6
6
1002
3006
3006
1006
2006
6
3006
4005
6
3005
1005
1005
2004
2006
6
1006
4005
6
6
4005
1005
2004...

result:

ok 

Test #46:

score: 10
Accepted
time: 2ms
memory: 4128kb

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
6
2002
6006
4006
1003
3003
5006
7
6
2005
5005
6006
1006
3005
4005
7
6
1005
6006
5005
2005
4005
3005
6
5
4004
5005
2002
1005
3003
6
5
4004
3003
2002
1005
5005
6
5
2002
1002
4004
5005
3003
6
5
3003
2002
5005
1002
4004
6
5
2005
1005
5005
3003
4004
6
5
5005
4004
3003
1005
2004
6
5
1005
4004
5005
2005
...

input:

1
336
5 5005 4
1002
3003
4004
5005
1005 5 5
5
2002
3003
4004
5005
3005 4005 2
2005
4005
1002 5005 2
5
2002
4005 5005 2
3005
5005
5 1005 1
1005
1005 4004 2
5
2005
2005 1005 4
1005
3003
4004
5005
4006 5006 2
6
5006
3003 2002 1
1005
5 1005 1
1005
3003 4004 1
1005
1005 3003 5
5
2002
3003
4004
5005
1005 ...

output:

5005
5
4005
5
5005
1005
2005
1005
5006
1005
1005
1005
3003
2005
5005
4006
4006
5
1006
2005
1005
5
4005
1005
3005
1002
6
5
2005
1005
3004
2004
4006
1005
1005
1002
1005
2005
2005
2002
4006
4006
1005
5
3004
4005
2005
2005
2005
2004
1006
1006
2005
2005
6
4004
1005
2005
4005
3003
1005
2002
6
5
5
2005
200...

result:

ok 

Test #47:

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

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
5
3004
4004
5005
1002
2002
6
5
3003
5005
1003
2002
4005
6
5
4004
2004
3003
1004
5005
6
5
2004
1004
4004
5005
3004
5
4
4004
2002
3003
1004
5
4
4004
1004
3003
2002
5
4
3003
1003
4004
2002
5
4
4004
2004
3003
1004
5
4
4004
3003
2003
1004
5
4
2004
3004
4004
1004

input:

1
240
3003 4 1
2003
4 2002 1
1004
2004 5 2
1004
3004
3004 2004 2
2004
4004
5 1004 2
1004
5005
4 4004 1
1004
1003 4004 3
4
2002
3003
3003 2002 1
1004
4004 5005 1
3004
3003 1003 1
1003
2002 4004 1
1004
4004 2002 1
1004
4 4004 1
1004
1004 3004 2
5
2004
5005 4004 1
5
3004 1002 2
5
4004
1003 3003 3
5
200...

output:

2003
1004
1004
2004
1004
1004
4
1004
3004
1003
1004
1004
1004
2004
5
5
3003
2004
5005
3004
3004
1004
5
5
5
2004
3004
1004
3004
1003
1004
1003
5
2004
4
1004
1003
5
3003
1004
5
5
2002
4
4005
1004
1004
5
5
2004
1003
1004
5
1004
2004
1002
5
2004
5
4
1004
2004
5
4004
1004
1003
1004
2004
5
1004
1004
3004
...

result:

ok 

Test #48:

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

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
3
3003
1003
2002
4
3
1001
2002
3003
4
3
3003
1003
2003
3
2
1002
2002
3
2
1001
2002
2
1
1001

input:

1
50
3003 3 1
3
1001 2002 1
2
3003 2003 1
2003
1001 2 1
2
3 2002 1
1003
2 2002 2
1001
2002
2002 1001 1
2
2002 3003 1
1003
1003 3003 2
3
2003
2 1001 2
1001
2002
1003 3 3
3
2002
3003
1001 3 1
3
3003 1003 1
1003
2002 1003 1
1003
2002 3 1
3
3 3003 1
1003
3003 3 1
2003
1002 2002 2
2
2002
1001 1 1
1
1003 ...

output:

3
2
2003
2
1003
2002
2
1003
2003
1001
3
3
1003
1003
3
1003
2003
2002
1
2003
3
3003
1001
2
1002
3003
1003
1003
1001
1003
2002
3
1003
1003
3
3
1003
3
3
3
1003
1003
1002
2002
2003
1003
1002
1002
3003
2

result:

ok 

Test #49:

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

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
7
4007
5007
1001
7007
3007
2007
6007
8
7
6006
4004
5006
3003
7007
2002
1007
8
7
1004
5007
2003
4004
6006
7007
3003
8
7
2007
4004
6006
3007
7007
1001
5005
8
7
7007
2002
5005
6006
3003
1007
4004
8
7
5005
2002
7007
6006
3003
4004
1007
8
7
1007
2007
4007
7007
5007
6006
3007
8
7
1006
6006
7007
5005
400...

input:

1
57240
7007 3007 1
3007
1007 7007 2
7
2007
2007 5007 2
7
3007
7007 2007 1
6007
7007 6006 1
3007
6006 7007 1
1007
6006 5005 1
1006
6006 3007 1
3007
7007 7 1
6007
4004 2002 1
1007
7007 1007 1
1007
7 1007 1
1007
5007 1007 3
4007
6006
7007
7 6006 1
1007
3007 4007 2
2007
4007
2002 6006 1
1007
2003 7 2
1...

output:

3007
2007
3007
6007
3007
1007
1006
3007
6007
1007
1007
1007
4007
1007
4007
1007
1004
5007
5007
1007
1007
3007
1007
5005
4007
2005
3007
3007
2005
6007
4007
4007
1007
3007
1007
5007
3007
7007
1007
5007
1007
1007
1007
4007
1007
1007
2007
1007
1007
1007
4007
7
5005
5007
2007
3007
1007
4007
1007
1007
500...

result:

ok 

Test #50:

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

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
7
1007
5005
2002
3003
7007
4004
6006
8
7
6007
4005
3003
1003
2003
7007
5005
8
7
3003
6006
7007
2004
1004
5007
4004
8
7
3006
2002
1007
6006
4006
7007
5006
8
7
1006
2006
4006
3006
5006
6006
7007
8
7
4006
3006
1006
2006
6006
5006
7007
8
7
5005
7007
4005
2002
1001
3005
6006
8
7
6006
7007
2002
1007
300...

input:

1
56820
7007 4005 1
6007
4004 2002 1
1007
7007 2006 1
7
2007 6006 6
1007
3003
4004
5005
6006
7007
5007 7007 3
7
6006
7007
7 5006 1
1007
2004 4004 3
1004
3003
4004
4006 2006 2
3006
5006
5005 7 1
1007
7007 3003 1
5007
5005 4005 1
4005
4004 2002 1
1007
6006 3006 1
5006
6006 4004 1
1007
5005 3003 1
2007...

output:

6007
1007
7
6006
7007
1007
4004
3006
1007
5007
4005
1007
5006
1007
2007
1006
2004
5007
7
1007
1007
4006
1007
1007
2006
1004
1007
1007
4004
6006
1004
4005
2006
1007
4005
4004
7
3006
4006
2007
1007
1007
1007
1004
1006
5007
7
1007
7
1007
1006
1007
5007
1007
5006
1007
1007
1002
1007
6007
7
1006
7
4006
7...

result:

ok 

Test #51:

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

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
7
1007
4007
6007
3007
7007
2002
5007
8
7
4004
2002
7007
1007
3003
5005
6006
8
7
4007
7007
6007
3007
5007
2007
1001
8
7
4004
7007
6006
1006
3003
2002
5005
8
7
6006
4007
2002
3007
7007
1002
5007
8
7
5007
2004
6007
3004
1004
7007
4004
8
7
6006
7007
5005
2002
3006
4004
1007
8
7
6006
2002
3003
1007
500...

input:

1
57000
6006 2005 1
1007
7 6007 2
1004
5007
5005 4004 1
2005
2004 7 2
1004
3004
7007 3003 1
1007
6006 5005 1
1007
1007 2002 3
7
2002
3007
1007 7007 4
7
2005
6006
7007
5007 4007 3
4007
6006
7007
1002 7007 2
7
2002
2002 4007 1
1007
1002 7007 2
7
2002
3003 4004 1
1006
7 3003 1
1007
5005 4004 1
1006
100...

output:

1007
5007
2005
1004
1007
1007
2002
7007
4007
7
1007
7
1006
1007
1006
7
4007
5007
7
1006
1007
3007
3004
1007
5007
1004
1007
7
7007
7
7
2003
2002
1007
1007
1007
5007
7007
1007
7
1007
2003
4007
3004
2003
1004
1007
1007
2004
2005
1003
1007
1006
5007
3004
1007
2005
1006
1007
4007
1007
5007
7
3006
1007
10...

result:

ok 

Test #52:

score: 10
Accepted
time: 30ms
memory: 4116kb

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
7
1007
4007
6007
3007
7007
2002
5007
8
7
4004
2002
7007
1007
3003
5005
6006
8
7
4007
7007
6007
3007
5007
2007
1001
8
7
4004
7007
6006
1006
3003
2002
5005
8
7
6006
4007
2002
3007
7007
1002
5007
8
7
5007
2004
6007
3004
1004
7007
4004
8
7
6006
7007
5005
2002
3006
4004
1007
8
7
6006
2002
3003
1007
500...

input:

1
57000
6006 2005 1
1007
7 6007 2
1004
5007
5005 4004 1
2005
2004 7 2
1004
3004
7007 3003 1
1007
6006 5005 1
1007
1007 2002 3
7
2002
3007
1007 7007 4
7
2005
6006
7007
5007 4007 3
4007
6006
7007
1002 7007 2
7
2002
2002 4007 1
1007
1002 7007 2
7
2002
3003 4004 1
1006
7 3003 1
1007
5005 4004 1
1006
100...

output:

1007
5007
2005
1004
1007
1007
2002
7007
4007
7
1007
7
1006
1007
1006
7
4007
5007
7
1006
1007
3007
3004
1007
5007
1004
1007
7
7007
7
7
2003
2002
1007
1007
1007
5007
7007
1007
7
1007
2003
4007
3004
2003
1004
1007
1007
2004
2005
1003
1007
1006
5007
3004
1007
2005
1006
1007
4007
1007
5007
7
3006
1007
10...

result:

ok 

Test #53:

score: 10
Accepted
time: 30ms
memory: 4116kb

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
7
1007
4007
6007
3007
7007
2002
5007
8
7
4004
2002
7007
1007
3003
5005
6006
8
7
4007
7007
6007
3007
5007
2007
1001
8
7
4004
7007
6006
1006
3003
2002
5005
8
7
6006
4007
2002
3007
7007
1002
5007
8
7
5007
2004
6007
3004
1004
7007
4004
8
7
6006
7007
5005
2002
3006
4004
1007
8
7
6006
2002
3003
1007
500...

input:

1
57000
6006 2005 1
1007
7 6007 2
1004
5007
5005 4004 1
2005
2004 7 2
1004
3004
7007 3003 1
1007
6006 5005 1
1007
1007 2002 3
7
2002
3007
1007 7007 4
7
2005
6006
7007
5007 4007 3
4007
6006
7007
1002 7007 2
7
2002
2002 4007 1
1007
1002 7007 2
7
2002
3003 4004 1
1006
7 3003 1
1007
5005 4004 1
1006
100...

output:

1007
5007
2005
1004
1007
1007
2002
7007
4007
7
1007
7
1006
1007
1006
7
4007
5007
7
1006
1007
3007
3004
1007
5007
1004
1007
7
7007
7
7
2003
2002
1007
1007
1007
5007
7007
1007
7
1007
2003
4007
3004
2003
1004
1007
1007
2004
2005
1003
1007
1006
5007
3004
1007
2005
1006
1007
4007
1007
5007
7
3006
1007
10...

result:

ok 

Subtask #5:

score: 26.3205
Acceptable Answer

Test #54:

score: 26.3205
Acceptable Answer
time: 42ms
memory: 4112kb

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
2
1002
2002
998
997
335997
316997
714997
920997
140203
630997
933997
216997
527997
182203
685997
236997
715997
631997
880997
174203
128203
921997
52203
385997
89203
748997
560997
574997
62203
185203
948997
364997
634997
258997
946997
620997
816997
537997
257997
439997
719997
796997
282997
12203
49...

input:

1
59797
2003 3003 2
1003
3003
532759 626759 2
531759
533759
1001 1 1
1
84099 51099 2
83099
85099
214487 920998 2
213487
215487
1003 3 2
3
2003
1003 3003 2
3
2003
321997 617997 2
320997
322997
944998 542998 2
943998
945998
575996 725996 2
574996
576996
1 1001 1
1001
503759 511759 2
502759
504759
3977...

output:

3003
533759
1
83099
213487
3
2003
322997
943998
576996
1001
504759
396759
251997
2
330996
516999
26099
9009
176999
941999
1
1003
561998
189203
905999
832998
948999
652997
1001
2
214999
230996
1002
17759
31099
94203
987999
68099
1
1002
1001
741998
275996
1
647759
695999
626759
543998
8009
1001
106146...

result:

points 0.43148441690 max label = 999999

Test #55:

score: 26.3205
Acceptable Answer
time: 38ms
memory: 3828kb

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
996
246265
245265
327996
857996
406996
918996
323996
58265
354996
972996
112265
242265
824996
562996
596996
6265
400996
756996
876996
688996
61265
186265
683996
655996
813996
906996
332996
926996
358996
527996
605996
856996
339996
567996
754996
953996
872996
366996
106265
878996
388996
479996
71...

input:

1
50045
435777 793990 2
434777
436777
634754 670754 2
633754
635754
568997 927997 2
567997
569997
535991 259991 2
534991
536991
776996 348996 2
775996
777996
379754 596754 2
378754
380754
475754 682754 2
474754
476754
576999 492999 2
575999
577999
345591 732998 2
344591
346591
260603 868994 2
259603...

output:

434777
635754
569997
534991
775996
380754
476754
575999
344591
259603
701997
345754
834991
734999
758991
776998
874998
621997
448999
752777
804997
276997
796995
987994
847996
193231
552754
301777
286754
585999
514578
278999
252265
490564
67564
120265
85118
104603
485603
371564
73578
996
757998
24799...

result:

points 0.43148441690 max label = 999999

Test #56:

score: 50
Acceptable Answer
time: 54ms
memory: 3832kb

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
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001

input:

1
100000
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1...

output:

1001
1001
1001
1
1001
1001
1001
1001
1001
1001
1
1001
1
1001
1
1
1001
1001
1
1001
1001
1001
1
1
1
1
1
1
1001
1001
1
1001
1001
1001
1001
1
1001
1
1001
1001
1
1001
1
1001
1
1001
1001
1001
1001
1001
1
1001
1
1
1001
1001
1
1001
1
1001
1001
1001
1001
1001
1001
1001
1001
1
1
1
1
1
1
1001
1
1001
1001
1001
...

result:

points 0.81967213110 max label = 1001

Test #57:

score: 49.9962
Acceptable Answer
time: 44ms
memory: 3828kb

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
2
2002
1001
3
2
1002
2002
3
2
1002
2002
3
2
2002
1001
3
2
1002
2002
3
2
2002
1002
3
2
2002
1002
3
2
1002
2002
3
2
2002
1001
3
2
2002
1001

input:

1
74928
2 2002 1
1002
2 2002 1
1002
1002 2 2
2
2002
2002 1002 1
1002
2002 2 1
1002
2002 2 1
1002
1001 2002 1
2
2002 1002 1
1002
2 2002 2
1001
2002
2002 2 1
2
2002 1001 1
2
2 1002 1
1002
2002 2 1
1002
1002 2002 2
2
2002
2002 1001 1
2
2002 2 1
1002
2 2002 1
1002
2 2002 2
1001
2002
1001 2 1
2
1001 2 1
...

output:

1002
1002
2
1002
1002
1002
2
1002
2002
2
2
1002
1002
2002
2
1002
1002
2002
2
2
1002
2002
2002
1002
2
1002
1002
1002
2002
1002
1001
1002
1002
1002
2
2
1002
1002
2002
1001
1002
1002
2
1002
2002
1002
2002
2
1002
1002
1002
2
1002
2002
2
2
2002
1002
2
1002
2002
1002
2002
2002
1002
2
1002
2002
1002
1002
2...

result:

points 0.81960969860 max label = 2002

Test #58:

score: 48.4513
Acceptable Answer
time: 44ms
memory: 3792kb

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
3
2003
1003
3003
4
3
2003
3003
1001
4
3
3003
2002
1002
4
3
3003
2003
1003
4
3
2002
3003
1002
4
3
3003
2002
1002
4
3
1003
3003
2003
4
3
1002
2002
3003
4
3
1003
3003
2003
4
3
1002
2002
3003

input:

1
66734
2002 3 1
1002
2003 1003 2
1003
3003
1002 2002 2
3
2002
2003 3 2
3
3003
1002 2002 2
3
2002
2003 3 2
1003
3003
1002 3 2
3
2002
2003 1003 2
1003
3003
3 2002 2
1002
3003
2002 3003 1
1002
2002 3 1
1002
3 1002 2
1002
3003
2002 1002 1
1002
3 2002 2
1002
3003
2003 1001 2
3
3003
3003 3 1
3
3003 2003 ...

output:

1002
1003
2002
3
2002
1003
3
1003
1002
1002
1002
1002
1002
1002
3
3
2003
2003
1003
2003
3
1002
1002
3
2003
1002
3
1003
3003
3
2003
3
1003
1003
3
2003
2003
1002
3
3
3
1002
3
2003
2003
3
3
3
3003
3
1002
3003
3
2003
2003
3
1003
3
1001
3
2003
2003
1003
2003
2003
3
3
3
2003
2002
2002
2003
1002
2003
3
200...

result:

points 0.79428282420 max label = 3003

Test #59:

score: 26.3205
Acceptable Answer
time: 38ms
memory: 3852kb

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
999
719999
388503
683999
553999
509999
889999
448503
122503
386503
954999
634999
56503
464503
145503
813999
505999
682999
959999
411503
678999
479503
994999
271503
533999
294503
272503
896999
626999
838999
378503
104503
921999
932999
232503
603999
366503
513999
471503
707999
546999
207503
22350...

input:

1
50038
618999 631999 2
617999
619999
678999 709999 2
677999
679999
83953 516953 2
82953
84953
918999 799999 2
917999
919999
334953 977999 2
333953
335953
719953 786953 2
718953
720953
952999 690999 2
951999
953999
529999 242999 2
528999
530999
391999 345999 2
390999
392999
610999 60503 2
609999
611...

output:

619999
679999
84953
917999
333953
720953
951999
528999
390999
609999
538999
610999
966999
314999
27252
24370
270953
927999
828999
685999
668999
517999
356379
304503
611953
219370
160999
377999
46999
919999
232503
715999
239370
313999
972999
409999
810999
809999
283999
659999
566999
350401
940999
812...

result:

points 0.43148441690 max label = 999999

Test #60:

score: 26.3205
Acceptable Answer
time: 38ms
memory: 3824kb

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
999
53557
159557
58557
981999
376557
398557
17557
881999
580999
987999
253557
243557
350557
200557
598999
749999
649999
67557
417557
209557
858999
250557
105557
452557
161557
776999
370557
835999
330557
314557
10557
971999
290557
493557
923999
266557
316557
262557
901999
682999
527557
450557
83...

input:

1
50048
15557 70557 2
14557
16557
780999 507557 2
779999
781999
335557 596999 2
334557
336557
397557 25557 2
396557
398557
565999 476557 2
564999
566999
423557 485557 2
422557
424557
739999 59557 2
738999
740999
40557 852999 2
39557
41557
4557 543557 2
3557
5557
667999 841999 2
666999
668999
185557 ...

output:

16557
779999
334557
396557
564999
424557
738999
39557
5557
668999
184557
398557
708999
200557
526557
367557
163557
396557
686999
880999
444557
228557
926999
685999
2557
492557
76557
413557
977999
513557
440557
688999
710999
115557
859999
548557
223557
191557
955999
762999
956999
616999
861999
819999...

result:

points 0.43148441690 max label = 999999

Test #61:

score: 48.4513
Acceptable Answer
time: 0ms
memory: 3708kb

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
3
1003
2003
3003
4
3
1003
3003
2003
4
3
2003
1003
3003
4
3
3003
1003
2003
4
3
2003
3003
1003
4
3
3003
2003
1003
4
3
1001
2003
3003
4
3
1001
3003
2003
4
3
2002
1002
3003
4
3
2002
3003
1002

input:

1
120
3003 1001 1
2003
1003 3003 2
3
2003
3003 1003 1
2003
3 2003 1
1003
3003 1003 1
2003
3 3003 2
1002
3003
1003 2003 2
3
2003
1002 2002 2
3
2002
1001 3 1
3
3003 3 1
2003
3 3003 1
1003
2003 1003 2
1003
3003
1003 2003 2
3
2003
2003 1001 2
3
3003
3 1003 1
1003
1003 3 2
3
2003
3 1003 1
1003
2003 3 2
1...

output:

2003
2003
2003
1003
2003
3003
2003
2002
3
2003
1003
1003
2003
3
1003
3
1003
1003
3
1003
1002
3
1003
1003
3
1002
3
3
3003
1001
2003
2003
3
3003
1002
1003
2002
2003
2003
1003
1003
2003
3
2003
3
2003
2003
3003
2003
1003
1003
3
1003
1002
3003
3
2003
3
2003
1002
1003
2003
3
2003
3
1003
3
2003
3003
3003
1...

result:

points 0.79428282420 max label = 3003

Test #62:

score: 46.5049
Acceptable Answer
time: 0ms
memory: 3816kb

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
5
1005
2005
3005
4005
5005
6
5
1005
2005
3005
5005
4005
6
5
1005
2005
4005
3005
5005
6
5
1005
2005
5005
3005
4005
6
5
1005
2005
4005
5005
3005
6
5
1005
2005
5005
4005
3005
6
5
1005
3005
2005
4005
5005
6
5
1005
3005
2005
5005
4005
6
5
1005
4005
2005
3005
5005
6
5
1005
5005
2005
3005
4005

input:

1
300
5 3005 1
1005
4005 1005 2
3005
5005
1005 3005 2
5
2005
2005 5 2
1005
3005
5 5005 1
1005
5005 2005 1
4005
4005 2005 2
3005
5005
1005 3005 2
5
2005
5005 3005 1
4005
4005 5 2
3005
5005
5 2005 1
1005
4005 5 2
3005
5005
4005 5 2
3005
5005
1005 4005 2
5
2005
2005 4005 2
1005
3005
4005 5 2
3005
5005
...

output:

1005
3005
2005
1005
1005
4005
3005
2005
4005
3005
1005
3005
3005
2005
3005
3005
4005
5005
1005
1005
3005
4005
1005
1005
1005
2005
1005
4005
1005
3005
4005
3005
2005
1005
3005
4005
3005
4005
1005
1005
3005
4005
1005
4005
4005
5
2005
4005
5
3005
1005
1005
2005
1005
3005
2005
2005
4005
2005
2005
3005
3...

result:

points 0.7623747360 max label = 5005

Test #63:

score: 49.9962
Acceptable Answer
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
2
1002
2002
3
2
2002
1002
3
2
1001
2002

input:

1
18
1002 2 2
2
2002
1001 2 1
2
1002 2002 2
2
2002
2 1002 1
1002
2002 2 1
1002
2 1002 1
1002
2 1001 2
1001
2002
1002 2 2
2
2002
2002 1002 1
1002
2002 2 1
2
1002 2002 2
2
2002
1001 2002 1
2
2 2002 1
1002
2 2002 1
1002
2002 1002 1
1002
2 2002 2
1001
2002
2002 2 1
1002
2002 1001 1
2

output:

2
2
2002
1002
1002
1002
1001
2
1002
2
2002
2
1002
1002
1002
2002
1002
2

result:

points 0.81960969860 max label = 2002

Test #64:

score: 26.3205
Acceptable Answer
time: 38ms
memory: 3900kb

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
996
1511
512996
2256
257511
513767
768996
3129
130256
258384
385511
514640
641767
769895
896996
4066
67129
131193
194256
259321
322384
386448
449511
515577
578640
642704
705767
770832
833895
897959
960996
5035
36066
68098
99129
132162
163193
195225
226256
260290
291321
323353
354384
387417
41844...

input:

1
49888
707721 394394 3
706736
708714
715721
183183 375377 1
181183
775775 207207 1
774776
751751 396402 1
750752
475477 693693 3
474480
476476
477477
450480 800800 3
449511
451465
466480
224224 821821 1
223225
962974 564570 3
961981
963969
970974
949949 286286 1
947949
544546 935937 3
540546
545545...

output:

706736
181183
774776
750752
474480
449511
223225
961981
947949
540546
490496
581587
893895
769895
646648
862864
484486
5035
452458
23025
506508
387417
981983
942944
307321
750752
705767
914928
572574
897959
165171
978981
269275
36066
957959
235241
453455
889895
513767
235241
463465
787801
187193
684...

result:

points 0.43148441690 max label = 999999

Test #65:

score: 26.3205
Acceptable Answer
time: 28ms
memory: 3816kb

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
511
1256
257511
2129
130256
258384
385511
3066
67129
131193
194256
259321
322384
386448
449511
4035
36066
68098
99129
132162
163193
195225
226256
260290
291321
323353
354384
387417
418448
450480
481511
5020
21035
37051
52066
69083
84098
100114
115129
133147
148162
164178
179193
196210
211225
227...

input:

1
59652
9009 22024 1
7009
248248 411417 1
247249
2002 3003 1
1002
1 1001 1
1001
93093 20026 1
91093
1002 2002 2
3
2002
1 1001 1
1001
1001 1 1
1
1 1001 1
1001
481495 227233 3
480510
482488
489495
301303 473473 3
300306
302302
303303
2033 80080 3
1064
3018
19033
2002 2 1
2
610640 502504 3
578640
61162...

output:

7009
247249
1002
1001
91093
2002
1001
1
1001
480510
300306
1064
2
578640
93095
6008
1001
36038
65127
127129
101103
1002
2
389395
2008
131193
18024
28030
14016
1001
292298
2
1001
2002
241255
3
1001
10016
141147
2
126128
62064
19021
660666
407409
1002
3
60066
1001
2002
1002
71073
10012
2
29031
1001
3
...

result:

points 0.43148441690 max label = 999999

Test #66:

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

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
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001
2
1
1001

input:

1
100000
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1001 1 1
1
1001 1 1
1
1 1001 1
1001
1001 1 ...

output:

1
1
1001
1001
1001
1001
1001
1001
1
1
1001
1001
1001
1001
1001
1001
1
1
1001
1
1
1001
1
1
1001
1
1001
1001
1
1001
1
1
1
1001
1
1
1
1001
1001
1
1
1001
1
1001
1
1
1
1
1001
1001
1
1001
1001
1001
1
1
1001
1
1001
1
1001
1001
1001
1
1001
1
1001
1001
1001
1
1001
1
1
1001
1
1001
1
1
1001
1001
1
1
1001
1001
...

result:

points 0.81967213110 max label = 1001

Test #67:

score: 49.9962
Acceptable Answer
time: 42ms
memory: 4128kb

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
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002
3
2
1001
2002

input:

1
74942
1001 2 1
2
1001 2 1
2
2 2002 2
1001
2002
2 2002 2
1001
2002
1001 2 1
2
1001 2 1
2
2002 2 1
2
1001 2 1
2
1001 2 1
2
1001 2002 1
2
1001 2 1
2
1001 2002 1
2
2002 2 1
2
2 1001 2
1001
2002
2 1001 2
1001
2002
2002 2 1
2
2 1001 2
1001
2002
2 2002 2
1001
2002
2002 1001 1
2
2 1001 2
1001
2002
2002 2 ...

output:

2
2
2002
2002
2
2
2
2
2
2
2
2
2
1001
1001
2
1001
2002
2
1001
2
2
2
2
2
2002
2002
2
2
2
2
2
2
2
1001
2
2
2002
2
1001
1001
2
1001
2
2002
2
2
2002
2002
2
2
2
2
1001
2002
2
2
1001
1001
1001
1001
2
2
2002
2
1001
2002
2
2
2002
2
2002
2
2002
2
2
2
2
2
2
2
2
1001
2
2
2
2
2
2
2002
2002
2
2
2
2002
2002
2
2
2
...

result:

points 0.81960969860 max label = 2002

Test #68:

score: 48.4513
Acceptable Answer
time: 34ms
memory: 3840kb

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
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002
4
3
1002
3003
2002

input:

1
66795
3 1002 2
1002
3003
3003 3 1
3
1002 3 2
3
2002
3 1002 2
1002
3003
1002 3003 2
3
2002
3003 1002 1
3
3 3003 2
1002
3003
3 1002 2
1002
3003
3 3003 2
1002
3003
3 2002 2
1002
3003
2002 3003 1
1002
3 2002 2
1002
3003
2002 3 1
1002
1002 3003 2
3
2002
3003 3 1
3
3 1002 2
1002
3003
2002 1002 1
1002
20...

output:

1002
3
3
1002
3
3
3003
1002
3003
1002
1002
1002
1002
3
3
1002
1002
1002
3
1002
3
1002
3
1002
1002
2002
2002
1002
3
3
3
3
2002
1002
1002
1002
1002
1002
3003
3
2002
1002
2002
1002
3
1002
3003
3
3
3
3
1002
1002
1002
3003
1002
3
3
3003
1002
1002
1002
3
3
1002
1002
1002
1002
3
1002
3
3
3
3003
3
1002
3
10...

result:

points 0.79428282420 max label = 3003

Test #69:

score: 26.3205
Acceptable Answer
time: 40ms
memory: 3884kb

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
999
1511
512999
2256
257511
513767
768999
3129
130256
258384
385511
514640
641767
769895
896999
4066
67129
131193
194256
259321
322384
386448
449511
515577
578640
642704
705767
770832
833895
897959
960999
5035
36066
68098
99129
132162
163193
195225
226256
260290
291321
323353
354384
387417
4184...

input:

1
50098
722736 428430 3
706736
723729
730736
545545 839839 1
544546
756756 280280 1
755757
192192 764764 1
191193
171171 741741 1
169171
974976 713713 3
970976
975975
976976
570570 912912 1
568570
806806 361361 1
805807
76076 268268 1
74076
4066 605605 3
3129
5035
36066
576576 369369 1
575577
430430...

output:

706736
544546
755757
191193
169171
970976
568570
805807
74076
3129
575577
428430
244246
513767
850864
135137
451465
60066
505511
23025
244246
475477
835849
109111
731733
743745
997999
947949
619625
556562
716718
333335
513767
722736
626640
38044
204210
276290
436438
260290
133147
645651
273275
57864...

result:

points 0.43148441690 max label = 999999

Test #70:

score: 48.4513
Acceptable Answer
time: 42ms
memory: 3828kb

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
3
1001
3003
2002
4
3
3003
1003
2003
4
3
2002
1003
3003
4
3
3003
2003
1003
4
3
2002
1003
3003
4
3
1001
3003
2003
4
3
3003
2003
1003
4
3
3003
2002
1003
4
3
3003
1002
2002
4
3
2002
1003
3003

input:

1
66444
2003 1003 2
1003
3003
1003 3003 2
3
2003
3003 1001 1
2003
3 3003 1
1003
1003 3 3
3
2002
3003
2003 3003 2
1003
3003
3003 1003 1
1003
3003 3 1
2003
3003 2003 1
2003
1003 2002 3
3
2002
3003
3 2003 1
1003
3 3003 2
1002
3003
2002 1001 1
3
3003 2003 1
2003
2002 1001 1
3
1002 2002 2
3
2002
3003 200...

output:

1003
2003
2003
1003
3
3003
1003
2003
2003
2002
1003
3003
3
2003
3
2002
3
1003
2002
1003
1001
1003
1003
2002
1003
1003
1003
2003
3
1003
1003
3
1003
3
3003
3
2002
2002
2003
1003
3003
1003
2003
3
1003
3
1003
1003
1003
3
1003
1003
2003
1002
2003
2003
1003
1003
3
1003
1003
2003
2002
2003
1003
1003
1003
1...

result:

points 0.79428282420 max label = 3003

Test #71:

score: 26.3205
Acceptable Answer
time: 38ms
memory: 4120kb

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
999
424999
553999
181328
542999
462999
441999
314328
8328
455999
584999
103328
243328
464999
753999
80328
655999
433999
521999
543999
19328
896999
317328
809999
200328
960999
374999
880999
831999
147328
276328
993997
491999
548999
484999
418999
415999
427999
961999
759999
828999
836999
835999
8...

input:

1
50431
830999 228328 2
829999
831999
351371 474486 2
350371
352371
950950 575575 1
37999
129328 970999 2
128328
130328
651651 930959 1
101987
885999 853999 2
884999
886999
805815 739755 2
804815
806815
2426 918999 2
1426
3426
616623 181193 2
615623
617623
977987 237250 2
976987
978987
48405 755999 ...

output:

829999
350371
37999
128328
101987
884999
804815
1426
615623
976987
47405
985999
812999
582999
101987
101987
594598
983998
958999
363526
144192
101987
285290
101987
817999
333385
297306
668769
417452
669999
850855
479999
477487
900999
933999
556999
1001
428452
511999
774999
633645
611620
64987
135405...

result:

points 0.43148441690 max label = 999999

Test #72:

score: 26.3205
Acceptable Answer
time: 40ms
memory: 4128kb

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
999
289999
48195
492647
364647
616647
41195
22195
443647
568647
723999
188195
459647
985999
642647
861999
151195
259999
431647
838999
315999
124195
375647
321999
306999
669999
747999
311999
507647
605647
857999
808999
864999
365647
900999
580647
324999
893999
165195
590647
446647
368647
448647
...

input:

1
51725
931999 525703 2
930999
932999
403999 23072 2
402999
404999
710720 683720 2
709720
711720
856856 676720 1
855856
15015 296296 1
1999
394703 126703 2
393703
395703
304306 881881 2
303306
305306
381508 399508 2
380508
382508
597613 279299 2
596613
598613
754774 26027 2
753774
755774
12012 79279...

output:

930999
402999
709720
855856
1999
393703
303306
382508
596613
753774
1999
891999
585703
1999
745999
796845
393703
998999
391703
692719
555559
977978
5626
1999
1999
719723
564626
591999
1999
300626
48055
562565
763774
895909
359361
500647
214720
539720
587613
995998
577999
567703
992998
993999
165999
...

result:

points 0.43148441690 max label = 999999

Test #73:

score: 26.3205
Acceptable Answer
time: 30ms
memory: 3812kb

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
999
164173
651656
366378
372378
292317
214243
346349
502509
491509
284317
228243
335349
378378
142154
868874
937959
112115
728754
92115
662688
920959
665688
34041
492509
551554
544554
13986
367378
406418
143154
244279
727727
526554
296317
872874
340349
408418
421450
343349
757782
664688
341349
...

input:

1
49651
907912 630656 2
906912
908912
874874 431450 1
873874
268279 421450 2
267279
269279
450450 677688 1
449450
817817 297317 1
816817
655656 583586 2
654656
656656
441450 919959 2
440450
442450
258279 962986 2
257279
259279
102115 317317 2
101115
103115
479488 77080 2
478488
480488
385418 364378 ...

output:

906912
873874
267279
449450
816817
654656
440450
257279
101115
478488
384418
38041
534554
286317
151154
646656
981986
827851
708727
18986
887912
673688
130154
494509
18986
917959
902912
264279
341349
484488
194201
325349
164173
64080
298317
386418
826851
936959
658688
630656
784817
18986
405418
3904...

result:

points 0.43148441690 max label = 999999

Test #74:

score: 35.2857
Acceptable Answer
time: 14ms
memory: 4120kb

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
95
76076
15015
36036
2002
92092
48048
79079
43043
68068
8008
14014
62062
4004
16016
45045
90090
11011
83083
67067
72072
41041
42042
22022
20020
34034
28028
77077
33033
38038
93093
63063
3003
26026
27027
50050
82082
53053
56056
71071
25025
86086
9009
89089
66066
37037
21021
95095
75075
5005
58058
...

input:

1
4308
4004 54054 1
1095
48048 90090 1
1095
1095 49049 95
95
2002
3003
4004
5005
6006
7007
8008
9009
10010
11011
12012
13013
14014
15015
16016
17017
18018
19019
20020
21021
22022
23023
24024
25025
26026
27027
28028
29029
30030
31031
32032
33033
34034
35035
36036
37037
38038
39039
40040
41041
42042
4...

output:

1095
1095
49049
95
1095
38038
1095
1095
95
1095
1095
1095
1095
1095
1095
29029
95
1095
95
1095
1095
95
1095
1095
1095
1095
95
1095
95
1095
1095
1095
95
1095
1095
1095
1095
1095
1095
1095
90090
1095
1095
95
50050
1095
1095
1095
1095
1095
83083
95
38038
83083
53053
1095
69069
51051
1095
1095
95
1095
9...

result:

points 0.5784540120 max label = 95095

Test #75:

score: 28.6646
Acceptable Answer
time: 14ms
memory: 3888kb

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
540
490490
250250
54054
62062
312312
321321
369369
63063
57057
237237
387387
251251
499499
422422
366366
381381
41041
466466
272272
98098
484484
83083
142142
203203
75075
476476
169169
124124
509509
249249
536536
161161
329329
435435
235235
385385
212212
48048
182182
361361
78078
285285
183183
1...

input:

1
6214
485485 471471 1
540
435435 218218 1
1540
59059 504504 1
1540
309309 333333 1
1540
486486 302302 1
540
311311 483483 1
540
45045 65065 1
540
354354 93093 1
540
160160 30030 1
540
421421 140140 1
540
112112 212212 1
540
173173 401401 1
1540
384384 353353 1
540
360360 254254 1
540
402402 238238 ...

output:

540
1540
1540
1540
540
540
540
540
540
540
540
1540
540
540
540
540
1540
540
1540
1540
540
1540
540
1540
540
1540
540
354354
540
540
540
540
540
1540
540
540
1540
1540
1540
540
540
540
540
540
540
540
540
540
540
540
540
540
540
540
540
540
540
1540
540
540
1540
540
540
540
1540
1540
154154
540
540
...

result:

points 0.46991122390 max label = 540540

Test #76:

score: 26.3205
Acceptable Answer
time: 16ms
memory: 3824kb

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
999
816816
157157
390390
66066
443443
683683
957957
897897
98098
439439
115115
544544
94094
958958
232232
359359
813813
644644
50050
364364
492492
697697
770770
632632
468468
935935
206206
409409
28028
876876
481481
125125
319319
171171
670670
663663
252252
945945
906906
45045
267267
474474
146...

input:

1
10180
18018 801801 1
999
4004 425425 1
999
618618 21021 1
999
204204 287287 1
1999
471471 862862 1
999
532532 783783 1
999
134134 909909 1
1999
213213 609609 1
999
968968 871871 1
999
552552 573573 1
999
979979 748748 1
1999
860860 356356 1
1999
669669 690690 1
1999
783783 397397 1
999
151151 3233...

output:

999
999
999
1999
999
999
1999
999
999
999
1999
1999
1999
999
1999
999
999
1999
999
999
999
999
999
1999
999
1999
999
1999
999
1999
999
1999
999
1999
999
1999
1999
999
1999
1999
1999
1999
1999
999
1999
1999
1999
999
999
999
1999
999
1999
1999
999
999
999
1999
1999
999
999
999
1999
1999
1999
999
999
9...

result:

points 0.43148441690 max label = 999999

Test #77:

score: 45.8102
Acceptable Answer
time: 0ms
memory: 3900kb

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
6
2002
6006
3003
5005
4004
1006
7
6
5005
6006
1006
4004
2002
3003
7
6
2003
4004
6006
5005
1006
3003
7
6
5005
2003
3003
4004
1006
6006
7
6
2002
4004
6006
1005
5005
3003
7
6
2002
3003
6006
4004
1003
5005
7
6
1006
6006
5005
3003
2005
4004
7
6
1006
4004
5005
3003
2004
6006
7
6
3004
5005
2006
6006
4004...

input:

1
420
1003 6006 3
6
2002
3003
6006 2003 1
1006
2003 5005 2
1006
3003
4004 5005 1
6
5005 6 1
1006
6006 5005 1
1006
6006 6 1
1006
3003 6 1
1003
4004 5005 1
1006
1005 5005 5
6
2002
3003
4004
5005
5005 4004 1
1006
4004 1006 1
1006
1006 4004 5
6
2003
4004
5005
6006
3003 4004 1
2003
5005 6006 1
1006
2002 ...

output:

6
1006
1006
6
1006
1006
1006
1003
1006
5005
1006
1006
4004
2003
1006
1006
1006
1005
1006
1006
1006
2006
1006
2003
1006
1005
1006
6
1006
6
2004
1006
1006
2005
1005
5005
1006
2005
6
2003
1006
5005
2006
2003
1006
1006
1003
1006
1006
2005
2006
2006
6
1006
1006
1005
5005
1006
1006
1005
1006
1005
1006
6
1...

result:

points 0.75098624640 max label = 6006

Test #78:

score: 45.8102
Acceptable Answer
time: 2ms
memory: 3812kb

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
6
5005
3004
2004
4004
6006
1006
7
6
3004
4004
6006
2004
5005
1006
7
6
2005
6006
4004
3004
1006
5005
7
6
5005
4004
3003
6006
1004
2003
7
6
3003
2004
5005
1005
4004
6006
7
6
6006
1006
5005
3004
2005
4004
7
6
1006
6006
4004
3004
2006
5006
7
6
3003
6006
1003
4005
2003
5005
7
6
5005
1006
2006
6006
4005...

input:

1
420
1006 6 3
6
2005
6006
6006 6 1
6
1006 5005 3
6
2005
6006
3004 5005 2
2005
4004
5005 6 1
2005
4004 6 1
3004
6006 2003 1
6
4004 2005 1
3004
6006 3004 1
1006
1005 4004 3
6
2004
5005
4004 2003 1
1004
2003 1004 2
1004
3003
1004 2003 3
6
2003
4004
5005 6006 1
4005
4005 6006 2
6
5005
2004 4004 2
1006
...

output:

6
6
2005
2005
2005
3004
6
3004
1006
2004
1004
1004
2003
4005
6
3004
2004
2004
1006
1003
1006
2006
1006
3004
1006
1005
1006
6
2005
6
2003
6
2004
2006
4004
5005
4005
6
2006
6
1006
6006
2006
4005
5005
3004
3004
1006
6
1006
2006
2006
1006
2005
4004
3006
4005
1006
1006
1005
1004
2004
2005
2005
1006
4005
...

result:

points 0.75098624640 max label = 6006

Test #79:

score: 45.8102
Acceptable Answer
time: 0ms
memory: 3836kb

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
6
6006
2005
4005
5005
1006
3005
7
6
1005
6006
3005
4004
5005
2005
7
6
2004
4004
5006
1004
6006
3004
6
5
2002
3003
1001
4004
5005
6
5
1005
4004
3003
2002
5005
6
5
2002
4004
3003
5005
1004
6
5
1004
4004
3003
5005
2002
6
5
1005
3003
5005
4004
2003
6
5
2004
3003
1005
5005
4004
6
5
2002
4004
3004
1002
...

input:

1
336
1004 4004 4
5
2002
3003
4004
1005 5 5
5
2002
3003
4004
5005
6 5006 2
1004
5006
5 4004 2
1004
5005
5006 6006 2
6
6006
3003 2004 1
2004
1002 4004 2
5
2002
1005 2003 4
5
2003
4004
5005
3005 4005 2
2005
4005
3003 2002 1
1005
4004 5 1
5
2002 3003 1
5
5 2002 5
1001
2002
3003
4004
5005
2004 1004 2
10...

output:

4004
5
5006
1004
6006
2004
5
2003
4005
1005
5
5
2002
1004
5005
3005
3005
1004
3005
5
2004
1004
5006
2004
1005
5
2005
1004
1004
1005
3004
1005
3005
2003
1005
5
1005
1005
1005
1001
3005
3005
2004
1004
3004
6
1005
2005
5
1005
3005
3005
5
1004
3004
4004
2004
2005
5006
2002
5
5005
3004
1004
1004
5
1005
5...

result:

points 0.75098624640 max label = 6006

Test #80:

score: 46.5049
Acceptable Answer
time: 0ms
memory: 3788kb

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
5
5005
4004
2002
3004
1002
6
5
1004
5005
3003
2004
4004
6
5
4004
1004
2004
3003
5005
6
5
1004
2004
4004
3004
5005
5
4
1001
4004
2002
3003
5
4
4004
3003
1004
2002
5
4
2003
1004
3003
4004
5
4
1004
3003
2004
4004
5
4
4004
1004
2004
3003
5
4
1003
3003
4004
2003

input:

1
240
4 4004 1
1004
4004 4 1
1004
2004 5 2
1004
3004
2003 1003 2
1003
3003
5 1004 2
1004
5005
4004 3003 1
4
1004 3003 3
4
2003
4004
3003 2002 1
4
4004 5005 1
3004
4004 1004 1
1004
4 3003 1
1004
4004 2002 1
4
1001 4004 1
4
1004 3004 2
5
2004
5005 4004 1
5
3004 1002 2
5
4004
2004 4004 3
1004
3003
4004...

output:

1004
1004
1004
1003
1004
4
2003
4
3004
1004
1004
4
4
2004
5
5
4004
2004
5005
3004
3004
4
5
5
1004
2004
3004
2004
3004
1004
1004
1004
1004
1003
2003
2004
1004
5
2002
4
5
1004
4
4004
5
1004
1004
5
5
2004
2004
1004
5
1004
2004
1002
5
2004
5
4
1004
2004
5
3003
4
2004
1004
1003
5
1004
1004
3004
2004
1004...

result:

points 0.7623747360 max label = 5005

Test #81:

score: 48.4513
Acceptable Answer
time: 0ms
memory: 3824kb

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
3
3003
2002
1003
4
3
3003
2002
1003
4
3
3003
1002
2002
3
2
2002
1002
3
2
1001
2002
2
1
1001

input:

1
50
3003 1003 1
1003
1001 2002 1
2
3003 3 1
3
1001 2 1
2
3003 2002 1
1003
2 2002 2
1001
2002
2002 1001 1
2
2002 3 1
1003
1002 3003 2
3
2002
2 1001 2
1001
2002
1003 3003 3
3
2002
3003
3 1003 1
1003
3 1003 1
1003
2002 1003 1
1003
2002 1003 1
1003
3003 3 1
1003
3003 2002 1
3
1002 2 2
2
2002
1 1001 1
1...

output:

1003
2
3
2
1003
2002
2
1003
3
1001
3003
1003
1003
1003
1003
1003
3
2
1001
3
1003
3003
1
2
1002
3
1002
1003
3
1003
2002
2002
1002
1002
1003
1003
1003
1003
1003
1003
1003
1002
1002
2002
3
1002
1002
1002
3003
2002

result:

points 0.79428282420 max label = 3003

Test #82:

score: 45.2228
Acceptable Answer
time: 38ms
memory: 4116kb

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
7
3004
4004
7007
5007
2004
1004
6007
8
7
1007
2007
3007
4007
5007
6007
7007
8
7
3005
5005
2005
6007
4005
1005
7007
8
7
1004
5007
2003
4004
6006
7007
3003
8
7
2002
6006
5005
7007
1007
3003
4004
8
7
6006
5005
2002
3003
7007
1001
4004
8
7
3004
4004
6007
7007
2004
5007
1004
8
7
1006
7007
5005
3004
200...

input:

1
57266
4004 2003 1
1004
3007 5007 2
2007
4007
4004 2002 1
3004
3003 5005 1
1007
6006 7 1
5007
2004 3004 2
1004
3004
7 4004 2
1004
5007
7007 4004 1
5007
7 3007 1
1007
3005 7 2
2005
4005
6007 5005 2
7
7007
5007 2003 3
7
6006
7007
7007 4004 1
6007
5007 3003 3
7
6006
7007
2005 7 2
1005
3005
4005 1005 2...

output:

1004
4007
3004
1007
5007
3004
1004
5007
1007
2005
7
7
6007
7
1005
3005
1007
5007
5007
3005
7
1005
1007
3004
1006
5007
6007
7
7
7
1007
3003
7
7
7
7
1006
7
7
7
1006
6007
3004
2004
3005
2002
7
7
3005
1006
3004
4005
7
3004
5007
7
7
2007
2005
4005
4007
3004
1006
6007
1007
3004
6007
7
3003
1004
5007
1006
...

result:

points 0.74135741560 max label = 7007

Test #83:

score: 45.2228
Acceptable Answer
time: 38ms
memory: 3824kb

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
7
5005
4004
2002
1007
6006
3004
7007
8
7
2002
5006
1007
6006
3003
7007
4004
8
7
4004
2007
3004
1001
5005
7007
6006
8
7
2006
6006
3006
5006
7007
1006
4006
8
7
6006
3006
2002
1002
5006
4006
7007
8
7
5007
2004
4004
1004
3004
6007
7007
8
7
1001
6007
3003
7007
2005
4005
5005
8
7
1003
4007
6007
5007
300...

input:

1
57297
2002 3003 1
1007
6006 1007 1
1007
5007 1003 2
4007
6007
6007 7 2
5007
7007
7 4005 3
1001
2005
6007
6007 5007 2
5007
7007
2002 7 1
1007
5007 1003 2
4007
6007
4006 1002 2
3006
5006
2004 5007 2
1004
3004
5005 7007 1
1007
3003 2005 1
2005
1003 7007 2
7
2003
7 7007 3
1002
3006
7007
2007 1007 4
10...

output:

1007
1007
4007
5007
2005
5007
1007
4007
3006
1004
1007
2005
7
7007
1007
1007
5007
4006
1007
7
5006
2005
2007
1007
4007
2005
4006
1007
5007
7
1007
1007
2002
1007
1007
1003
7
5006
3006
1001
7
5006
1007
7
2007
2003
1006
2007
1007
2005
1004
6007
2007
1007
2006
1007
2007
1007
4006
1007
1007
1007
3004
300...

result:

points 0.74135741560 max label = 7007

Test #84:

score: 45.2228
Acceptable Answer
time: 38ms
memory: 3744kb

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
7
7007
4004
1007
5005
6006
3003
2002
8
7
6007
5007
1004
7007
3004
2002
4004
8
7
4005
3003
5005
7007
6006
2006
1006
8
7
7007
1004
3004
5007
2004
6007
4004
8
7
4004
1005
2005
6007
5005
3004
7007
8
7
1007
3004
2007
6006
5005
4004
7007
8
7
5007
6007
2007
4007
7007
1007
3007
8
7
1007
3003
2002
7007
600...

input:

1
57195
3003 7007 1
1007
7 5007 1
1007
2006 3003 4
1006
3003
4005
6006
7 5007 1
1007
7007 3003 1
1007
2002 7 1
1007
7 6006 1
1007
4004 2005 1
3004
4005 2006 2
2006
5005
7 1007 1
1007
7007 3003 1
1007
5005 7007 1
1007
5005 6007 1
2005
2002 5005 1
1007
3003 2002 1
1007
6006 2006 1
3006
6007 7 2
5007
7...

output:

1007
1007
3003
1007
1007
1007
1007
3004
2006
1007
1007
1007
2005
1007
1007
3006
5007
3004
1007
1004
4004
1007
2007
2007
3004
1004
6007
4005
2005
3004
2005
2007
3004
3007
2007
2006
2004
2006
2004
1004
2005
2007
4005
3004
4007
3003
2003
7
5007
2003
3004
1007
2007
2007
3004
1006
5007
1007
4007
5007
600...

result:

points 0.74135741560 max label = 7007

Test #85:

score: 45.2228
Acceptable Answer
time: 38ms
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
7
7007
4004
1007
5005
6006
3003
2002
8
7
6007
5007
1004
7007
3004
2002
4004
8
7
4005
3003
5005
7007
6006
2006
1006
8
7
7007
1004
3004
5007
2004
6007
4004
8
7
4004
1005
2005
6007
5005
3004
7007
8
7
1007
3004
2007
6006
5005
4004
7007
8
7
5007
6007
2007
4007
7007
1007
3007
8
7
1007
3003
2002
7007
600...

input:

1
57195
3003 7007 1
1007
7 5007 1
1007
2006 3003 4
1006
3003
4005
6006
7 5007 1
1007
7007 3003 1
1007
2002 7 1
1007
7 6006 1
1007
4004 2005 1
3004
4005 2006 2
2006
5005
7 1007 1
1007
7007 3003 1
1007
5005 7007 1
1007
5005 6007 1
2005
2002 5005 1
1007
3003 2002 1
1007
6006 2006 1
3006
6007 7 2
5007
7...

output:

1007
1007
3003
1007
1007
1007
1007
3004
2006
1007
1007
1007
2005
1007
1007
3006
5007
3004
1007
1004
4004
1007
2007
2007
3004
1004
6007
4005
2005
3004
2005
2007
3004
3007
2007
2006
2004
2006
2004
1004
2005
2007
4005
3004
4007
3003
2003
7
5007
2003
3004
1007
2007
2007
3004
1006
5007
1007
4007
5007
600...

result:

points 0.74135741560 max label = 7007

Test #86:

score: 45.2228
Acceptable Answer
time: 30ms
memory: 4112kb

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
7
7007
4004
1007
5005
6006
3003
2002
8
7
6007
5007
1004
7007
3004
2002
4004
8
7
4005
3003
5005
7007
6006
2006
1006
8
7
7007
1004
3004
5007
2004
6007
4004
8
7
4004
1005
2005
6007
5005
3004
7007
8
7
1007
3004
2007
6006
5005
4004
7007
8
7
5007
6007
2007
4007
7007
1007
3007
8
7
1007
3003
2002
7007
600...

input:

1
57195
3003 7007 1
1007
7 5007 1
1007
2006 3003 4
1006
3003
4005
6006
7 5007 1
1007
7007 3003 1
1007
2002 7 1
1007
7 6006 1
1007
4004 2005 1
3004
4005 2006 2
2006
5005
7 1007 1
1007
7007 3003 1
1007
5005 7007 1
1007
5005 6007 1
2005
2002 5005 1
1007
3003 2002 1
1007
6006 2006 1
3006
6007 7 2
5007
7...

output:

1007
1007
3003
1007
1007
1007
1007
3004
2006
1007
1007
1007
2005
1007
1007
3006
5007
3004
1007
1004
4004
1007
2007
2007
3004
1004
6007
4005
2005
3004
2005
2007
3004
3007
2007
2006
2004
2006
2004
1004
2005
2007
4005
3004
4007
3003
2003
7
5007
2003
3004
1007
2007
2007
3004
1006
5007
1007
4007
5007
600...

result:

points 0.74135741560 max label = 7007

Test #87:

score: 26.3358
Acceptable Answer
time: 28ms
memory: 3824kb

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
977
527630
166519
589630
145519
543630
93630
370519
385519
689977
351519
785977
233519
851977
127519
338519
495519
655977
600630
29630
380519
352519
891977
498519
657977
622630
171519
436519
129519
954977
59630
330519
910977
371519
464519
73630
794977
46630
855977
359519
558630
756977
852977
426...

input:

1
35090
303519 201519 2
302519
304519
797972 520624 2
796972
798972
960963 696963 2
959963
961963
267988 151988 2
266988
268988
61182 404555 2
60182
62182
630833 570833 2
629833
631833
41156 285631 2
40156
42156
645674 443994 2
644674
646674
398502 277385 2
397502
399502
577833 838950 2
576833
57883...

output:

302519
796972
959963
266988
60182
629833
40156
644674
397502
576833
931977
352555
449950
203957
341519
2679
604679
350519
253994
138502
930957
24502
811977
923963
93950
970977
366414
457557
501950
888994
396557
329385
416425
860950
738977
270385
501557
48624
73624
611750
596679
31182
360994
379434
5...

result:

points 0.43173502410 max label = 995995

Test #88:

score: 26.3205
Acceptable Answer
time: 30ms
memory: 4096kb

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
999
843843
877877
543543
556556
864864
827827
406406
41041
702702
396397
165165
83126
614614
609609
474474
896896
899899
342342
819819
335335
185185
800800
147147
832832
672672
65065
352352
480480
249249
717717
901901
407419
539539
240240
997997
498498
655655
795796
273273
96096
538538
915915
3...

input:

1
47617
788789 661686 2
787789
789789
819825 268268 3
818832
820822
823825
715715 941942 1
712715
46048 261275 3
45051
47047
48048
16016 894932 1
15934
412412 423423 1
411412
610999 284566 2
609999
611999
542543 351351 2
541543
543543
94256 553999 2
93256
95256
630640 790792 6
629645
631631
632632
6...

output:

787789
818832
712715
45051
15934
411412
609999
541543
93256
629645
501545
126566
1999
651657
70076
1999
8256
188189
1999
808818
851999
450999
1999
4989
569999
951953
386999
188190
5256
548697
437566
418448
729999
718792
821824
987989
637999
122999
360566
251256
993999
261999
1999
86391
991999
924926...

result:

points 0.43148441690 max label = 999999

Test #89:

score: 26.3244
Acceptable Answer
time: 38ms
memory: 3824kb

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
990
967990
538830
574830
557830
500830
772830
950990
95830
71830
788830
585830
237830
531830
741830
97830
87830
711830
275830
136830
464830
586830
891990
159830
139830
947990
780830
343830
47830
762830
173830
216830
889990
742830
73830
449830
361830
920990
847990
899990
276830
269830
962990
1988...

input:

1
49922
824825 234531 2
823825
825825
705705 30064 1
693712
671680 55289 2
670680
672680
733989 362660 2
732989
734989
491680 932991 2
490680
492680
661696 825825 2
660696
662696
292992 337992 2
291992
293992
404407 941941 3
401407
405405
406407
577660 851989 2
576660
578660
980992 94180 2
979992
98...

output:

823825
693712
670680
732989
490680
660696
293992
401407
576660
979992
728736
111136
240992
682683
30064
421830
509660
842990
582680
219992
742989
605680
409531
877991
241830
137141
636660
6180
817819
348357
691830
286289
775991
233294
179257
508991
812989
499527
304992
568569
233294
586660
643644
35...

result:

points 0.43154697450 max label = 998998

Test #90:

score: 26.3205
Acceptable Answer
time: 40ms
memory: 3832kb

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
992
525531
94094
248248
252253
652652
962979
796803
646650
793794
542576
130130
865878
366367
267275
950951
654661
290318
558558
86088
734734
539539
827831
937939
635640
334334
687688
488488
361361
14393
108108
726734
496497
606606
945954
738738
649649
289318
992992
890893
287287
206206
120122
7...

input:

1
50698
426429 442446 3
424429
427427
428429
25025 789789 1
20026
959959 67067 1
1999
667922 80080 3
666922
668674
675922
218220 61062 2
216220
219220
767767 134134 1
766767
620620 613613 1
619620
563563 359359 1
126946
256283 455455 3
255287
257282
283283
40365 490491 2
38365
41365
918918 718718 1
...

output:

424429
20026
1999
666922
216220
766767
619620
126946
255287
38365
1999
703711
619620
153172
5994
749758
690692
713716
768779
24031
92098
48882
974978
266975
211238
890932
860893
428435
161168
164212
86087
418423
269270
383492
505513
789830
48882
827831
615942
245245
61062
905906
627628
48882
964978
...

result:

points 0.43148441690 max label = 999999

Test #91:

score: 26.3205
Acceptable Answer
time: 40ms
memory: 4140kb

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
992
525531
94094
248248
252253
652652
962979
796803
646650
793794
542576
130130
865878
366367
267275
950951
654661
290318
558558
86088
734734
539539
827831
937939
635640
334334
687688
488488
361361
14393
108108
726734
496497
606606
945954
738738
649649
289318
992992
890893
287287
206206
120122
7...

input:

1
50698
426429 442446 3
424429
427427
428429
25025 789789 1
20026
959959 67067 1
1999
667922 80080 3
666922
668674
675922
218220 61062 2
216220
219220
767767 134134 1
766767
620620 613613 1
619620
563563 359359 1
126946
256283 455455 3
255287
257282
283283
40365 490491 2
38365
41365
918918 718718 1
...

output:

424429
20026
1999
666922
216220
766767
619620
126946
255287
38365
1999
703711
619620
153172
5994
749758
690692
713716
768779
24031
92098
48882
974978
266975
211238
890932
860893
428435
161168
164212
86087
418423
269270
383492
505513
789830
48882
827831
615942
245245
61062
905906
627628
48882
964978
...

result:

points 0.43148441690 max label = 999999

Test #92:

score: 26.3244
Acceptable Answer
time: 38ms
memory: 3824kb

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
991
5005
18018
764764
989989
702705
425425
720720
723728
106115
557570
664665
878878
739739
394394
156156
624624
866866
777785
951951
579583
685685
566566
453453
952952
343343
335335
185185
177177
669669
285286
60062
360362
63063
756756
388388
988988
73073
713713
26026
150150
504504
588589
29629...

input:

1
49569
777777 644644 1
776777
605606 314610 2
602607
606606
149149 312321 1
148149
52053 2993 2
51053
53053
281637 245245 3
280637
282636
637637
972972 354354 1
936985
907910 267270 4
874910
908908
909909
910910
871871 367369 1
870871
535595 19025 3
534596
536594
595595
100100 24026 1
98100
928928 ...

output:

776777
602607
148149
51053
280637
936985
874910
870871
534596
98100
923928
390391
496497
351447
11141
210226
893909
51951
936937
462466
698908
885890
892897
332337
629636
352375
1989
208697
13027
385453
848869
417557
647681
230241
367385
270276
146201
44780
180181
41042
155713
401404
688703
342343
6...

result:

points 0.43154697450 max label = 998998

Test #93:

score: 26.3244
Acceptable Answer
time: 30ms
memory: 3800kb

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
991
5005
18018
764764
989989
702705
425425
720720
723728
106115
557570
664665
878878
739739
394394
156156
624624
866866
777785
951951
579583
685685
566566
453453
952952
343343
335335
185185
177177
669669
285286
60062
360362
63063
756756
388388
988988
73073
713713
26026
150150
504504
588589
29629...

input:

1
49569
777777 644644 1
776777
605606 314610 2
602607
606606
149149 312321 1
148149
52053 2993 2
51053
53053
281637 245245 3
280637
282636
637637
972972 354354 1
936985
907910 267270 4
874910
908908
909909
910910
871871 367369 1
870871
535595 19025 3
534596
536594
595595
100100 24026 1
98100
928928 ...

output:

776777
602607
148149
51053
280637
936985
874910
870871
534596
98100
923928
390391
496497
351447
11141
210226
893909
51951
936937
462466
698908
885890
892897
332337
629636
352375
1989
208697
13027
385453
848869
417557
647681
230241
367385
270276
146201
44780
180181
41042
155713
401404
688703
342343
6...

result:

points 0.43154697450 max label = 998998

Test #94:

score: 26.3205
Acceptable Answer
time: 30ms
memory: 3828kb

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
999
241244
453453
134134
763765
727727
258258
716716
849851
837837
745758
954960
255258
656679
321322
981981
760760
836842
580581
544561
273273
407408
819819
678679
630643
783783
267267
642642
539539
484484
610610
448537
891891
687687
884884
955956
104104
217217
201201
306306
208208
50051
81381...

input:

1
50684
420420 968968 1
402420
163163 879879 1
162163
3017 786786 2
2948
4017
602602 75075 1
599604
694694 319374 1
693976
542542 61061 1
541548
777777 207413 1
776780
931934 898898 3
930943
932932
933934
217218 938938 2
205271
218218
687687 551551 1
649706
437438 396405 2
435459
438438
56071 34263 ...

output:

402420
162163
2948
599604
693976
541548
776780
930943
205271
649706
435459
34263
144471
171898
851876
2999
2999
71145
280282
443498
176878
466473
30936
642643
605610
658690
411418
132145
882884
753777
654991
27035
571574
284469
271382
638640
2999
286309
365368
374462
123952
20096
919929
33035
709711...

result:

points 0.43148441690 max label = 999999

Test #95:

score: 27.5159
Acceptable Answer
time: 6ms
memory: 3768kb

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
730
524524
215215
693693
95095
41041
420420
364364
455455
603603
467467
331331
181181
77077
94094
703703
208208
137137
525525
376376
618618
123123
33033
558558
699699
623623
579579
112112
47047
321321
374374
211211
585585
188188
241241
293293
674674
689689
31031
276276
690690
143143
232232
39639...

input:

1
5230
211211 201201 1
730
250250 341341 1
730
270270 538538 1
1730
259259 603603 1
730
49049 609609 1
1730
559559 235235 1
730
673673 604604 1
1730
247247 9009 1
730
579579 616616 1
730
298298 688688 1
730
577577 655655 1
1730
95095 406406 1
730
577577 380380 1
1730
622622 430430 1
730
327327 53553...

output:

730
730
1730
730
1730
730
1730
730
730
730
1730
730
1730
730
1730
730
1730
730
730
1730
1730
1730
1730
730
730
730
1730
1730
730
730
65065
730
730
730
730
1730
730
1730
730
1730
730
730
719719
730
730
730
1730
1730
730
730
1730
730
730
1730
730
730
730
730
1730
730
730
730
1730
730
730
1730
1730
173...

result:

points 0.45107993770 max label = 730730

Test #96:

score: 26.3205
Acceptable Answer
time: 16ms
memory: 3860kb

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
999
794794
263263
169169
278278
454454
588588
888888
430430
337337
998998
492492
612612
723723
11011
651651
519519
29029
668668
25025
449449
720720
284284
906906
61061
940940
91091
313313
174174
26026
587587
31031
965965
191191
885885
529529
60060
913913
150150
384384
484484
796796
555555
95695...

input:

1
10180
700700 389389 1
999
999 278278 1
1999
717717 178178 1
999
720720 136136 1
1999
125125 243243 1
1999
633633 120120 1
999
641641 259259 1
1999
591591 343343 1
999
645645 291291 1
999
760760 825825 1
999
566566 30030 1
1999
424424 253253 1
999
735735 77077 1
999
926926 318318 1
999
957957 66466...

output:

999
1999
999
1999
1999
999
1999
999
999
999
1999
999
999
999
999
999
1999
1999
1999
999
999
1999
999
1999
999
1999
999
1999
1999
1999
999
1999
1999
1999
1999
1999
999
999
1999
999
999
564564
1999
999
999
999
999
1999
999
999
1999
1999
1999
999
999
999
1999
999
1999
999
1999
1999
999
999
1999
1999
19...

result:

points 0.43148441690 max label = 999999

Test #97:

score: 26.7565
Acceptable Answer
time: 20ms
memory: 4116kb

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
891
795795
376376
786786
550550
267277
503503
463463
804804
214214
401401
542542
158158
186186
40040
615615
287287
630630
464464
175175
276276
565565
666666
733743
247247
397397
455455
584584
226226
822832
648648
363363
874874
189199
194194
169169
566566
147147
846846
195195
742742
280280
164164...

input:

1
13208
875882 366366 8
7890
876876
877877
878878
879879
880880
881881
882882
551561 53053 11
495605
552552
553553
554554
555555
556556
557557
558558
559559
560560
561561
874883 312312 10
2883
875875
876876
877877
878878
879879
880880
881881
882882
883883
83092 225225 10
12102
84084
85085
86086
8708...

output:

7890
495605
2883
12102
5886
5095
215225
73413
142198
30114
483525
819839
91133
672728
564584
65697
728812
217557
729785
48090
721811
202222
552594
721811
396438
154174
3887
30114
6812
721811
107887
553806
783793
601621
783793
357447
665685
371461
2882
416436
559579
154174
304324
601621
379421
142198...

result:

points 0.43863091740 max label = 891891

Test #98:

score: 26.3205
Acceptable Answer
time: 22ms
memory: 3828kb

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
999
92092
145145
344344
405405
867867
973973
48104
337337
811818
323323
44044
312312
67067
189189
450450
972972
15022
819875
443443
580580
109109
905905
334334
476476
852859
510517
272272
168168
306313
94094
64064
503503
161161
203203
141141
213213
557557
955955
93093
533533
61061
310310
656656...

input:

1
16365
413421 938938 9
358430
414414
415415
416416
417417
418418
419419
420420
421421
224231 800800 8
191247
225225
226226
227227
228228
229229
230230
231231
876932 121121 8
47989
877884
885892
893900
901908
909916
917924
925932
56982 625625 9
1991
57129
130202
203275
276324
325397
398836
837909
91...

output:

358430
191247
47989
398836
539545
430486
738893
472544
5019
547586
886942
156162
468474
583613
501543
203275
498512
347359
10998
400412
894924
262301
363419
399471
19049
20988
134190
789856
304318
170184
487543
717751
913919
810816
191247
705761
130202
857977
415457
678788
105132
676682
212284
85889...

result:

points 0.43148441690 max label = 999999

Test #99:

score: 27.6164
Acceptable Answer
time: 30ms
memory: 3820kb

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
711
693702
120629
669708
147620
87638
587587
566566
130625
442525
171614
434529
174613
211211
586586
561561
335335
327566
380549
168615
452523
679679
398539
235594
75075
664664
403403
226599
16016
549549
607607
657657
233596
281578
678705
601601
501510
676705
270581
278579
113630
651651
616616
5...

input:

1
33400
296663 489608 3
295664
297297
298663
166365 487690 3
164365
167167
168365
184611 3003 3
183612
185610
611611
49124 465604 3
48125
50050
51124
71572 135556 3
69572
72571
572572
438625 507600 3
437626
439624
625625
48407 64399 3
46407
49406
407407
113384 367367 3
112385
114383
384384
442609 20...

output:

298663
164365
183612
48125
72571
439624
49406
114383
441610
340491
556579
534623
340607
90211
520679
464615
204651
401478
484609
222531
42099
208649
84691
353638
108108
379550
440527
437574
290657
244641
240685
405626
635684
274439
497688
241344
80501
299620
96499
431578
324607
398627
587700
452457
...

result:

points 0.45272723850 max label = 711711

Test #100:

score: 26.3205
Acceptable Answer
time: 14ms
memory: 4128kb

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
999
589724
113113
271824
967967
199854
785785
598719
214849
306815
887887
820820
905905
585726
959992
381788
658658
262262
557557
516753
405784
10931
503503
206853
413782
925925
706706
469764
148875
799799
141878
792792
207207
506755
439439
268827
631710
299299
48915
610610
805805
455455
533744...

input:

1
33377
590913 213213 3
589914
591912
913913
327836 311311 3
325836
328328
329836
490757 35922 3
488757
491491
492757
300843 378819 3
298843
301842
843843
76827 880993 3
75828
77077
78827
205482 526526 3
204483
206206
207482
338923 395395 3
337924
339339
340923
504949 651886 3
503950
505948
949949
5...

output:

589914
325836
488757
301842
75828
204483
340923
505948
51532
716841
57178
80905
378721
672707
554999
444693
144897
105516
325834
439968
310933
323808
630977
537656
144987
251860
125808
8197
160983
685808
517762
595738
129808
361834
208481
250861
158893
289464
153288
162891
432817
334731
118511
55464...

result:

points 0.43148441690 max label = 999999

Test #101:

score: 26.7013
Acceptable Answer
time: 6ms
memory: 3784kb

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
904
737737
505505
272272
493493
618618
528528
627627
682682
393393
49049
856856
827827
330330
710710
127127
162162
19019
742742
7007
438438
403403
833833
630630
197197
290290
869869
653653
107107
309309
151151
809809
689689
372372
816816
841841
535535
785785
892892
709709
600600
82082
318318
846...

input:

1
4502
335376 895895 42
318406
336336
337337
338338
339339
340340
341341
342342
343343
344344
345345
346346
347347
348348
349349
350350
351351
352352
353353
354354
355355
356356
357357
358358
359359
360360
361361
362362
363363
364364
365365
366366
367367
368368
369369
370370
371371
372372
373373
374...

output:

318406
421870
574667
136682
427478
161223
104411
267415
92691
113427
1904
684775
125375
435638
10366
421870
1904
618673
1904
203354
15053
124172
132806
233311
74831
91853
104411
136682
1904
232533
50701
125375
286396
534626
1904
553632
112413
18883
104411
111797
693879
421870
1904
548856
548856
1136...

result:

points 0.43772613410 max label = 904904

Test #102:

score: 26.3205
Acceptable Answer
time: 14ms
memory: 4164kb

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
999
668668
871871
581581
402402
553553
669669
5005
429429
573573
398398
510510
932932
51051
218218
215215
778778
618618
321321
955955
746746
253253
890890
961961
426426
419419
853853
848848
590590
731731
66066
973973
436436
365365
533533
708708
34034
454454
904904
872872
674674
210210
608608
88...

input:

1
4293
244244 232232 1
216543
546546 425425 1
511956
778778 795795 1
742966
360360 3003 1
100391
199242 166166 44
99383
200200
201201
202202
203203
204204
205205
206206
207207
208208
209209
210210
211211
212212
213213
214214
215215
216216
217217
218218
219219
220220
221221
222222
223223
224224
22522...

output:

216543
511956
742966
100391
99383
774857
161349
812963
263389
129883
12891
422772
774857
304812
549772
519916
1999
1999
129883
781835
1999
511956
12891
713870
519916
422772
223436
59977
445850
441634
12891
263389
336417
12891
566668
18018
318399
304812
370450
696889
290442
61866
511956
100391
245374...

result:

points 0.43148441690 max label = 999999