QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#838631#9910. 颠倒歌lmh_qwq100 ✓1136ms418484kbC++145.0kb2024-12-31 16:48:592024-12-31 16:48:59

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

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

output:

9

result:

ok single line: '9'

Test #2:

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

input:

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

output:

2

result:

ok single line: '2'

Test #3:

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

input:

0
3 8
3 2
5 4
1 2
3 6
5 7
5 2
8 3
8 3
1 2
2 5
6 3
2 4
7 5
3 2
8 3
5 2
2 4
3 6
3 2
1 2
5 7

output:

4

result:

ok single line: '4'

Test #4:

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

input:

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

output:

262144

result:

ok single line: '262144'

Subtask #2:

score: 4
Accepted

Test #5:

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

input:

0
1 189
77 175
145 175
4 175
92 175
175 33
175 125
175 185
157 175
186 175
115 175
113 175
38 175
175 138
175 133
175 48
175 128
175 66
175 34
175 148
150 175
175 104
175 84
175 59
175 154
80 175
176 175
135 175
55 175
139 175
175 132
175 91
13 175
175 110
155 175
175 60
175 184
73 175
152 175
83 17...

output:

5245226

result:

ok single line: '5245226'

Test #6:

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

input:

0
1 183
23 70
23 123
23 75
149 23
142 23
14 23
23 99
23 36
23 73
23 29
23 153
56 23
165 23
82 23
110 23
167 23
18 23
119 23
23 146
93 23
23 176
89 23
23 10
50 23
117 23
40 23
23 115
23 4
139 23
177 23
53 23
132 23
23 84
151 23
154 23
31 23
23 120
183 23
26 23
5 23
23 65
43 23
23 182
23 118
169 23
15...

output:

114478935

result:

ok single line: '114478935'

Test #7:

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

input:

0
1 194
182 96
78 182
182 109
161 182
26 182
194 182
31 182
99 182
182 65
39 182
182 77
159 182
136 182
182 85
182 125
83 182
167 182
182 112
121 182
63 182
11 182
182 145
182 60
182 45
108 182
182 13
24 182
168 182
140 182
182 88
27 182
182 30
182 75
182 155
182 119
80 182
182 56
182 14
52 182
182 ...

output:

608479208

result:

ok single line: '608479208'

Test #8:

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

input:

0
1 200
158 157
158 58
9 158
154 158
104 158
14 158
158 111
158 120
169 158
35 158
98 158
158 174
188 158
192 158
158 72
158 115
145 158
149 158
55 158
6 158
155 158
17 158
158 181
158 162
132 158
158 177
158 195
82 158
158 31
53 158
158 52
158 193
158 127
158 73
158 168
81 158
158 164
158 60
158 99...

output:

325306908

result:

ok single line: '325306908'

Subtask #3:

score: 8
Accepted

Dependency #2:

100%
Accepted

Test #9:

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

input:

0
1 200
115 118
97 44
127 197
71 198
116 38
16 58
166 129
200 92
40 136
44 146
37 117
153 59
28 122
139 76
191 104
84 49
22 138
124 98
131 141
151 45
41 9
80 147
159 165
123 13
31 54
199 167
52 33
54 158
142 95
36 101
59 195
35 50
130 44
178 5
192 64
52 21
106 21
171 81
66 35
18 15
39 33
131 126
64 ...

output:

480827728

result:

ok single line: '480827728'

Test #10:

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

input:

0
1 159
23 54
23 123
35 23
143 23
132 23
23 63
134 38
41 23
47 55
98 23
155 2
65 23
23 90
23 136
143 11
23 22
156 45
23 36
104 101
23 39
23 24
64 109
91 23
92 116
104 142
23 115
76 21
71 77
159 23
61 68
153 23
47 23
72 38
60 107
115 148
131 99
71 32
83 93
31 58
23 67
23 13
53 153
22 44
58 99
10 23
2...

output:

73916574

result:

ok single line: '73916574'

Test #11:

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

input:

