QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54819#2963. Protect the Pollen!Beevo#AC ✓750ms225460kbC++231.4kb2022-10-10 17:37:592022-10-10 17:38:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-10 17:38:01]
  • 评测
  • 测评结果:AC
  • 用时:750ms
  • 内存:225460kb
  • [2022-10-10 17:37:59]
  • 提交

answer

#include <bits/stdc++.h>

#define el '\n'
#define ll long long
#define ld long double

#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 300 + 5, INF = 1e9;

int s[N], p[N];
int dp[N][N][N][2];
vector<int> g[N];

// cur = 1 ? removed
int solve(int u, int rem, int idx, bool cur, int par) {
    if (rem < 0)
        return -INF;

    if (idx >= g[u].size())
        return 0;

    int &ret = dp[u][rem][idx][cur];

    if (~ret)
        return ret;

    ret = 0;

    if (g[u][idx] == par)
        ret = solve(u, rem, idx + 1, cur, par);
    else {
        for (int i = 0; i <= rem; i++) {
            ret = max(ret, solve(g[u][idx], i, 0, 0, u) + solve(u, rem - i, idx + 1, cur, par));

            if (!cur)
                ret = max(ret, p[g[u][idx]] + solve(g[u][idx], i - s[g[u][idx]], 0, 1, u) + solve(u, rem - i, idx + 1, 0, par));
        }
    }

    return ret;
}

void testCase() {
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++)
        cin >> s[i] >> p[i];

    int u, v;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;

        g[u].push_back(v);
        g[v].push_back(u);
    }

    memset(dp, -1, sizeof dp);

    cout << max(solve(1, k, 0, 0, 0), solve(1, k - s[1], 0, 1, 0) + p[1]);
}