0
1 200
193 130
89 191
23 109
81 28
69 49
65 99
142 94
176 33
146 112
114 47
200 197
164 138
68 133
143 172
150 54
33 196
182 98
190 64
126 67
175 181
116 132
52 160
106 97
192 155
83 21
5 164
172 131
139 56
153 149
101 157
98 27
140 128
2 156
24 58
12 29
63 13
9 182
199 154
46 34
151 33
150 68
154 ...

output:

170540372

result:

ok single line: '170540372'

Test #12:

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

input:

0
1 200
126 29
85 98
71 157
34 81
59 29
184 29
75 48
38 29
71 99
28 45
92 89
145 130
149 161
57 40
147 149
29 84
29 42
137 29
156 115
173 128
14 200
133 123
29 103
181 6
29 131
138 182
29 71
118 74
29 150
29 16
141 29
29 198
142 128
29 185
180 59
35 29
191 29
89 24
4 188
121 106
22 29
158 29
11 31
5...

output:

204491280

result:

ok single line: '204491280'

Subtask #4:

score: 9
Accepted

Dependency #3:

100%
Accepted

Test #13:

score: 9
Accepted
time: 0ms
memory: 20720kb

input:

0
1 160
8 11
75 73
134 158
96 94
20 121
75 100
23 26
135 131
68 26
48 20
77 146
73 40
55 107
17 14
95 4
41 151
87 25
72 51
26 120
112 71
26 12
101 98
142 76
110 132
115 82
143 33
124 29
133 100
28 101
11 120
100 35
111 63
59 30
85 154
84 101
22 30
32 24
64 10
85 6
45 19
70 158
122 110
22 75
47 150
2...

output:

172926914

result:

ok single line: '172926914'

Test #14:

score: 9
Accepted
time: 0ms
memory: 20632kb

input:

0
2 151
112 86
114 18
20 41
51 33
41 29
41 58
74 41
41 147
123 63
136 151
134 41
59 61
41 11
2 41
41 39
99 129
41 63
28 41
19 41
41 65
41 120
133 78
126 41
96 105
143 133
97 72
32 28
72 98
69 41
71 41
145 100
41 50
41 117
86 13
55 41
148 127
41 64
19 12
14 26
23 41
45 151
91 41
141 111
82 146
41 141...

output:

106301136

result:

ok single line: '106301136'

Test #15:

score: 9
Accepted
time: 0ms
memory: 18760kb

input:

0
2 178
5 122
8 93
37 20
3 71
126 178
78 18
163 157
65 154
24 47
174 118
124 16
101 104
21 97
156 58
44 52
22 76
44 19
99 116
105 127
94 97
12 123
132 72
55 171
150 133
145 155
150 11
175 117
125 161
103 109
7 118
165 78
80 126
176 59
34 110
26 156
93 25
59 106
170 167
113 86
20 60
81 171
106 173
95...

output:

6691944

result:

ok single line: '6691944'

Test #16:

score: 9
Accepted
time: 0ms
memory: 21200kb

input:

0
2 200
195 147
163 146
81 146
29 146
55 146
146 35
22 120
122 7
124 146
127 146
182 146
36 146
38 185
146 61
93 197
50 159
109 66
68 146
14 169
182 178
164 127
168 200
146 83
146 103
161 108
44 146
146 187
48 96
146 105
65 193
157 141
55 15
142 146
50 85
186 113
37 36
107 146
53 141
34 146
8 35
169...

output:

725412495

result:

ok single line: '725412495'

Subtask #5:

score: 10
Accepted

Dependency #4:

100%
Accepted

Test #17:

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

input:

0
39 180
111 1
69 123
13 43
69 101
41 54
62 139
147 7
56 53
144 111
74 9
20 92
53 1
111 114
94 68
24 25
18 136
160 86
50 128
96 87
173 113
25 112
34 79
7 129
144 73
130 149
138 178
14 67
61 80
178 27
119 43
30 37
43 34
165 76
167 53
19 29
30 91
169 176
118 119
56 84
22 43
180 103
59 74
110 17
15 59
...

output:

215220514

result:

ok single line: '215220514'

Test #18:

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

input:

0
34 190
84 94
36 110
67 60
189 47
167 106
158 84
84 46
8 49
170 136
98 84
89 100
126 54
84 142
84 5
128 168
146 106
14 79
159 41
149 84
58 84
144 84
113 124
84 31
84 56
72 111
71 88
84 114
126 61
125 84
84 111
16 141
84 67
91 84
179 64
173 137
131 84
39 157
108 151
123 84
84 184
65 79
84 112
135 24...

output:

518168388

result:

ok single line: '518168388'

Test #19:

score: 10
Accepted
time: 4ms
memory: 18928kb

input:

0
35 172
79 4
102 76
122 71
74 116
54 145
126 31
95 132
135 103
25 81
5 123
87 8
37 146
34 39
53 122
155 49
90 70
117 143
133 112
128 52
108 150
13 167
148 85
87 132
9 129
30 22
106 11
132 51
135 48
144 97
61 2
7 105
139 104
46 70
111 100
110 77
29 121
58 120
114 62
78 50
106 50
7 64
45 55
60 172
17...

output:

3523655

result:

ok single line: '3523655'

Test #20:

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

input:

0
40 200
15 152
120 15
193 39
15 107
184 101
9 15
177 167
15 42
140 87
15 139
96 5
61 156
15 161
196 59
157 50
166 179
124 100
177 15
187 15
15 81
15 70
78 165
66 154
188 99
198 15
142 139
103 15
134 15
15 150
15 59
15 169
62 176
144 160
15 86
143 134
158 15
15 116
93 107
15 195
121 195
15 118
54 47...

output:

648232010

result:

ok single line: '648232010'

Subtask #6:

score: 14
Accepted

Dependency #5:

100%
Accepted

Test #21:

score: 14
Accepted
time: 650ms
memory: 350436kb

input:

0
1000 4284
2024 1037
1494 1306
536 133
1961 981
1926 3517
3135 259
1313 2789
1200 2081
3576 1279
2712 239
1683 1843
767 2124
3405 3520
996 206
3925 2472
3124 3189
1738 1614
1953 2564
1053 3
36 436
390 134
3691 2635
1285 2419
3548 138
1150 18
101 27
3885 2893
2481 2684
509 3852
958 1392
2588 4193
33...

output:

370256058

result:

ok single line: '370256058'

Test #22:

score: 14
Accepted
time: 800ms
memory: 395544kb

input:

0
980 4730
4258 1867
4528 4258
4258 1316
4258 890
1736 4258
3352 493
2650 3031
1145 4258
4255 4271
824 4258
1372 4258
4258 1925
4258 4307
1326 1794
4258 2955
4258 4497
3163 1156
3917 4388
1776 4258
4258 3698
4675 4258
3353 4546
3547 4053
4258 3496
2823 4258
2608 4258
4258 697
1871 1970
2034 2987
359...

output:

558241818

result:

ok single line: '558241818'

Test #23:

score: 14
Accepted
time: 643ms
memory: 335828kb

input:

0
930 4160
3441 3412
1473 3722
2532 1198
2073 1049
627 810
752 3298
1924 2584
2094 575
1301 21
2330 687
2006 3905
4061 235
2046 3883
147 257
1480 3642
537 65
2387 21
3181 1276
3108 1349
1107 1805
2031 3993
2283 925
622 2868
3597 2806
2447 1476
2490 3552
3038 3643
2153 22
4087 2184
3687 273
4042 1158...

output:

669154252

result:

ok single line: '669154252'

Test #24:

score: 14
Accepted
time: 918ms
memory: 418484kb

input:

0
1000 5000
3894 1313
911 345
292 3894
3156 3894
2865 1404
4001 3894
2733 3436
180 4666
3588 3894
3894 4280
3894 3379
3866 3894
3149 3894
2250 4186
89 132
544 3777
3894 1412
3894 3687
3894 3150
4608 3894
2678 2187
3894 3252
3825 2167
1815 3298
2925 3894
631 3016
3894 91
1375 4625
3894 1928
3894 560
...