signed main() {
    Beevo

    int T = 1;
//    cin >> T;

    while (T--)
        testCase();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 20ms
memory: 225268kb

input:

5 10
2 1
2 2
2 4
2 8
2 16
1 2
2 3
3 4
4 5

output:

21

result:

ok single line: '21'

Test #2:

score: 0
Accepted
time: 33ms
memory: 225248kb

input:

7 10
1 7
2 4
5 18
2 3
3 12
9 20
2 8
1 2
1 3
2 4
2 5
3 6
3 7

output:

33

result:

ok single line: '33'

Test #3:

score: 0
Accepted
time: 25ms
memory: 225252kb

input:

10 10
272 37
78 1
278 44
49 57
235 23
112 8
203 96
67 82
65 90
169 13
4 3
3 9
9 7
7 6
6 10
10 2
2 5
5 8
8 1

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 49ms
memory: 225308kb

input:

10 10
1 9
1 37
1 95
1 68
1 95
1 6
1 60
1 94
1 42
1 94
2 8
8 1
1 4
4 7
7 10
10 5
5 6
6 9
9 3

output:

357

result:

ok single line: '357'

Test #5:

score: 0
Accepted
time: 25ms
memory: 225280kb

input:

10 10
9 23
9 6
9 94
9 98
9 6
9 70
9 44
9 60
9 94
9 19
5 4
4 10
10 1
1 8
8 2
2 6
6 3
3 7
7 9

output:

98

result:

ok single line: '98'

Test #6:

score: 0
Accepted
time: 35ms
memory: 225136kb

input:

10 10
196 76
274 17
235 29
223 55
85 93
267 37
142 49
153 3
272 55
91 8
4 5
4 9
5 1
5 7
9 10
9 8
1 3
1 6
7 2

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 28ms
memory: 225228kb

input:

10 10
1 66
1 65
1 85
1 12
1 7
1 97
1 22
1 50
1 44
1 81
8 4
8 6
4 10
4 2
6 5
6 7
10 9
10 3
2 1

output:

304

result:

ok single line: '304'

Test #8:

score: 0
Accepted
time: 29ms
memory: 225280kb

input:

10 10
10 89
10 80
10 17
10 58
10 15
10 54
10 77
10 13
10 29
10 57
1 7
1 4
7 6
7 5
4 2
4 8
6 10
6 9
5 3

output:

89

result:

ok single line: '89'

Test #9:

score: 0
Accepted
time: 49ms
memory: 225324kb

input:

10 10
271 11
158 100
171 87
125 73
180 42
121 52
51 17
260 25
142 50
299 65
9 1
9 10
9 6
9 7
10 2
10 3
6 8
8 5
8 4

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 46ms
memory: 225132kb

input:

10 10
1 91
1 61
1 52
1 28
1 95
1 4
1 98
1 53
1 94
1 20
8 6
8 3
8 7
8 10
3 1
3 4
7 2
2 9
2 5

output:

430

result:

ok single line: '430'

Test #11:

score: 0
Accepted
time: 23ms
memory: 225328kb

input:

10 10
1 58
1 27
1 18
1 46
1 16
1 44
1 91
1 61
1 36
1 24
8 10
8 9
8 5
8 1
9 2
9 4
5 7
7 6
7 3

output:

246

result:

ok single line: '246'

Test #12:

score: 0
Accepted
time: 47ms
memory: 225196kb

input:

10 10
137 12
93 34
211 47
234 46
125 61
58 91
248 36
145 59
28 70
40 43
9 4
9 10
9 7
9 3
9 8
9 1
9 2
9 5
9 6

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 447ms
memory: 225240kb

input:

300 300
76 63
26 78
245 91
212 66
249 70
84 7
72 70
285 32
20 31
132 86
184 4
110 52
61 38
180 64
130 49
186 16
194 68
214 89
97 32
187 92
259 51
119 86
124 62
151 82
51 12
17 12
247 75
298 63
94 98
210 2
126 56
141 31
165 89
133 35
172 97
112 26
129 60
12 88
132 18
160 39
227 31
197 58
215 88
158 2...

output:

1119

result:

ok single line: '1119'

Test #14:

score: 0
Accepted
time: 575ms
memory: 225424kb

input:

300 300
1 20
1 91
1 80
1 30
1 56
1 33
1 4
1 48
1 21
1 86
1 23
1 90
1 79
1 60
1 60
1 94
1 59
1 59
1 46
1 1
1 22
1 70
1 23
1 76
1 88
1 86
1 98
1 72
1 39
1 2
1 32
1 83
1 91
1 54
1 24
1 46
1 56
1 59
1 44
1 75
1 11
1 47
1 100
1 1
1 54
1 20
1 78
1 88
1 10
1 13
1 4
1 51
1 11
1 21
1 62
1 98
1 84
1 56
1 42
1...

output:

10545

result:

ok single line: '10545'

Test #15:

score: 0
Accepted
time: 423ms
memory: 225272kb

input:

300 300
219 62
219 67
219 16
219 92
219 2
219 53
219 68
219 5
219 89
219 86
219 8
219 21
219 26
219 74
219 88
219 71
219 70
219 34
219 56
219 90
219 34
219 7
219 25
219 49
219 41
219 91
219 62
219 81
219 82
219 39
219 100
219 37
219 29
219 44
219 79
219 95
219 14
219 93
219 42
219 58
219 78
219 68
2...

output:

100

result:

ok single line: '100'

Test #16:

score: 0
Accepted
time: 449ms
memory: 225240kb

input:

300 300
189 86
34 43
98 87
243 21
259 31
57 59
249 51
269 56
39 37
180 12
172 48
173 65
127 62
22 85
102 68
109 64
173 90
194 74
56 19
248 75
3 63
80 13
113 14
192 53
246 58
160 75
14 44
62 49
36 78
160 4
46 18
35 83
146 49
100 81
89 90
24 88
31 30
255 45
62 75
194 98
225 97
288 8
150 98
250 76
58 5...

output:

1247

result:

ok single line: '1247'

Test #17:

score: 0
Accepted
time: 572ms
memory: 225380kb

input:

300 300
1 83
1 97
1 67
1 93
1 2
1 34
1 80
1 13
1 75
1 40
1 67
1 82
1 6
1 33
1 7
1 94
1 33
1 31
1 96
1 16
1 99
1 1
1 53
1 99
1 76
1 47
1 59
1 46
1 51
1 48
1 45
1 82
1 51
1 58
1 62
1 87
1 97
1 75
1 10
1 50
1 56
1 67
1 72
1 84
1 49
1 8
1 44
1 15
1 95
1 77
1 19
1 24
1 60
1 76
1 88
1 4
1 2
1 6
1 38
1 97
...

output:

10463

result:

ok single line: '10463'

Test #18:

score: 0
Accepted
time: 461ms
memory: 225356kb

input:

300 300
142 4
142 12
142 7
142 57
142 99
142 30
142 100
142 58
142 69
142 81
142 80
142 27
142 40
142 68
142 57
142 74
142 48
142 48
142 9
142 20
142 17
142 25
142 54
142 11
142 8
142 62
142 50
142 39
142 84
142 72
142 17
142 81
142 86
142 95
142 42
142 65
142 33
142 94
142 85
142 38
142 95
142 80
1...

output:

199

result:

ok single line: '199'

Test #19:

score: 0
Accepted
time: 514ms
memory: 225392kb

input:

300 300
77 29
240 71
70 22
128 74
182 38
264 91
51 59
144 63
10 54
229 2
22 33
121 19
267 21
47 65
25 82
213 93
134 77
283 40
198 60
221 86
142 99
269 91
292 51
156 46
261 21
72 75
271 42
130 21
285 68
54 36
210 22
281 18
249 65
159 79
141 99
231 51
134 79
205 20
208 54
258 46
25 32
193 29
87 30
147...

output:

1353

result:

ok single line: '1353'

Test #20:

score: 0
Accepted
time: 750ms
memory: 225244kb

input:

300 300
1 89
1 17
1 67
1 60
1 23
1 23
1 54
1 68
1 8
1 16
1 29
1 76
1 32
1 78
1 8
1 77
1 70
1 91
1 19
1 60
1 69
1 32
1 75
1 88
1 58
1 98
1 20
1 85
1 2
1 47
1 51
1 27
1 53
1 92
1 7
1 41
1 19
1 84
1 37
1 34
1 17
1 64
1 15
1 82
1 40
1 34
1 89
1 70
1 11
1 23
1 10
1 41
1 55
1 93
1 86
1 29
1 31
1 77
1 50
1...

output:

15280

result:

ok single line: '15280'

Test #21:

score: 0
Accepted
time: 690ms
memory: 225244kb

input:

300 300
30 87
30 30
30 61
30 9
30 88
30 94
30 2
30 65
30 48
30 57
30 2
30 79
30 74
30 52
30 47
30 40
30 90
30 46
30 42
30 36
30 28
30 97
30 25
30 30
30 13
30 70
30 81
30 55
30 86
30 15
30 48
30 79
30 53
30 36
30 83
30 28
30 46
30 63
30 45
30 95
30 84
30 56
30 11
30 57
30 57
30 8
30 80
30 84
30 79
30...

output:

986

result:

ok single line: '986'

Test #22:

score: 0
Accepted
time: 33ms
memory: 225272kb

input:

100 100
101 71
101 33
101 25
101 93
101 13
101 31
101 40
101 96
101 88
101 81
101 42
101 54
101 74
101 96
101 78
101 17
101 16
101 73
101 54
101 1
101 50
101 95
101 19
101 46
101 37
101 91
101 42
101 83
101 1
101 8
101 18
101 49
101 87
101 64
101 96
101 1
101 24
101 98
101 99
101 92
101 10
101 78
10...

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Accepted
time: 52ms
memory: 225268kb

input:

10 10
1 52
1 17
1 66
1 3
1 27
1 65
1 77
1 98
1 48
1 55
7 6
7 2
7 9
7 10
7 5
7 8
7 4
7 3
7 1

output:

431

result:

ok single line: '431'

Test #24:

score: 0
Accepted
time: 532ms
memory: 225240kb

input:

300 300
128 48
1 42
128 78
4 99
16 81
64 62
256 55
128 60
256 47
32 43
256 31
2 2
1 73
4 33
1 87
256 15
32 16
32 42
2 48
16 45
128 15
32 92
1 53
128 83
16 74
8 89
8 80
4 75
1 84
2 77
128 8
16 95
64 30
8 12
64 7
2 86
64 90
2 51
128 19
16 61
128 13
32 12
32 11
1 97
64 100
32 66
8 16
1 86
2 62
2 23
8 5...

output:

5667

result:

ok single line: '5667'

Test #25:

score: 0
Accepted
time: 24ms
memory: 225132kb

input:

1 1
1 42

output:

42

result:

ok single line: '42'

Test #26:

score: 0
Accepted
time: 20ms
memory: 225232kb

input:

10 10
9 65
9 10
9 91
9 64
9 28
9 77
9 36
9 54
9 62
9 47
7 5
7 2
7 3
7 4
7 1
7 8
7 10
7 9
7 6

output:

91

result:

ok single line: '91'

Test #27:

score: 0
Accepted
time: 46ms
memory: 225340kb

input:

10 100
150 75
101 71
18 71
161 64
154 80
101 93
214 47
194 100
52 68
160 47
9 7
7 3
3 6
6 2
2 4
4 5
5 1
1 8
8 10

output:

139

result:

ok single line: '139'

Test #28:

score: 0
Accepted
time: 20ms
memory: 225384kb

input:

10 100
1 80
1 45
1 37
1 85
1 83
1 90
1 98
1 78
1 51
1 24
10 1
1 7
7 2
2 6
6 4
4 9
9 5
5 3
3 8

output:

373

result:

ok single line: '373'

Test #29:

score: 0
Accepted
time: 24ms
memory: 225228kb

input:

10 100
28 28
28 78
28 7
28 100
28 90
28 63
28 61
28 84
28 31
28 40
6 5
5 2
2 7
7 10
10 4
4 3
3 9
9 8
8 1

output:

274

result:

ok single line: '274'

Test #30:

score: 0
Accepted
time: 40ms
memory: 225196kb

input:

10 100
288 12
53 100
179 21
281 89
239 83
51 21
298 99
283 54
272 18
254 87
10 4
10 1
4 3
4 2
1 8
1 5
3 6
3 9
2 7

output:

100

result:

ok single line: '100'

Test #31:

score: 0
Accepted
time: 21ms
memory: 225256kb

input:

10 100
1 95
1 10
1 81
1 82
1 28
1 70
1 28
1 46
1 88
1 83
9 5
9 10
5 4
5 3
10 7
10 1
4 8
4 6
3 2

output:

408

result:

ok single line: '408'

Test #32:

score: 0
Accepted
time: 28ms
memory: 225272kb

input:

10 100
62 22
62 36
62 55
62 51
62 89
62 25
62 93
62 12
62 39
62 71
6 7
6 1
7 9
7 10
1 3
1 5
9 8
9 4
10 2

output:

93

result:

ok single line: '93'

Test #33:

score: 0
Accepted
time: 24ms
memory: 225256kb

input:

10 100
28 12
154 29
16 25
277 58
43 63
9 51
57 79
72 27
286 91
166 53
1 5
1 9
5 8
5 6
8 2
6 7
6 4
7 3
3 10

output:

142

result:

ok single line: '142'

Test #34:

score: 0
Accepted
time: 37ms
memory: 225340kb

input:

10 100
1 76
1 29
1 41
1 29
1 79
1 88
1 29
1 99
1 51
1 74
3 9
3 4
9 10
9 1
10 8
1 5
1 6
5 7
7 2

output:

375

result:

ok single line: '375'

Test #35:

score: 0
Accepted
time: 28ms
memory: 225264kb

input:

10 100
91 55
91 98
91 99
91 19
91 62
91 45
91 75
91 23
91 51
91 95
2 9
2 4
9 8
9 10
8 7
10 5
10 3
5 6
6 1

output:

99

result:

ok single line: '99'

Test #36:

score: 0
Accepted
time: 28ms
memory: 225272kb

input:

10 100
206 95
160 44
203 58
117 21
85 20
67 2
300 97
100 14
85 89
184 8
6 9
6 1
6 2
6 3
6 5
6 10
6 7
6 8
6 4

output:

89

result:

ok single line: '89'

Test #37:

score: 0
Accepted
time: 32ms
memory: 225248kb

input:

10 100
1 21
1 47
1 35
1 50
1 34
1 43
1 13
1 69
1 6
1 91
3 1
3 7
3 6
3 10
3 8
3 5
3 9
3 2
3 4

output:

374

result:

ok single line: '374'

Test #38:

score: 0
Accepted
time: 28ms
memory: 225416kb

input:

10 100
12 85
12 15
12 99
12 85
12 25
12 22
12 19
12 12
12 36
12 39
9 8
9 1
9 10
9 7
9 3
9 2
9 6
9 4
9 5

output:

389

result:

ok single line: '389'

Test #39:

score: 0
Accepted
time: 31ms
memory: 225308kb

input:

10 300
144 36
56 10
55 94
29 62
82 9
205 61
218 78
260 13
13 32
81 51
2 10
10 6
6 8
8 1
1 3
3 9
9 7
7 4
4 5

output:

217

result:

ok single line: '217'

Test #40:

score: 0
Accepted
time: 37ms
memory: 225308kb

input:

10 300
1 86
1 22
1 82
1 22
1 52
1 55
1 69
1 3
1 83
1 17
7 8
8 3
3 6
6 5
5 2
2 1
1 10
10 9
9 4

output:

372

result:

ok single line: '372'

Test #41:

score: 0
Accepted
time: 45ms
memory: 225280kb

input:

10 300
130 36
130 32
130 97
130 51
130 4
130 4
130 87
130 21
130 38
130 43
5 7
7 1
1 9
9 8
8 3
3 4
4 2
2 6
6 10

output:

184

result:

ok single line: '184'

Test #42:

score: 0
Accepted
time: 43ms
memory: 225216kb

input:

10 300
124 24
151 45
59 79
122 61
57 48
231 48
161 86
115 4
23 25
44 63
5 1
5 2
1 4
1 8
2 7
2 6
4 9
4 10
8 3

output:

253

result:

ok single line: '253'

Test #43:

score: 0
Accepted
time: 39ms
memory: 225364kb

input:

10 300
1 48
1 15
1 95
1 34
1 81
1 26
1 8
1 62
1 8
1 46
2 3
2 6
3 1
3 5
6 7
6 10
1 4
1 9
5 8

output:

253

result:

ok single line: '253'

Test #44:

score: 0
Accepted
time: 35ms
memory: 225364kb

input:

10 300
220 71
220 56
220 20
220 17
220 70
220 97
220 75
220 13
220 60
220 1
6 3
6 8
3 2
3 5
8 4
8 10
2 1
2 9
5 7

output:

97

result:

ok single line: '97'

Test #45:

score: 0
Accepted
time: 32ms
memory: 225368kb

input:

10 300
92 6
248 42
209 51
61 68
92 95
27 5
252 17
219 22
193 16
15 84
1 3
1 5
3 10
5 7
5 2
7 4
4 8
8 9
8 6

output:

252

result:

ok single line: '252'

Test #46:

score: 0
Accepted
time: 51ms
memory: 225192kb

input:

10 300
1 23
1 52
1 86
1 23
1 45
1 92
1 46
1 17
1 35
1 65
8 2
8 1
2 9
1 5
1 7
5 4
4 3
3 6
3 10

output:

300

result:

ok single line: '300'

Test #47:

score: 0
Accepted
time: 47ms
memory: 225344kb

input:

10 300
91 53
91 25
91 76
91 59
91 62
91 45
91 40
91 92
91 53
91 72
7 4
7 1
4 8
1 3
1 5
3 2
2 10
10 9
10 6

output:

240

result:

ok single line: '240'

Test #48:

score: 0
Accepted
time: 40ms
memory: 225228kb

input:

10 300
115 71
296 23
1 23
219 8
286 94
152 56
282 88
151 79
57 31
179 16
4 7
4 2
4 3
4 8
4 9
4 1
4 5
4 6
4 10

output:

173

result:

ok single line: '173'

Test #49:

score: 0
Accepted
time: 44ms
memory: 225248kb

input:

10 300
1 100
1 57
1 62
1 37
1 33
1 38
1 35
1 76
1 13
1 75
1 9
1 10
1 3
1 4
1 5
1 2
1 8
1 7
1 6

output:

426

result:

ok single line: '426'

Test #50:

score: 0
Accepted
time: 43ms
memory: 225252kb

input:

10 300
21 38
21 20
21 34
21 5
21 50
21 3
21 83
21 9
21 81
21 20
8 7
8 1
8 9
8 5
8 10
8 4
8 2
8 6
8 3

output:

334

result:

ok single line: '334'

Test #51:

score: 0
Accepted
time: 55ms
memory: 225324kb

input:

100 10
114 88
158 40
234 10
51 58
42 100
72 43
257 93
203 8
270 57
256 87
280 61
255 17
23 10
272 93
126 73
164 11
135 92
114 88
5 88
198 69
37 83
53 17
59 46
42 48
117 65
298 2
295 67
51 10
115 43
295 60
212 13
293 21
243 67
204 61
129 95
113 83
245 90
186 40
263 90
192 90
291 8
121 58
108 64
119 8...

output:

126

result:

ok single line: '126'

Test #52:

score: 0
Accepted
time: 44ms
memory: 225280kb

input:

100 10
1 6
1 50
1 35
1 30
1 15
1 27
1 92
1 14
1 2
1 81
1 49
1 69
1 81
1 51
1 82
1 34
1 32
1 69
1 51
1 91
1 1
1 43
1 45
1 92
1 87
1 33
1 12
1 90
1 90
1 37
1 68
1 1
1 47
1 78
1 91
1 70
1 91
1 19
1 90
1 69
1 1
1 99
1 66
1 18
1 31
1 94
1 95
1 84
1 61
1 100
1 93
1 10
1 96
1 68
1 4
1 68
1 63
1 92
1 64
1 8...

output:

959

result:

ok single line: '959'

Test #53:

score: 0
Accepted
time: 39ms
memory: 225276kb

input:

100 10
3 33
3 32
3 65
3 81
3 87
3 81
3 48
3 59
3 19
3 9
3 9
3 31
3 87
3 80
3 68
3 44
3 71
3 65
3 23
3 56
3 46
3 42
3 66
3 18
3 35
3 17
3 5
3 36
3 43
3 8
3 16
3 6
3 45
3 61
3 85
3 78
3 10
3 15
3 37
3 61
3 22
3 47
3 33
3 53
3 35
3 93
3 40
3 85
3 11
3 12
3 53
3 66
3 72
3 57
3 15
3 42
3 49
3 59
3 38
3 9...

output:

283

result:

ok single line: '283'

Test #54:

score: 0
Accepted
time: 53ms
memory: 225348kb

input:

100 10
208 75
171 30
179 23
265 58
96 52
211 87
71 89
257 59
56 95
245 22
158 26
49 60
38 90
300 88
61 56
288 75
14 17
69 91
191 78
170 40
17 70
35 97
192 56
248 34
176 32
244 64
163 52
259 94
185 38
128 15
285 69
271 18
212 22
105 64
179 67
201 36
130 89
76 90
254 100
67 100
74 31
192 86
181 67
247...

output:

89

result:

ok single line: '89'

Test #55:

score: 0
Accepted
time: 27ms
memory: 225344kb

input:

100 10
1 27
1 53
1 26
1 45
1 12
1 43
1 92
1 83
1 29
1 13
1 5
1 51
1 85
1 100
1 19
1 71
1 55
1 67
1 12
1 11
1 82
1 4
1 81
1 38
1 24
1 99
1 41
1 48
1 60
1 93
1 5
1 73
1 61
1 60
1 84
1 92
1 39
1 57
1 96
1 43
1 76
1 59
1 18
1 66
1 19
1 8
1 6
1 30
1 30
1 64
1 34
1 48
1 52
1 35
1 90
1 57
1 41
1 80
1 33
1 ...

output:

949

result:

ok single line: '949'

Test #56:

score: 0
Accepted
time: 23ms
memory: 225360kb

input:

100 10
8 8
8 55
8 91
8 3
8 18
8 63
8 14
8 58
8 98
8 74
8 14
8 82
8 8
8 37
8 26
8 6
8 76
8 93
8 47
8 57
8 16
8 42
8 96
8 91
8 38
8 34
8 33
8 52
8 14
8 40
8 1
8 42
8 36
8 97
8 60
8 3
8 20
8 34
8 23
8 61
8 50
8 17
8 98
8 28
8 20
8 53
8 76
8 1
8 78
8 99
8 3
8 95
8 84
8 52
8 92
8 43
8 56
8 5
8 65
8 40
8 ...

output:

99

result:

ok single line: '99'

Test #57:

score: 0
Accepted
time: 35ms
memory: 225420kb

input:

100 10
54 86
257 61
69 37
197 22
88 61
211 93
279 8
283 9
253 83
294 73
261 48
36 44
176 50
75 95
85 33
262 74
231 33
37 78
109 94
263 93
18 46
179 23
127 45
158 14
148 62
50 78
31 79
49 16
138 64
29 78
140 39
221 60
268 47
60 94
205 3
112 2
224 38
265 54
143 93
269 60
110 70
196 24
58 76
273 92
210...

output:

0

result:

ok single line: '0'

Test #58:

score: 0
Accepted
time: 35ms
memory: 225272kb

input:

100 10
1 69
1 16
1 80
1 89
1 36
1 36
1 26
1 68
1 75
1 7
1 65
1 57
1 14
1 18
1 93
1 30
1 21
1 74
1 5
1 15
1 73
1 27
1 46
1 16
1 53
1 9
1 43
1 71
1 38
1 19
1 79
1 30
1 24
1 35
1 76
1 87
1 24
1 28
1 100
1 63
1 19
1 2
1 6
1 1
1 15
1 49
1 17
1 66
1 25
1 92
1 80
1 32
1 47
1 1
1 40
1 56
1 19
1 35
1 21
1 72...

output:

914

result:

ok single line: '914'

Test #59:

score: 0
Accepted
time: 32ms
memory: 225236kb

input:

100 10
9 11
9 39
9 20
9 40
9 91
9 3
9 63
9 45
9 96
9 34
9 50
9 84
9 19
9 81
9 23
9 8
9 17
9 58
9 70
9 74
9 56
9 79
9 44
9 45
9 43
9 40
9 75
9 64
9 63
9 33
9 88
9 49
9 6
9 2
9 33
9 78
9 87
9 99
9 29
9 10
9 100
9 91
9 37
9 63
9 4
9 12
9 9
9 11
9 1
9 86
9 60
9 79
9 37
9 16
9 95
9 44
9 51
9 26
9 32
9 60...

output:

100

result:

ok single line: '100'

Test #60:

score: 0
Accepted
time: 40ms
memory: 225212kb

input:

100 10
88 29
175 61
213 29
222 24
206 83
177 84
262 34
95 86
163 71
197 55
143 14
108 85
12 85
114 24
284 62
286 92
73 30
49 21
44 24
200 75
282 37
34 37
59 75
185 48
111 93
9 54
103 53
222 33
220 13
285 51
285 28
195 52
73 71
134 63
105 97
288 97
89 54
70 86
44 22
35 94
86 2
255 84
66 50
230 86
166...

output:

161

result:

ok single line: '161'

Test #61:

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

input:

100 10
1 59
1 72
1 59
1 12
1 53
1 79
1 76
1 56
1 72
1 48
1 42
1 50
1 46
1 33
1 89
1 60
1 46
1 39
1 43
1 39
1 93
1 7
1 98
1 53
1 48
1 77
1 76
1 68
1 3
1 44
1 42
1 79
1 6
1 2
1 49
1 25
1 52
1 38
1 36
1 98
1 18
1 6
1 20
1 96
1 61
1 26
1 62
1 84
1 15
1 77
1 27
1 91
1 15
1 67
1 79
1 86
1 53
1 30
1 15
1 3...

output:

927

result:

ok single line: '927'

Test #62:

score: 0
Accepted
time: 28ms
memory: 225376kb

input:

100 10
3 58
3 85
3 48
3 32
3 40
3 48
3 15
3 82
3 11
3 71
3 77
3 30
3 34
3 17
3 18
3 82
3 70
3 55
3 87
3 32
3 39
3 47
3 47
3 55
3 7
3 3
3 38
3 96
3 69
3 50
3 66
3 79
3 87
3 12
3 66
3 90
3 79
3 53
3 14
3 54
3 100
3 44
3 66
3 55
3 33
3 68
3 32
3 88
3 34
3 51
3 100
3 12
3 90
3 98
3 2
3 57
3 67
3 6
3 63
...

output:

300

result:

ok single line: '300'

Test #63:

score: 0
Accepted
time: 53ms
memory: 225296kb

input:

100 100
197 88
221 80
270 13
289 31
220 37
196 43
97 40
224 36
33 9
115 83
113 97
285 98
180 93
207 95
9 94
109 66
127 85
48 40
289 8
207 87
51 72
41 20
170 6
14 78
74 65
240 23
160 40
9 75
214 98
193 84
115 25
102 27
137 39
113 37
216 14
65 96
191 90
117 65
211 24
64 87
61 1
22 15
296 61
147 95
116...

output:

562

result:

ok single line: '562'

Test #64:

score: 0
Accepted
time: 60ms
memory: 225292kb

input:

100 100
1 68
1 21
1 49
1 55
1 50
1 22
1 55
1 80
1 48
1 40
1 53
1 84
1 1
1 59
1 50
1 29
1 85
1 25
1 89
1 74
1 97
1 49
1 22
1 8
1 31
1 20
1 55
1 29
1 8
1 24
1 14
1 66
1 78
1 70
1 83
1 48
1 8
1 52
1 77
1 65
1 70
1 61
1 3
1 75
1 69
1 76
1 40
1 42
1 84
1 26
1 62
1 30
1 25
1 84
1 58
1 75
1 3
1 96
1 43
1 2...

output:

2803

result:

ok single line: '2803'

Test #65:

score: 0
Accepted
time: 48ms
memory: 225212kb

input:

100 100
30 27
30 38
30 29
30 84
30 82
30 10
30 79
30 50
30 90
30 99
30 95
30 97
30 62
30 37
30 15
30 88
30 20
30 38
30 76
30 53
30 21
30 73
30 80
30 90
30 91
30 4
30 9
30 99
30 85
30 1
30 82
30 3
30 67
30 52
30 48
30 31
30 99
30 90
30 20
30 79
30 98
30 62
30 96
30 34
30 99
30 1
30 21
30 64
30 85
30 ...

output:

297

result:

ok single line: '297'

Test #66:

score: 0
Accepted
time: 36ms
memory: 225328kb

input:

100 100
129 93
80 93
41 6
81 36
48 13
257 81
10 31
231 50
143 63
218 64
143 95
39 61
179 89
38 17
69 79
92 86
143 93
189 12
11 85
265 36
80 14
262 63
279 91
23 51
283 68
268 42
137 93
254 18
164 36
219 69
201 8
148 53
181 12
244 2
92 11
286 63
86 30
132 81
165 63
165 20
135 97
128 99
132 41
189 6
18...

output:

355

result:

ok single line: '355'

Test #67:

score: 0
Accepted
time: 48ms
memory: 225136kb

input:

100 100
1 50
1 46
1 91
1 84
1 89
1 93
1 73
1 27
1 28
1 2
1 27
1 24
1 36
1 3
1 86
1 83
1 65
1 47
1 98
1 19
1 52
1 8
1 97
1 4
1 24
1 88
1 32
1 92
1 64
1 56
1 54
1 72
1 82
1 95
1 100
1 52
1 99
1 26
1 74
1 62
1 67
1 19
1 2
1 66
1 40
1 82
1 64
1 10
1 49
1 25
1 96
1 25
1 79
1 42
1 64
1 20
1 7
1 62
1 72
1 ...

output:

3411

result:

ok single line: '3411'

Test #68:

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

input:

100 100
28 37
28 81
28 64
28 66
28 52
28 53
28 65
28 43
28 2
28 76
28 95
28 95
28 37
28 12
28 78
28 81
28 36
28 65
28 100
28 85
28 60
28 2
28 18
28 84
28 78
28 45
28 72
28 87
28 13
28 11
28 92
28 62
28 15
28 57
28 42
28 98
28 47
28 91
28 81
28 50
28 71
28 51
28 97
28 6
28 97
28 9
28 65
28 28
28 5
28...

output:

296

result:

ok single line: '296'

Test #69:

score: 0
Accepted
time: 36ms
memory: 225332kb

input:

100 100
154 66
35 50
238 51
300 65
42 44
159 97
108 24
70 27
30 99
124 22
183 92
244 52
242 8
272 34
239 13
247 11
270 55
112 17
92 60
43 12
171 20
117 78
75 37
186 17
138 46
285 74
44 86
263 12
50 47
166 39
6 89
294 89
278 17
136 89
119 67
94 81
122 60
9 3
284 66
130 20
179 77
273 71
14 56
46 2
241...

output:

438

result:

ok single line: '438'

Test #70:

score: 0
Accepted
time: 39ms
memory: 225272kb

input:

100 100
1 82
1 34
1 62
1 44
1 43
1 64
1 38
1 1
1 5
1 11
1 58
1 91
1 66
1 74
1 41
1 30
1 19
1 92
1 22
1 2
1 21
1 65
1 41
1 84
1 92
1 77
1 8
1 79
1 62
1 80
1 68
1 62
1 81
1 25
1 3
1 6
1 2
1 99
1 39
1 54
1 48
1 78
1 34
1 44
1 96
1 82
1 51
1 50
1 40
1 49
1 83
1 50
1 31
1 72
1 71
1 45
1 35
1 66
1 5
1 7
1...

output:

3397

result:

ok single line: '3397'

Test #71:

score: 0
Accepted
time: 48ms
memory: 225232kb

input:

100 100
63 23
63 65
63 3
63 50
63 44
63 62
63 95
63 99
63 4
63 74
63 83
63 79
63 72
63 52
63 19
63 82
63 29
63 59
63 93
63 97
63 52
63 38
63 33
63 37
63 9
63 17
63 57
63 29
63 85
63 3
63 9
63 58
63 61
63 28
63 4
63 74
63 10
63 81
63 84
63 69
63 67
63 19
63 19
63 50
63 74
63 48
63 85
63 23
63 17
63 5...

output:

100

result:

ok single line: '100'

Test #72:

score: 0
Accepted
time: 70ms
memory: 225328kb

input:

100 100
205 1
55 73
163 57
248 66
16 60
107 25
122 94
277 97
39 1
16 88
193 69
226 31
69 67
260 52
199 34
55 22
134 91
76 47
30 85
114 36
105 74
260 30
215 77
250 51
251 29
177 91
77 78
160 69
110 38
116 59
273 2
93 23
90 67
80 61
213 32
5 71
289 34
277 63
30 78
3 27
220 58
145 8
258 32
270 5
172 70...

output:

495

result:

ok single line: '495'

Test #73:

score: 0
Accepted
time: 53ms
memory: 225244kb

input:

100 100
1 76
1 69
1 14
1 43
1 35
1 25
1 85
1 28
1 72
1 97
1 41
1 41
1 84
1 59
1 24
1 56
1 83
1 69
1 53
1 29
1 15
1 31
1 23
1 79
1 77
1 4
1 32
1 68
1 25
1 35
1 41
1 91
1 2
1 18
1 1
1 35
1 17
1 25
1 86
1 9
1 17
1 46
1 87
1 36
1 76
1 90
1 26
1 26
1 66
1 52
1 80
1 73
1 64
1 90
1 57
1 21
1 7
1 19
1 4
1 6...

output:

4870

result:

ok single line: '4870'

Test #74:

score: 0
Accepted
time: 48ms
memory: 225212kb

input:

100 100
2 47
2 51
2 2
2 44
2 46
2 76
2 70
2 51
2 91
2 45
2 69
2 85
2 77
2 75
2 92
2 67
2 64
2 65
2 75
2 57
2 98
2 90
2 76
2 93
2 19
2 85
2 77
2 2
2 53
2 53
2 59
2 17
2 50
2 19
2 24
2 31
2 2
2 73
2 55
2 82
2 11
2 47
2 22
2 26
2 53
2 19
2 9
2 48
2 22
2 54
2 4
2 67
2 24
2 100
2 72
2 71
2 59
2 18
2 72
2...

output:

3799

result:

ok single line: '3799'

Test #75:

score: 0
Accepted
time: 138ms
memory: 225236kb

input:

100 300
106 20
224 52
117 7
278 48
202 90
258 63
282 18
53 81
184 5
114 16
286 9
29 93
287 72
33 5
167 8
117 35
87 32
212 93
16 94
273 71
186 94
266 57
194 40
110 2
51 22
93 52
168 5
227 41
145 73
157 43
37 52
223 81
16 21
154 31
67 45
257 47
284 23
46 54
259 31
131 79
214 54
94 81
149 15
153 42
91 ...

output:

615

result:

ok single line: '615'

Test #76:

score: 0
Accepted
time: 170ms
memory: 225244kb

input:

100 300
1 58
1 66
1 57
1 16
1 34
1 90
1 44
1 28
1 78
1 77
1 18
1 82
1 77
1 78
1 85
1 51
1 34
1 37
1 5
1 39
1 98
1 93
1 22
1 2
1 73
1 60
1 94
1 30
1 87
1 6
1 95
1 85
1 17
1 98
1 92
1 21
1 86
1 69
1 95
1 22
1 73
1 84
1 92
1 22
1 87
1 38
1 24
1 43
1 21
1 13
1 51
1 79
1 34
1 84
1 11
1 51
1 55
1 30
1 44
...

output:

3021

result:

ok single line: '3021'

Test #77:

score: 0
Accepted
time: 162ms
memory: 225260kb

input:

100 300
186 1
186 42
186 26
186 97
186 11
186 92
186 22
186 90
186 87
186 40
186 99
186 93
186 9
186 98
186 56
186 89
186 5
186 51
186 19
186 82
186 10
186 69
186 29
186 21
186 34
186 86
186 88
186 16
186 27
186 47
186 4
186 46
186 35
186 44
186 10
186 45
186 69
186 86
186 9
186 15
186 100
186 84
18...

output:

100

result:

ok single line: '100'

Test #78:

score: 0
Accepted
time: 158ms
memory: 225328kb

input:

100 300
25 94
300 7
116 21
163 55
177 57
129 7
281 55
237 9
255 37
223 74
55 75
296 75
184 53
252 26
279 69
180 61
91 92
15 98
156 62
8 67
160 42
24 16
279 37
154 49
279 73
291 85
147 14
180 74
181 63
14 94
137 74
299 10
113 65
197 5
100 56
54 8
293 49
197 73
143 11
9 76
296 68
4 25
151 93
53 57
17 ...

output:

1004

result:

ok single line: '1004'

Test #79:

score: 0
Accepted
time: 209ms
memory: 225140kb

input:

100 300
1 7
1 38
1 10
1 4
1 60
1 17
1 53
1 52
1 46
1 52
1 88
1 36
1 71
1 62
1 13
1 43
1 61
1 54
1 98
1 19
1 5
1 8
1 27
1 45
1 32
1 91
1 59
1 1
1 1
1 40
1 81
1 26
1 26
1 84
1 64
1 77
1 39
1 64
1 2
1 76
1 38
1 32
1 12
1 3
1 24
1 65
1 98
1 44
1 53
1 36
1 52
1 49
1 98
1 82
1 32
1 92
1 43
1 52
1 48
1 65
...

output:

3273

result:

ok single line: '3273'

Test #80:

score: 0
Accepted
time: 155ms
memory: 225420kb

input:

100 300
184 44
184 66
184 58
184 56
184 14
184 58
184 15
184 57
184 96
184 90
184 62
184 78
184 12
184 8
184 31
184 87
184 37
184 71
184 56
184 78
184 39
184 98
184 44
184 14
184 81
184 78
184 35
184 87
184 59
184 35
184 57
184 37
184 16
184 41
184 73
184 30
184 89
184 15
184 87
184 16
184 36
184 73...

output:

100

result:

ok single line: '100'

Test #81:

score: 0
Accepted
time: 170ms
memory: 225344kb

input:

100 300
174 83
239 75
39 83
282 99
265 86
264 92
76 23
177 3
68 53
32 9
163 40
232 87
185 92
105 88
203 38
35 76
65 72
228 71
119 93
259 32
63 57
191 26
261 89
41 100
159 19
3 58
226 78
96 19
253 97
194 40
37 14
142 18
225 46
1 39
59 27
88 25
176 34
47 98
132 90
187 41
168 12
91 91
200 47
174 88
58 ...

output:

697

result:

ok single line: '697'

Test #82:

score: 0
Accepted
time: 196ms
memory: 225312kb

input:

100 300
1 75
1 80
1 89
1 3
1 12
1 60
1 2
1 84
1 48
1 88
1 68
1 64
1 35
1 67
1 48
1 13
1 23
1 46
1 50
1 51
1 43
1 62
1 15
1 65
1 32
1 98
1 25
1 9
1 54
1 79
1 77
1 64
1 95
1 98
1 43
1 13
1 7
1 21
1 70
1 95
1 19
1 23
1 51
1 56
1 58
1 15
1 95
1 41
1 39
1 64
1 11
1 12
1 67
1 92
1 3
1 22
1 10
1 80
1 2
1 7...

output:

3120

result:

ok single line: '3120'

Test #83:

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

input:

100 300
86 88
86 47
86 8
86 64
86 73
86 61
86 1
86 79
86 8
86 85
86 16
86 23
86 10
86 35
86 95
86 24
86 35
86 8
86 78
86 77
86 80
86 18
86 35
86 70
86 45
86 95
86 23
86 30
86 68
86 42
86 33
86 33
86 7
86 47
86 84
86 28
86 3
86 20
86 95
86 41
86 25
86 46
86 21
86 57
86 1
86 79
86 31
86 25
86 59
86 72...

output:

288

result:

ok single line: '288'

Test #84:

score: 0
Accepted
time: 169ms
memory: 225424kb

input:

100 300
178 95
294 85
131 92
58 73
183 74
119 89
35 10
300 69
45 25
233 93
26 41
196 53
171 57
212 78
128 29
97 66
242 75
137 91
172 94
284 58
69 23
100 7
296 42
148 78
115 76
211 74
152 67
16 95
281 86
118 10
185 86
185 28
288 82
103 46
41 55
54 43
197 96
199 12
86 74
239 39
216 95
85 73
16 4
19 17...

output:

774

result:

ok single line: '774'

Test #85:

score: 0
Accepted
time: 256ms
memory: 225396kb

input:

100 300
1 87
1 79
1 34
1 44
1 23
1 54
1 43
1 71
1 36
1 33
1 62
1 86
1 89
1 29
1 89
1 10
1 38
1 68
1 54
1 32
1 67
1 46
1 98
1 54
1 54
1 20
1 80
1 46
1 53
1 24
1 9
1 80
1 37
1 83
1 71
1 74
1 16
1 51
1 83
1 79
1 15
1 66
1 85
1 13
1 32
1 12
1 11
1 94
1 27
1 33
1 17
1 37
1 46
1 73
1 84
1 95
1 22
1 10
1 5...

output:

5020

result:

ok single line: '5020'

Test #86:

score: 0
Accepted
time: 213ms
memory: 225264kb

input:

100 300
84 17
84 85
84 64
84 42
84 39
84 5
84 33
84 77
84 65
84 74
84 92
84 60
84 39
84 54
84 63
84 18
84 45
84 68
84 52
84 85
84 22
84 67
84 32
84 34
84 52
84 7
84 18
84 56
84 73
84 93
84 11
84 20
84 98
84 29
84 15
84 83
84 41
84 69
84 1
84 45
84 77
84 91
84 81
84 45
84 88
84 32
84 61
84 90
84 70
8...

output:

296

result:

ok single line: '296'

Test #87:

score: 0
Accepted
time: 35ms
memory: 225428kb

input:

300 10
54 10
207 58
273 17
156 31
77 35
46 36
202 46
31 38
31 78
74 79
87 32
153 45
264 23
64 12
98 65
128 11
247 44
90 77
229 36
209 92
111 86
55 19
243 2
101 46
130 96
77 16
125 68
81 75
160 17
208 79
265 62
214 45
177 38
191 3
116 5
129 64
23 100
271 32
256 49
98 76
9 16
203 77
173 83
210 5
151 2...

output:

108

result:

ok single line: '108'

Test #88:

score: 0
Accepted
time: 32ms
memory: 225304kb

input:

300 10
1 94
1 33
1 93
1 51
1 34
1 5
1 72
1 76
1 1
1 10
1 73
1 19
1 89
1 32
1 13
1 22
1 40
1 62
1 35
1 74
1 48
1 12
1 70
1 12
1 32
1 85
1 27
1 83
1 88
1 58
1 42
1 100
1 75
1 24
1 24
1 39
1 71
1 46
1 7
1 93
1 78
1 70
1 52
1 51
1 69
1 61
1 53
1 98
1 28
1 94
1 22
1 51
1 27
1 9
1 8
1 25
1 12
1 47
1 32
1 ...

output:

988

result:

ok single line: '988'

Test #89:

score: 0
Accepted
time: 20ms
memory: 225332kb

input:

300 10
9 88
9 57
9 4
9 68
9 89
9 27
9 93
9 47
9 23
9 50
9 97
9 10
9 30
9 32
9 35
9 48
9 83
9 12
9 59
9 10
9 95
9 22
9 85
9 98
9 77
9 88
9 83
9 65
9 60
9 97
9 51
9 31
9 86
9 12
9 64
9 25
9 52
9 25
9 65
9 79
9 30
9 15
9 59
9 33
9 83
9 75
9 64
9 86
9 69
9 59
9 8
9 13
9 85
9 89
9 86
9 75
9 7
9 77
9 63
9...

output:

100

result:

ok single line: '100'

Test #90:

score: 0
Accepted
time: 39ms
memory: 225276kb

input:

300 10
138 41
176 47
237 68
261 60
173 48
225 5
100 63
300 3
241 31
229 78
119 16
276 2
220 16
39 43
88 52
66 64
168 90
169 95
159 3
8 100
15 31
49 23
178 66
79 52
51 34
79 97
110 1
271 30
164 93
35 78
40 73
152 86
267 4
137 87
102 54
249 9
203 94
14 79
273 59
129 73
178 82
163 55
29 28
298 15
242 1...

output:

198

result:

ok single line: '198'

Test #91:

score: 0
Accepted
time: 46ms
memory: 225376kb

input:

300 10
1 19
1 13
1 84
1 31
1 51
1 81
1 65
1 64
1 21
1 11
1 38
1 55
1 17
1 4
1 17
1 5
1 3
1 18
1 36
1 76
1 52
1 67
1 10
1 100
1 21
1 86
1 11
1 52
1 79
1 38
1 23
1 84
1 55
1 92
1 47
1 57
1 48
1 26
1 26
1 23
1 3
1 67
1 40
1 45
1 94
1 77
1 90
1 20
1 71
1 84
1 61
1 1
1 55
1 21
1 44
1 31
1 86
1 35
1 66
1 ...

output:

975

result:

ok single line: '975'

Test #92:

score: 0
Accepted
time: 28ms
memory: 225428kb

input:

300 10
7 90
7 43
7 78
7 60
7 16
7 17
7 52
7 99
7 41
7 61
7 9
7 10
7 67
7 67
7 43
7 8
7 94
7 2
7 17
7 16
7 88
7 51
7 73
7 67
7 85
7 32
7 67
7 34
7 37
7 50
7 24
7 46
7 91
7 87
7 18
7 92
7 47
7 14
7 14
7 90
7 16
7 38
7 83
7 30
7 60
7 51
7 94
7 73
7 67
7 30
7 56
7 10
7 96
7 85
7 79
7 68
7 37
7 77
7 96
7...

output:

100

result:

ok single line: '100'

Test #93:

score: 0
Accepted
time: 36ms
memory: 225292kb

input:

300 10
193 55
163 3
14 97
285 42
73 22
251 9
29 89
84 2
295 66
228 54
108 25
167 65
225 9
17 24
78 1
42 89
17 50
16 80
181 14
282 15
214 98
148 66
50 60
202 47
249 89
211 34
276 27
17 75
219 31
4 6
165 3
54 68
252 84
83 91
143 13
15 94
103 67
37 2
222 69
50 65
57 21
27 22
238 21
115 91
79 93
188 55
...

output:

232

result:

ok single line: '232'

Test #94:

score: 0
Accepted
time: 28ms
memory: 225216kb

input:

300 10
1 95
1 17
1 33
1 72
1 10
1 79
1 15
1 65
1 74
1 50
1 27
1 73
1 90
1 91
1 99
1 56
1 67
1 6
1 36
1 41
1 90
1 71
1 33
1 29
1 49
1 10
1 74
1 10
1 52
1 60
1 87
1 7
1 54
1 71
1 12
1 47
1 13
1 84
1 4
1 50
1 5
1 27
1 75
1 72
1 54
1 18
1 78
1 85
1 44
1 29
1 40
1 7
1 30
1 67
1 37
1 5
1 26
1 17
1 94
1 70...

output:

973

result:

ok single line: '973'

Test #95:

score: 0
Accepted
time: 40ms
memory: 225292kb

input:

300 10
1 87
1 86
1 63
1 75
1 56
1 94
1 88
1 59
1 92
1 6
1 63
1 4
1 15
1 18
1 90
1 40
1 20
1 96
1 77
1 48
1 47
1 72
1 25
1 65
1 7
1 76
1 81
1 62
1 7
1 5
1 1
1 65
1 98
1 78
1 49
1 10
1 87
1 77
1 22
1 11
1 7
1 78
1 14
1 56
1 44
1 77
1 98
1 28
1 51
1 18
1 2
1 94
1 16
1 33
1 41
1 5
1 85
1 71
1 36
1 66
1 ...

output:

987

result:

ok single line: '987'

Test #96:

score: 0
Accepted
time: 28ms
memory: 225184kb

input:

300 10
254 1
37 72
227 78
63 65
65 93
83 72
256 75
46 79
185 54
121 99
98 50
208 95
24 27
110 33
32 78
237 94
115 4
65 37
242 95
272 55
136 91
83 4
232 70
170 56
142 87
46 85
126 38
298 14
142 51
209 37
184 62
243 68
34 24
256 73
162 98
83 95
24 71
185 70
65 49
190 8
35 90
230 68
264 17
104 63
104 9...

output:

140

result:

ok single line: '140'

Test #97:

score: 0
Accepted
time: 40ms
memory: 225180kb

input:

300 10
1 77
1 63
1 69
1 36
1 81
1 84
1 91
1 15
1 58
1 63
1 52
1 11
1 45
1 67
1 78
1 95
1 3
1 47
1 38
1 9
1 37
1 40
1 97
1 84
1 45
1 37
1 14
1 46
1 16
1 19
1 76
1 39
1 65
1 68
1 7
1 86
1 61
1 93
1 92
1 10
1 14
1 27
1 77
1 47
1 27
1 54
1 97
1 11
1 17
1 58
1 73
1 86
1 16
1 29
1 5
1 18
1 79
1 3
1 38
1 7...

output:

991

result:

ok single line: '991'

Test #98:

score: 0
Accepted
time: 15ms
memory: 225300kb

input:

300 10
2 66
2 7
2 12
2 30
2 87
2 20
2 43
2 36
2 54
2 77
2 53
2 19
2 97
2 77
2 25
2 15
2 27
2 28
2 28
2 84
2 78
2 12
2 9
2 5
2 49
2 4
2 8
2 55
2 47
2 95
2 28
2 18
2 30
2 6
2 80
2 84
2 28
2 9
2 89
2 52
2 3
2 55
2 62
2 94
2 25
2 77
2 68
2 40
2 53
2 100
2 60
2 7
2 75
2 69
2 53
2 23
2 46
2 56
2 31
2 28
2...

output:

500

result:

ok single line: '500'

Test #99:

score: 0
Accepted
time: 74ms
memory: 225264kb

input:

300 100
259 18
75 62
273 99
56 75
140 13
62 29
90 69
266 4
208 50
175 55
128 74
213 40
236 19
203 79
100 29
117 71
189 42
59 33
163 81
211 98
181 18
17 23
225 55
277 8
55 28
98 45
53 23
192 96
196 78
180 42
109 63
133 27
2 66
41 8
16 76
193 55
63 86
16 49
280 8
203 28
207 11
216 31
255 32
122 2
210 ...

output:

669

result:

ok single line: '669'

Test #100:

score: 0
Accepted
time: 97ms
memory: 225392kb

input:

300 100
1 58
1 91
1 28
1 58
1 11
1 100
1 13
1 85
1 61
1 16
1 97
1 47
1 37
1 11
1 70
1 19
1 36
1 96
1 25
1 68
1 12
1 2
1 17
1 53
1 41
1 11
1 97
1 88
1 8
1 31
1 50
1 39
1 11
1 25
1 91
1 78
1 12
1 17
1 78
1 54
1 41
1 65
1 20
1 16
1 92
1 80
1 56
1 99
1 4
1 77
1 91
1 53
1 39
1 86
1 63
1 15
1 3
1 80
1 58
...

output:

7604

result:

ok single line: '7604'

Test #101:

score: 0
Accepted
time: 68ms
memory: 225460kb

input:

300 100
31 3
31 45
31 57
31 35
31 100
31 64
31 32
31 31
31 21
31 12
31 65
31 39
31 43
31 12
31 78
31 39
31 27
31 75
31 86
31 21
31 97
31 84
31 94
31 32
31 82
31 40
31 3
31 33
31 43
31 36
31 83
31 86
31 20
31 5
31 23
31 12
31 55
31 5
31 23
31 11
31 42
31 92
31 44
31 3
31 13
31 17
31 62
31 22
31 61
31...

output:

300

result:

ok single line: '300'

Test #102:

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

input:

300 100
12 71
180 92
288 40
178 23
251 90
164 50
210 48
259 7
57 20
289 56
274 46
37 38
199 91
69 77
13 54
80 76
285 13
151 58
270 2
181 9
218 89
215 40
197 22
141 63
276 78
189 65
79 1
19 28
93 23
122 85
151 9
40 58
61 50
190 13
165 46
11 3
154 50
105 92
204 78
111 74
72 80
138 83
128 69
47 86
104 ...

output:

738

result:

ok single line: '738'

Test #103:

score: 0
Accepted
time: 77ms
memory: 225316kb

input:

300 100
1 73
1 13
1 21
1 16
1 67
1 49
1 44
1 46
1 40
1 9
1 42
1 81
1 49
1 47
1 87
1 39
1 44
1 27
1 56
1 76
1 37
1 42
1 86
1 7
1 73
1 40
1 59
1 49
1 32
1 19
1 35
1 51
1 40
1 26
1 14
1 25
1 48
1 91
1 54
1 62
1 89
1 4
1 44
1 36
1 49
1 79
1 69
1 43
1 98
1 90
1 87
1 5
1 96
1 79
1 28
1 24
1 70
1 94
1 45
1...

output:

7805

result:

ok single line: '7805'

Test #104:

score: 0
Accepted
time: 68ms
memory: 225352kb

input:

300 100
68 5
68 72
68 60
68 3
68 12
68 7
68 81
68 87
68 100
68 100
68 98
68 63
68 24
68 56
68 27
68 72
68 10
68 37
68 10
68 37
68 85
68 8
68 71
68 6
68 74
68 40
68 75
68 11
68 76
68 78
68 12
68 43
68 87
68 15
68 51
68 49
68 4
68 98
68 63
68 38
68 77
68 45
68 13
68 78
68 9
68 32
68 92
68 49
68 70
68 ...

output:

100

result:

ok single line: '100'

Test #105:

score: 0
Accepted
time: 67ms
memory: 225276kb

input:

300 100
51 19
84 75
170 75
271 92
300 56
293 77
17 13
52 76
287 61
151 25
298 68
170 1
201 73
239 3
270 63
58 84
87 11
223 57
53 8
114 8
10 69
154 25
40 4
295 63
71 61
153 99
175 37
79 26
131 6
142 64
137 59
204 13
247 4
247 37
151 32
154 46
289 24
81 28
91 12
4 59
112 2
174 98
273 12
175 9
11 94
10...

output:

964

result:

ok single line: '964'

Test #106:

score: 0
Accepted
time: 76ms
memory: 225292kb

input:

300 100
1 53
1 53
1 3
1 21
1 81
1 35
1 14
1 76
1 37
1 9
1 27
1 91
1 55
1 44
1 73
1 91
1 92
1 64
1 60
1 89
1 56
1 82
1 74
1 52
1 73
1 28
1 25
1 92
1 64
1 82
1 54
1 59
1 46
1 66
1 8
1 46
1 61
1 36
1 25
1 73
1 4
1 13
1 12
1 97
1 3
1 54
1 4
1 36
1 1
1 24
1 90
1 37
1 93
1 9
1 45
1 37
1 54
1 39
1 48
1 53
...

output:

7980

result:

ok single line: '7980'

Test #107:

score: 0
Accepted
time: 70ms
memory: 225340kb

input:

300 100
64 96
64 87
64 58
64 20
64 37
64 67
64 7
64 68
64 89
64 66
64 37
64 69
64 97
64 59
64 76
64 86
64 47
64 87
64 90
64 37
64 98
64 37
64 42
64 18
64 18
64 86
64 16
64 68
64 38
64 88
64 96
64 88
64 68
64 89
64 11
64 33
64 65
64 37
64 52
64 41
64 19
64 41
64 41
64 42
64 55
64 97
64 37
64 52
64 28...

output:

100

result:

ok single line: '100'

Test #108:

score: 0
Accepted
time: 97ms
memory: 225304kb

input:

300 100
143 21
255 10
32 82
223 4
142 28
146 2
54 78
169 4
212 89
28 61
50 82
154 43
277 41
87 85
296 9
240 17
80 85
87 99
282 24
208 41
26 46
193 100
39 16
60 36
79 66
11 56
144 58
225 68
286 19
274 29
115 16
264 64
234 60
282 12
8 9
2 95
39 12
78 69
213 97
43 95
150 39
58 49
48 28
93 13
89 93
16 1...

output:

885

result:

ok single line: '885'

Test #109:

score: 0
Accepted
time: 119ms
memory: 225304kb

input:

300 100
1 62
1 56
1 22
1 65
1 24
1 37
1 23
1 89
1 38
1 13
1 69
1 97
1 20
1 20
1 52
1 56
1 47
1 90
1 87
1 8
1 68
1 3
1 84
1 13
1 100
1 52
1 12
1 80
1 52
1 67
1 1
1 92
1 4
1 38
1 91
1 30
1 87
1 65
1 74
1 30
1 24
1 55
1 20
1 97
1 5
1 73
1 81
1 97
1 36
1 58
1 84
1 28
1 49
1 79
1 2
1 54
1 38
1 39
1 62
1 ...

output:

8710

result:

ok single line: '8710'

Test #110:

score: 0
Accepted
time: 124ms
memory: 225316kb

input:

300 100
12 65
12 62
12 97
12 84
12 45
12 76
12 90
12 62
12 84
12 47
12 15
12 24
12 41
12 76
12 3
12 75
12 9
12 43
12 63
12 15
12 29
12 8
12 51
12 85
12 39
12 31
12 37
12 99
12 40
12 52
12 41
12 40
12 49
12 55
12 71
12 84
12 15
12 69
12 74
12 72
12 17
12 87
12 34
12 65
12 25
12 87
12 59
12 38
12 38
1...

output:

786

result:

ok single line: '786'

Test #111:

score: 0
Accepted
time: 450ms
memory: 225308kb

input:

300 300
41 31
30 52
55 92
102 51
16 5
175 78
7 97
97 34
143 96
95 10
16 81
103 98
42 62
136 71
194 45
245 18
38 56
158 88
146 14
12 85
20 95
138 50
298 5
277 57
22 46
142 4
35 35
41 82
120 89
161 75
265 43
24 20
234 64
3 30
196 62
95 100
273 8
244 98
1 92
151 64
161 63
200 52
108 4
254 72
82 98
93 7...

output:

1728

result:

ok single line: '1728'

Test #112:

score: 0
Accepted
time: 589ms
memory: 225248kb

input:

300 300
1 64
1 66
1 7
1 41
1 57
1 69
1 90
1 19
1 14
1 77
1 48
1 50
1 58
1 97
1 82
1 98
1 9
1 46
1 85
1 39
1 28
1 57
1 87
1 40
1 100
1 48
1 100
1 62
1 32
1 23
1 100
1 41
1 41
1 22
1 74
1 29
1 60
1 98
1 19
1 62
1 56
1 28
1 91
1 31
1 18
1 43
1 55
1 14
1 20
1 63
1 2
1 5
1 43
1 45
1 88
1 12
1 77
1 64
1 2...

output:

8720

result:

ok single line: '8720'

Test #113:

score: 0
Accepted
time: 529ms
memory: 225356kb

input:

300 300
80 88
80 43
80 22
80 90
80 24
80 87
80 28
80 57
80 95
80 95
80 61
80 37
80 56
80 65
80 75
80 5
80 49
80 22
80 64
80 12
80 36
80 27
80 37
80 54
80 77
80 80
80 53
80 43
80 44
80 33
80 80
80 87
80 57
80 54
80 5
80 70
80 84
80 43
80 82
80 55
80 15
80 87
80 7
80 21
80 46
80 48
80 100
80 7
80 73
8...

output:

299

result:

ok single line: '299'