output:

142803865

result:

ok single line: '142803865'

Subtask #7:

score: 7
Accepted

Test #25:

score: 7
Accepted
time: 2ms
memory: 9972kb

input:

1
1 156
69 74
65 126
110 16
134 129
3 22
78 5
140 23
53 138
109 67
82 74
42 57
23 143
12 112
7 13
154 105
100 118
63 28
41 37
145 25
80 142
111 148
81 85
133 13
104 89
83 14
39 24
120 97
98 131
94 55
107 91
38 130
122 36
2 32
82 94
35 49
40 108
68 146
101 130
101 76
105 58
80 137
152 87
78 66
32 55
...

output:

261947439

result:

ok single line: '261947439'

Test #26:

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

input:

1
1 168
140 135
69 51
33 66
138 48
168 90
102 43
137 98
117 21
88 131
29 14
117 157
77 78
85 88
119 32
114 68
55 67
160 166
12 149
155 85
20 113
132 149
131 19
97 139
22 78
16 157
151 143
99 156
159 71
72 119
161 163
68 28
101 89
27 133
96 146
125 44
151 24
14 114
116 111
89 25
115 138
46 1
51 47
40...

output:

260505142

result:

ok single line: '260505142'

Test #27:

score: 7
Accepted
time: 2ms
memory: 9908kb

input:

1
1 155
77 28
89 81
138 11
85 7
124 53
29 52
116 32
151 66
103 80
145 77
82 51
116 138
141 144
57 20
34 101
14 84
75 68
42 64
95 117
117 137
122 33
76 50
12 71
112 44
134 83
134 18
105 10
75 122
106 94
84 69
1 123
140 10
70 71
78 133
24 152
87 13
9 31
135 142
101 146
149 129
28 16
52 39
26 119
146 3...

output:

252700555

result:

ok single line: '252700555'

Test #28:

score: 7
Accepted
time: 2ms
memory: 9968kb

input:

1
1 200
24 110
97 182
163 183
115 67
21 193
168 118
88 19
10 150
33 76
15 184
138 131
166 143
151 167
17 60
188 92
110 33
9 65
186 74
198 170
144 161
69 134
179 189
191 70
64 79
10 84
65 107
66 149
123 191
184 141
107 30
170 129
159 186
108 132
17 68
46 198
158 41
13 55
101 59
20 72
200 63
128 23
89...

output:

85910356

result:

ok single line: '85910356'

Subtask #8:

score: 7
Accepted

Dependency #7:

100%
Accepted

Test #29:

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

input:

1
1 170
104 123
43 65
8 61
169 138
20 160
34 169
133 25
129 2
115 137
64 168
33 35
77 38
128 166
159 151
78 3
155 34
6 140
16 133
26 117
13 143
144 150
7 131
64 61
162 52
149 16
17 80
136 77
141 83
54 146
85 47
140 24
107 158
91 152
66 43
24 21
86 38
141 85
51 11
162 151
2 66
73 74
9 26
156 68
121 1...

output:

83894725

result:

ok single line: '83894725'

Test #30:

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

input:

1
1 168
46 92
25 154
91 121
21 31
100 152
24 35
115 67
139 111
113 90
88 69
134 83
127 120
74 23
22 108
28 18
58 36
15 125
100 167
3 127
112 34
7 25
3 23
40 13
29 138
124 118
33 143
8 32
17 58
20 120
12 148
158 130
115 122
26 29
90 157
111 73
57 64
79 80
153 159
89 73
50 79
62 105
109 135
96 32
27 1...

output:

314954106

result:

ok single line: '314954106'

Test #31:

score: 7
Accepted
time: 2ms
memory: 10004kb

input:

1
1 173
71 145
155 153
150 80
164 52
158 173
116 96
169 100
59 20
143 151
43 73
66 38
77 161
39 91
166 11
35 136
4 145
65 37
163 67
138 140
170 31
28 124
85 104
27 2
50 129
76 82
69 155
36 33
86 112
58 23
89 40
47 3
64 27
94 110
36 22
47 67
99 19
165 134
55 131
16 118
68 144
45 53
52 35
125 6
120 77...

output:

223769237

result:

ok single line: '223769237'

Test #32:

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

input:

1
1 200
14 29
23 169
138 142
67 145
166 102
126 183
108 69
170 70
85 194
79 132
174 154
30 130
133 21
93 86
68 183
83 168
160 114
4 94
33 11
109 16
98 18
115 27
52 146
88 103
54 7
49 158
121 110
159 55
190 177
193 85
63 8
155 140
43 117
149 93
169 48
125 133
180 95
189 199
78 162
24 144
84 5
135 39
...

output:

792535599

result:

ok single line: '792535599'

Subtask #9:

score: 10
Accepted

Dependency #8:

100%
Accepted

Test #33:

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

input:

1
2 160
85 103
57 106
55 79
43 92
96 116
100 68
93 88
103 24
70 144
7 12
142 123
95 77
134 15
16 153
98 74
8 150
56 142
47 58
91 54
65 59
77 131
101 47
17 8
10 5
61 97
89 115
46 96
92 36
43 34
159 139
73 28
66 151
44 76
18 13
33 76
127 67
4 33
9 102
126 9
133 141
88 109
32 27
50 117
128 140
126 10
7...

output:

138251585

result:

ok single line: '138251585'

Test #34:

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

input:

1
2 170
18 31
34 76
122 66
130 150
32 115
155 69
153 46
77 92
26 83
15 109
93 116
142 62
133 25
99 114
117 37
64 102
152 122
143 86
157 110
10 16
98 51
96 139
52 45
55 108
78 166
137 142
160 80
45 40
7 94
132 54
9 81
153 141
54 70
4 60
127 91
13 26
120 152
124 161
94 82
106 61
121 30
111 77
160 165
...

output:

402212722

result:

ok single line: '402212722'

Test #35:

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

input:

1
2 165
164 110
44 89
147 71
66 57
104 142
60 31
125 62
163 158
141 161
15 157
109 54
114 108
143 45
25 10
83 75
88 36
118 122
97 72
79 19
19 72
148 153
79 132
153 3
23 130
7 91
148 17
10 46
78 65
151 85
16 128
137 82
136 162
126 75
72 1
101 117
50 60
43 132
69 63
27 94
110 155
162 33
107 140
124 20...

output:

239138702

result:

ok single line: '239138702'

Test #36:

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

input:

1
2 200
48 108
140 189
123 65
47 102
83 53
173 26
176 45
32 167
99 155
7 91
58 136
85 35
40 147
49 70
75 163
94 114
25 16
128 3
47 172
20 191
4 120
187 38
52 98
30 162
151 85
96 124
169 125
175 74
183 163
178 78
192 154
63 76
175 88
136 5
150 83
54 191
134 145
181 60
151 160
152 141
142 66
100 52
15...

output:

94911555

result:

ok single line: '94911555'

Subtask #10:

score: 10
Accepted

Dependency #9:

100%
Accepted

Test #37:

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

input:

1
31 151
94 56
7 113
142 50
51 81
131 1
25 10
74 106
87 68
43 76
25 91
128 116
12 61
75 34
43 5
36 53
13 41
48 51
40 73
89 69
59 34
62 10
133 107
89 49
139 53
91 97
125 23
35 44
22 135
98 105
4 83
49 26
100 48
2 110
28 52
3 96
46 96
15 6
132 78
109 73
145 81
69 102
54 92
30 56
74 117
11 146
70 26
99...

output:

494673301

result:

ok single line: '494673301'

Test #38:

score: 10
Accepted
time: 3ms
memory: 10000kb

input:

1
36 194
118 43
73 36
56 124
49 9
173 28
81 113
156 117
151 110
5 117
67 187
18 146
70 177
38 65
59 120
115 13
165 78
75 152
146 87
39 48
151 185
85 120
101 62
177 174
133 166
160 105
84 43
128 149
193 49
153 126
99 78
123 98
116 159
106 98
61 20
48 54
182 114
31 92
50 159
45 102
18 50
178 62
147 14...

output:

248295050

result:

ok single line: '248295050'

Test #39:

score: 10
Accepted
time: 3ms
memory: 10004kb

input:

1
36 164
110 58
147 116
133 17
26 1
160 143
11 112
123 113
97 37
138 132
73 80
67 56
138 142
40 33
115 153
52 6
126 81
124 76
122 83
135 114
67 129
109 89
62 76
36 98
57 91
63 64
85 41
155 118
86 13
12 63
77 15
117 54
146 112
118 26
70 72
74 55
128 98
50 28
30 139
29 78
108 66
105 7
21 78
151 104
11...

output:

273498099

result:

ok single line: '273498099'

Test #40:

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

input:

1
40 200
103 35
185 125
34 90
176 65
48 50
42 77
80 105
82 151
144 26
59 173
81 142
41 192
167 198
131 20
126 6
19 179
122 170
116 120
86 178
147 149
89 168
111 6
3 100
24 166
18 34
169 74
17 95
8 73
46 184
154 52
92 83
129 164
190 77
90 37
87 144
200 70
131 16
113 161
181 98
99 139
150 43
200 78
12...

output:

6219604

result:

ok single line: '6219604'

Subtask #11:

score: 11
Accepted

Dependency #10:

100%
Accepted

Test #41:

score: 11
Accepted
time: 769ms
memory: 14564kb

input:

1
820 4113
2108 233
4008 3416
4006 2604
1450 3610
1459 246
3094 1565
3052 3604
3985 3162
1804 92
2848 785
259 2585
2085 1942
1910 68
1191 4039
955 4056
1005 4030
2495 3228
4089 2400
439 2097
2861 663
649 3609
3112 3272
3690 1220
2456 1644
2912 2530
408 2209
2105 2253
851 51
419 3407
2193 2784
280 26...

output:

728750489

result:

ok single line: '728750489'

Test #42:

score: 11
Accepted
time: 795ms
memory: 13768kb

input:

1
919 3763
671 1387
863 3725
1050 3483
219 1528
2871 1049
1787 2307
366 783
1672 1645
420 811
1524 369
740 2151
2160 2692
1348 1150
2917 3299
879 1377
682 1861
3044 775
505 3740
3032 3005
3459 1074
298 698
3257 3694
548 2394
1365 2769
1250 3627
1752 485
1704 3455
793 2764
2111 806
3334 486
2178 2719...

output:

617892430

result:

ok single line: '617892430'

Test #43:

score: 11
Accepted
time: 738ms
memory: 13376kb

input:

1
785 4171
2289 39
3598 563
1549 2149
668 3461
2945 2471
1956 2552
2892 3836
2573 1834
2927 1909
1371 7
874 2271
3975 2907
3223 1098
3083 3893
652 1379
2043 955
1038 4154
2536 1289
3275 3257
3215 198
221 4026
537 3465
3470 646
4128 827
980 3796
142 3490
208 2701
3262 4114
1862 2408
1073 2695
4049 27...

output:

286098367

result:

ok single line: '286098367'

Test #44:

score: 11
Accepted
time: 1136ms
memory: 14756kb

input:

1
1000 5000
233 1051
3865 2813
3677 4977
2643 1598
495 1347
4910 1009
2728 288
2631 2123
3621 1471
2014 2079
2423 4772
2156 592
1687 3441
1394 4842
946 3367
925 3249
1553 892
3670 2729
2112 861
2987 1987
581 1751
1691 103
934 1488
766 4655
3017 2370
3504 1834
1288 2662
1498 3550
238 1058
4776 1182
1...

output:

25113695

result:

ok single line: '25113695'