QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#86518#1895. Moving Cellstriplem5ds#AC ✓155ms16532kbC++201.9kb2023-03-09 23:54:532023-03-09 23:54:57

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-09 23:54:57]
  • Judged
  • Verdict: AC
  • Time: 155ms
  • Memory: 16532kb
  • [2023-03-09 23:54:53]
  • Submitted

answer

///Enta etfsh5t nseet el rank

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
//#define mp(x, y) make_pair(x, y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ull = unsigned long long;
using uint = uint32_t;
using ii = pair<int, int>;

const int N = 3e6 + 6, A = 26, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const ll INF = 1e15;
int n, m;
int s[N], t[N];

void doWork() {

    cin >> n >> m;
    f(i, 1, m + 1) cin >> s[i] >> t[i];
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, 1e9));
    f(i, 1, n + 1)dp[0][i] = 0;
    f(i, 1, m + 1) {
        multiset<int> st;
        for (int j = 1; j <= t[i] - s[i]; j++)
            st.insert(dp[i - 1][j]);
        for (int j = 1; j <= n; j++) {
            int a = t[i] - s[i], b = t[i - 1] - s[i - 1];
            if (j - b > 1)
                st.erase(st.find(dp[i - 1][j - b - 1]));
            if (j + a <= n)
                st.insert(dp[i - 1][j + a]);
            dp[i][j] = abs(s[i] - j) + *st.begin();
        }
    }

    cout << *min_element(all(dp[m])) << '\n';

}


int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE
    int t = 1;
//    cin >> t;
    while (t--)
        doWork();

    return 0;
}


这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3532kb

input:

9 3
1 2
4 5
7 9

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

1 5
1 1
1 1
1 1
1 1
1 1

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

9 1
5 7

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

10 5
1 1
4 4
4 4
5 5
3 3

output:

5

result:

ok 1 number(s): "5"

Test #5:

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

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

7 10
1 7
1 5
1 6
1 5
1 7
1 5
1 7
1 7
1 6
1 5

output:

0

result:

ok 1 number(s): "0"

Test #7:

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

input:

6 6
1 1
6 6
1 1
6 6
1 1
6 6

output:

15

result:

ok 1 number(s): "15"

Test #8:

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

input:

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

output:

10

result:

ok 1 number(s): "10"

Test #9:

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

input:

5 5
3 5
1 2
1 5
1 3
1 5

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

10 7
1 10
7 7
1 1
2 7
9 9
6 6
1 9

output:

9

result:

ok 1 number(s): "9"

Test #11:

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

input:

5 8
1 4
1 3
3 4
1 3
1 2
2 4
1 3
1 3

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

10 10
1 9
2 7
2 7
2 8
2 7
2 6
2 7
2 8
2 7
1 8

output:

0

result:

ok 1 number(s): "0"

Test #13:

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

input:

9 99994
2 2
3 3
2 2
3 3
7 7
6 6
3 3
6 6
1 1
4 4
5 5
4 4
2 2
1 1
1 1
2 2
9 9
1 1
3 3
9 9
4 4
2 2
8 8
9 9
8 8
5 5
7 7
2 2
8 8
9 9
3 3
8 8
3 3
9 9
4 4
5 5
6 6
3 3
8 8
8 8
9 9
5 5
2 2
9 9
4 4
5 5
9 9
1 1
1 1
5 5
3 3
9 9
2 2
2 2
5 5
3 3
7 7
5 5
1 1
4 4
2 2
2 2
4 4
7 7
1 1
4 4
6 6
9 9
9 9
5 5
2 2
2 2
9 9
...

output:

222291

result:

ok 1 number(s): "222291"

Test #14:

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

input:

7 99994
1 2
5 7
5 7
4 6
2 3
4 5
1 2
1 2
5 6
4 5
1 3
5 7
5 6
3 4
2 4
2 3
4 6
4 6
2 4
3 5
2 4
5 7
3 5
5 6
4 6
1 2
4 6
4 6
3 5
1 3
4 6
1 2
2 3
3 4
1 3
2 3
5 7
5 6
4 6
4 5
5 7
2 3
4 6
4 5
3 4
3 5
2 4
3 5
3 5
3 4
1 3
1 2
4 5
5 6
5 7
4 6
4 5
2 4
1 3
3 4
4 5
4 5
2 4
5 6
3 5
5 7
5 7
1 3
2 3
1 2
1 3
4 5
3 4
...

output:

40532

result:

ok 1 number(s): "40532"

Test #15:

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

input:

5 100000
1 5
1 4
1 3
1 3
1 3
1 4
1 5
1 5
1 3
1 3
1 4
1 4
1 3
1 5
1 4
1 3
1 5
1 4
1 5
1 5
1 5
1 5
1 5
1 4
1 5
1 4
1 5
1 3
1 4
1 3
1 3
1 3
1 3
1 3
1 4
1 3
1 4
1 3
1 4
1 4
1 4
1 4
1 3
1 5
1 4
1 4
1 5
1 5
1 4
1 4
1 5
1 3
1 3
1 3
1 5
1 4
1 4
1 4
1 5
1 5
1 4
1 3
1 3
1 3
1 3
1 3
1 3
1 3
1 3
1 3
1 4
1 3
1 4...

output:

0

result:

ok 1 number(s): "0"

Test #16:

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

input:

7 99999
1 7
1 7
1 5
1 7
1 6
1 7
1 7
1 5
1 6
1 7
1 5
1 7
1 5
1 5
1 6
1 6
1 6
1 5
1 7
1 6
1 7
1 5
1 6
1 6
1 6
1 6
1 7
1 7
1 7
1 7
1 6
1 6
1 6
1 7
1 5
1 7
1 7
1 6
1 7
1 6
1 7
1 5
1 5
1 7
1 7
1 5
1 6
1 7
1 5
1 7
1 6
1 7
1 5
1 7
1 6
1 7
1 5
1 6
1 7
1 5
1 6
1 5
1 5
1 6
1 6
1 7
1 6
1 5
1 6
1 6
1 7
1 5
1 6
...

output:

0

result:

ok 1 number(s): "0"

Test #17:

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

input:

9 99998
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
9 9
1 1
...

output:

399992

result:

ok 1 number(s): "399992"

Test #18:

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

input:

7 99998
1 3
5 6
1 3
4 6
1 2
4 6
2 4
5 7
2 3
5 7
1 2
5 6
2 4
4 6
1 3
6 7
2 4
4 6
2 3
5 7
2 3
4 6
2 4
5 6
2 3
6 7
2 4
4 6
1 3
5 6
1 3
5 7
2 4
5 6
2 4
5 7
1 2
6 7
2 4
5 7
2 4
4 6
1 3
4 6
2 4
6 7
1 3
5 6
1 2
5 6
1 2
4 6
1 2
5 6
1 2
5 6
1 2
5 6
2 3
5 6
2 4
5 7
1 2
6 7
2 4
5 6
2 3
4 6
1 3
5 6
2 4
5 7
2 3
...

output:

100010

result:

ok 1 number(s): "100010"

Test #19:

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

input:

5 99993
1 4
1 4
1 4
1 4
2 5
2 4
1 3
1 3
2 5
1 5
2 4
1 3
3 5
1 5
2 4
1 3
2 4
1 3
3 5
2 4
3 5
3 5
1 4
1 4
3 5
1 3
3 5
2 4
3 5
2 4
2 4
1 3
3 5
2 5
1 3
3 5
1 4
2 5
1 3
2 4
3 5
1 3
1 5
2 4
1 3
2 4
1 4
1 5
3 5
1 5
1 4
1 5
2 5
1 3
3 5
2 4
3 5
2 5
2 4
1 5
2 5
1 3
2 4
1 4
1 4
3 5
3 5
1 4
2 4
1 3
3 5
1 3
3 5
...

output:

0

result:

ok 1 number(s): "0"

Test #20:

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

input:

5 99992
5 5
1 2
2 5
1 2
1 5
1 4
5 5
1 2
4 5
1 1
5 5
1 5
3 5
1 3
5 5
1 5
3 5
1 1
5 5
1 4
5 5
1 1
3 5
1 5
3 5
1 5
1 5
1 1
1 5
1 5
5 5
1 1
4 5
1 3
4 5
1 5
1 5
1 1
3 5
1 3
1 5
1 5
5 5
1 2
3 5
1 4
4 5
1 4
4 5
1 3
2 5
1 4
4 5
1 3
2 5
1 1
4 5
1 5
3 5
1 1
2 5
1 3
1 5
1 2
1 5
1 3
1 5
1 5
2 5
1 4
2 5
1 1
2 5
...

output:

50388

result:

ok 1 number(s): "50388"

Test #21:

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

input:

7 99990
1 5
1 1
1 6
7 7
1 7
4 4
1 7
7 7
1 6
5 5
1 4
5 5
1 4
2 2
1 6
5 5
1 6
4 4
1 6
7 7
1 4
4 4
1 6
3 3
1 4
7 7
1 5
1 1
1 6
2 2
1 5
5 5
1 4
7 7
1 4
3 3
1 6
3 3
1 6
2 2
1 6
1 1
1 7
6 6
1 5
7 7
1 6
4 4
1 7
5 5
1 7
5 5
1 5
6 6
1 7
5 5
1 6
6 6
1 7
5 5
1 5
6 6
1 4
6 6
1 7
6 6
1 7
1 1
1 6
4 4
1 5
1 1
1 7
...

output:

24625

result:

ok 1 number(s): "24625"

Test #22:

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

input:

5 99990
1 3
2 3
1 3
2 3
1 5
1 3
3 4
2 3
1 4
3 5
1 3
2 3
1 3
2 4
2 4
2 3
1 4
2 3
2 3
2 3
1 3
2 3
1 2
2 4
1 3
2 3
3 5
3 5
1 4
3 5
1 2
2 3
1 3
1 3
3 4
2 4
1 4
3 5
3 4
1 3
1 5
3 4
1 3
2 4
1 3
3 5
1 3
1 3
1 3
2 4
2 3
1 3
1 4
1 2
3 4
3 4
1 5
3 5
2 3
3 4
1 3
3 5
2 3
2 4
1 4
1 3
1 3
3 5
1 3
1 2
2 4
1 2
1 5
...

output:

4747

result:

ok 1 number(s): "4747"

Test #23:

score: 0
Accepted
time: 50ms
memory: 16472kb

input:

9 100000
2 7
5 8
2 5
3 5
2 6
4 8
4 8
2 9
1 5
2 5
4 7
5 7
1 4
3 7
2 6
3 6
2 4
5 7
1 5
1 5
3 5
2 6
5 7
1 5
2 5
4 7
4 6
1 3
1 5
2 5
4 6
4 8
3 5
3 7
2 4
2 7
4 7
1 3
5 8
2 6
2 5
1 5
1 8
3 5
2 5
2 6
2 6
1 3
5 8
1 9
2 5
4 6
4 6
5 9
1 4
5 7
2 7
1 5
3 5
4 8
3 5
3 7
2 6
2 8
2 4
4 7
3 7
5 7
4 8
3 6
2 7
5 9
2 6...

output:

8241

result:

ok 1 number(s): "8241"

Test #24:

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

input:

5 99992
1 5
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 4
1 5
1 5
1 5
1 5
1 4
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 4
1 5
1 5
1 5
1 5
1 3
1 5
1 5
1 5
1 5
1 4
1 5
1 5
1 5
1 5
1 4
1 5
1 5
...

output:

0

result:

ok 1 number(s): "0"

Test #25:

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

input:

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

output:

40503

result:

ok 1 number(s): "40503"

Test #26:

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

input:

6 99994
4 6
1 3
1 6
5 5
4 6
4 6
1 3
2 5
1 4
3 4
2 4
2 6
1 3
1 5
4 6
2 2
3 4
1 6
1 2
2 6
1 3
2 2
3 4
5 5
2 4
4 5
4 4
1 4
1 2
3 4
3 4
3 4
1 4
4 6
5 6
5 6
3 4
5 6
3 4
2 2
5 6
2 3
1 2
3 6
5 6
1 4
3 6
1 4
3 4
2 3
2 3
1 2
1 6
4 6
2 5
2 2
1 2
1 4
1 1
3 6
1 3
2 4
2 5
1 3
1 3
2 5
4 5
1 5
2 2
2 4
4 4
1 3
2 6
...

output:

30352

result:

ok 1 number(s): "30352"

Test #27:

score: 0
Accepted
time: 64ms
memory: 16496kb

input:

10 99993
1 6
4 8
1 2
2 3
1 9
6 6
6 6
10 10
4 7
4 9
1 6
7 7
5 8
3 7
6 10
7 9
2 9
1 10
6 7
2 9
5 10
3 10
6 9
8 10
5 6
2 8
3 8
3 6
10 10
6 8
4 5
5 9
8 8
5 10
5 5
4 9
4 8
2 6
4 9
1 9
3 4
3 8
7 9
6 9
2 8
4 6
3 10
4 5
6 7
5 6
6 7
7 10
6 10
5 7
8 9
1 3
5 8
3 9
1 9
2 5
4 5
5 5
6 7
8 9
2 8
2 8
4 6
1 6
4 7
5 ...

output:

50942

result:

ok 1 number(s): "50942"

Test #28:

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

input:

6 99995
5 5
2 5
1 2
4 4
1 1
2 5
1 4
1 4
2 5
1 4
6 6
1 3
3 3
1 6
1 4
2 4
3 4
1 1
4 6
2 6
2 6
1 4
6 6
3 4
1 5
2 5
2 3
1 2
4 6
4 4
4 6
6 6
1 1
6 6
2 3
2 4
1 4
4 4
2 5
1 6
3 5
2 4
3 4
2 6
3 4
3 6
1 6
3 5
6 6
3 6
4 5
3 5
4 6
2 3
4 5
2 4
4 6
1 3
2 6
3 5
4 5
3 3
2 6
2 5
4 6
2 5
2 4
4 6
4 6
4 5
4 5
4 6
2 6
...

output:

30670

result:

ok 1 number(s): "30670"

Test #29:

score: 0
Accepted
time: 26ms
memory: 11680kb

input:

99992 9
48870 48870
3581 3581
91178 91178
52403 52403
64445 64445
49071 49071
58388 58388
24849 24849
43489 43489

output:

145625

result:

ok 1 number(s): "145625"

Test #30:

score: 0
Accepted
time: 22ms
memory: 8572kb

input:

99992 5
30892 30899
83142 83149
94126 94133
81332 81336
15094 15098

output:

131267

result:

ok 1 number(s): "131267"

Test #31:

score: 0
Accepted
time: 58ms
memory: 9316kb

input:

99994 6
88361 90181
92219 93672
65330 66575
34960 36437
69529 71565
26109 27788

output:

116611

result:

ok 1 number(s): "116611"

Test #32:

score: 0
Accepted
time: 136ms
memory: 15512kb

input:

100000 9
10870 51025
11620 44605
24542 81423
1201 61017
4121 46450
1523 52754
22103 57702
14885 63156
32669 90368

output:

0

result:

ok 1 number(s): "0"

Test #33:

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

input:

99998 8
1 1
99998 99998
1 1
99998 99998
1 1
99998 99998
1 1
99998 99998

output:

399988

result:

ok 1 number(s): "399988"

Test #34:

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

input:

99997 6
3 9
99989 99993
2 10
99987 99995
2 9
99991 99995

output:

299939

result:

ok 1 number(s): "299939"

Test #35:

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

input:

99991 5
119 1868
98387 99790
348 2371
97851 99141
708 2357

output:

192013

result:

ok 1 number(s): "192013"

Test #36:

score: 0
Accepted
time: 115ms
memory: 14748kb

input:

99995 8
27250 88117
59945 99053
1233 42279
45769 93034
3401 50128
36961 71997
24707 58444
50861 96395

output:

17666

result:

ok 1 number(s): "17666"

Test #37:

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

input:

99999 7
10700 69616
4055 4055
72232 72232
20476 20476
6336 6336
1198 82160
57560 57560

output:

82317

result:

ok 1 number(s): "82317"

Test #38:

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

input:

99999 5
2252 63406
18494 18501
43602 43609
25168 25176
79993 80001

output:

79918

result:

ok 1 number(s): "79918"

Test #39:

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

input:

99995 10
14748 87297
92671 94572
27157 28936
33764 34829
59703 60968
14871 99745
33086 34907
13381 14406
83586 84799
76705 78011

output:

197349

result:

ok 1 number(s): "197349"

Test #40:

score: 0
Accepted
time: 99ms
memory: 13228kb

input:

99993 6
6553 63924
21171 73800
23670 81653
31076 73329
216 51337
14938 92540

output:

0

result:

ok 1 number(s): "0"

Test #41:

score: 0
Accepted
time: 139ms
memory: 16268kb

input:

99991 10
12306 24204
37167 79819
67681 93478
27294 30398
43380 77213
32922 69690
21224 92444
945 86418
3700 67763
14997 53063

output:

50246

result:

ok 1 number(s): "50246"

Test #42:

score: 0
Accepted
time: 149ms
memory: 16108kb

input:

99991 10
51454 68866
10128 12621
14710 41219
2343 68262
72845 95753
80839 94467
5716 13599
48221 62615
17261 66222
79950 99688

output:

124384

result:

ok 1 number(s): "124384"

Test #43:

score: 0
Accepted
time: 71ms
memory: 10516kb

input:

99999 5
77136 95147
77049 89244
62419 73231
47816 94140
79288 93043

output:

3818

result:

ok 1 number(s): "3818"

Test #44:

score: 0
Accepted
time: 136ms
memory: 16380kb

input:

99999 10
42243 64949
6198 12899
1294 33004
5754 47202
64998 79060
5952 73881
17061 90286
33394 91272
41282 87386
31209 60276

output:

47140

result:

ok 1 number(s): "47140"

Test #45:

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

input:

35139 28
8864 8864
11825 11825
3674 3674
28784 28784
28476 28476
28766 28766
26126 26126
16553 16553
32560 32560
12174 12174
15542 15542
27893 27893
20993 20993
32100 32100
22200 22200
5480 5480
30036 30036
24899 24899
34680 34680
14238 14238
3331 3331
16691 16691
3412 3412
15859 15859
493 493
195 1...

output:

264696

result:

ok 1 number(s): "264696"

Test #46:

score: 0
Accepted
time: 41ms
memory: 11468kb

input:

41409 24
27922 27930
18573 18580
7550 7558
23680 23687
34678 34683
38818 38824
20428 20436
27303 27307
27027 27034
5776 5780
22185 22193
39274 39279
19290 19297
24429 24434
19237 19241
30821 30828
6638 6643
2802 2808
30054 30060
16724 16729
32609 32616
35095 35101
31806 31811
25940 25948

output:

193823

result:

ok 1 number(s): "193823"

Test #47:

score: 0
Accepted
time: 100ms
memory: 12248kb

input:

98586 10
52654 54464
90727 92665
78970 80503
1927 3842
38996 40160
52357 54042
55038 56961
28475 30213
93060 94692
66829 68025

output:

194925

result:

ok 1 number(s): "194925"

Test #48:

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

input:

19052 52
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1
19052 19052
1 1...

output:

495326

result:

ok 1 number(s): "495326"

Test #49:

score: 0
Accepted
time: 42ms
memory: 11680kb

input:

92619 10
3 11
92613 92617
1 8
92611 92618
3 9
92613 92618
3 11
92610 92615
1 6
92610 92615

output:

463012

result:

ok 1 number(s): "463012"

Test #50:

score: 0
Accepted
time: 95ms
memory: 12036kb

input:

70336 14
251 1801
68087 69391
715 1922
67887 69398
945 2654
68364 69950
365 2192
68249 70249
567 1783
68582 70270
244 1727
68732 70218
909 2312
68293 69580

output:

463803

result:

ok 1 number(s): "463803"

Test #51:

score: 0
Accepted
time: 84ms
memory: 12780kb

input:

37558 26
4640 32148
22840 22840
11508 11508
3992 23188
11705 11705
14803 14803
1862 34817
27530 27530
20912 20912
1591 26462
19048 19048
35756 35756
9067 30560
13274 13274
36674 36674
9115 33430
18571 18571
22139 22139
932 22557
17030 17030
14382 14382
1162 34871
36118 36118
16643 16643
984 29117
54...

output:

86847

result:

ok 1 number(s): "86847"

Test #52:

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

input:

43829 22
8060 41551
10070 10075
27404 27412
3593 3600
3003 3011
28062 28066
9372 37376
3196 3200
28244 28250
4124 4131
13790 13796
27913 27918
4321 27669
31032 31040
38958 38966
27044 27050
10960 10965
16092 16096
10126 36819
26039 26047
36423 36427
20789 20796

output:

156206

result:

ok 1 number(s): "156206"

Test #53:

score: 0
Accepted
time: 101ms
memory: 12928kb

input:

50599 19
4547 30362
29514 31125
47674 49592
22108 23311
32239 33461
23749 25028
40341 42055
4502 38710
46298 48115
2588 4159
9550 11225
39999 41370
20611 21835
28157 29679
1435 40257
23553 24927
17099 18478
32410 33702
451 1909

output:

153601

result:

ok 1 number(s): "153601"

Test #54:

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

input:

21472 46
1426 11515
505 8722
284 7113
1996 21265
1107 4649
674 2320
12313 12908
13774 16389
2807 15973
13324 20961
1243 5255
442 20029
14032 19670
3819 20520
12089 18623
51 7733
4067 16114
1840 21202
26 2533
591 2540
6901 6958
3389 10324
713 9737
3248 8413
2209 3816
13812 19336
5469 7309
14455 18079...

output:

71934

result:

ok 1 number(s): "71934"

Test #55:

score: 0
Accepted
time: 128ms
memory: 15060kb

input:

95038 10
15381 40963
67877 94551
2973 5975
49813 57827
65143 78777
31220 75251
135 30900
10993 63700
47174 51823
659 75099

output:

78388

result:

ok 1 number(s): "78388"

Test #56:

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

input:

22349 44
1690 19437
7670 21634
1507 6086
6965 21779
8218 12217
5360 8116
536 17301
5432 21142
4668 10102
5629 12798
6005 7553
11501 12580
14135 15013
15202 18964
5434 17164
5208 9219
4165 21493
3182 5131
2990 3736
7687 19730
7208 18073
9602 18512
17465 18372
5391 12602
2578 14953
7814 15775
1795 720...

output:

24788

result:

ok 1 number(s): "24788"

Test #57:

score: 0
Accepted
time: 17ms
memory: 7744kb

input:

99990 4
1 1
99990 99990
1 1
99990 99990

output:

199978

result:

ok 1 number(s): "199978"

Test #58:

score: 0
Accepted
time: 18ms
memory: 7780kb

input:

99990 4
1 2
99989 99990
1 2
99990 99990

output:

199975

result:

ok 1 number(s): "199975"

Test #59:

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

input:

99999 3
1 1
99997 99999
2 3

output:

99996

result:

ok 1 number(s): "99996"

Test #60:

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

input:

99988 3
7 8
99979 99981
1 4

output:

99975

result:

ok 1 number(s): "99975"

Test #61:

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

input:

99992 9
10 19
99972 99992
9 18
99967 99976
7 16
99969 99982
1 25
99967 99976
10 27

output:

399797

result:

ok 1 number(s): "399797"

Test #62:

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

input:

99994 2
11 75
99955 99961

output:

99880

result:

ok 1 number(s): "99880"

Test #63:

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

input:

99984 10
4 166
99754 99900
155 238
99948 99969
141 201
99866 99947
7 181
99794 99811
143 184
99823 99963

output:

498215

result:

ok 1 number(s): "498215"

Test #64:

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

input:

99987 5
100 310
99621 99755
471 640
99602 99818
202 691

output:

198273

result:

ok 1 number(s): "198273"

Test #65:

score: 0
Accepted
time: 18ms
memory: 6152kb

input:

99992 2
567 2016
99701 99884

output:

97685

result:

ok 1 number(s): "97685"

Test #66:

score: 0
Accepted
time: 41ms
memory: 7756kb

input:

99990 4
2921 5345
95000 96500
2452 6383
95440 98978

output:

178712

result:

ok 1 number(s): "178712"

Test #67:

score: 0
Accepted
time: 125ms
memory: 12644kb

input:

99999 10
740 17714
94497 99240
2247 12653
88961 89020
9822 14502
82891 90360
2673 11146
92878 98782
4272 11854
93001 94398

output:

384359

result:

ok 1 number(s): "384359"

Test #68:

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

input:

99997 1
1 99997

output:

0

result:

ok 1 number(s): "0"

Test #69:

score: 0
Accepted
time: 73ms
memory: 11592kb

input:

99993 4
2 99993
2 99992
1 99993
1 99993

output:

0

result:

ok 1 number(s): "0"

Test #70:

score: 0
Accepted
time: 137ms
memory: 14796kb

input:

99981 8
4 99978
1 99980
1 99979
4 99978
2 99980
2 99978
1 99978
1 99980

output:

0

result:

ok 1 number(s): "0"

Test #71:

score: 0
Accepted
time: 153ms
memory: 15528kb

input:

99991 9
10 99990
10 99991
3 99985
5 99989
8 99986
9 99983
9 99983
5 99987
1 99986

output:

0

result:

ok 1 number(s): "0"

Test #72:

score: 0
Accepted
time: 90ms
memory: 12408kb

input:

99984 5
17 99976
20 99963
9 99973
18 99976
18 99979

output:

0

result:

ok 1 number(s): "0"

Test #73:

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

input:

99989 9
41 99971
40 99915
42 99978
11 99923
77 99955
35 99949
34 99922
33 99911
20 99963

output:

0

result:

ok 1 number(s): "0"

Test #74:

score: 0
Accepted
time: 139ms
memory: 14740kb

input:

99995 8
215 99912
202 99922
98 99975
52 99906
73 99983
204 99838
75 99842
91 99870

output:

0

result:

ok 1 number(s): "0"

Test #75:

score: 0
Accepted
time: 131ms
memory: 14016kb

input:

99981 7
24 99850
50 99862
674 99422
161 99411
591 99860
558 99489
339 99758

output:

0

result:

ok 1 number(s): "0"

Test #76:

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

input:

99992 4
1825 99973
332 99900
1140 98978
1315 98028

output:

0

result:

ok 1 number(s): "0"

Test #77:

score: 0
Accepted
time: 100ms
memory: 13196kb

input:

99997 6
2685 98686
2385 97345
2169 94614
3135 97311
1531 98681
2259 93929

output:

0

result:

ok 1 number(s): "0"

Test #78:

score: 0
Accepted
time: 96ms
memory: 13164kb

input:

99992 6
6550 95261
773 92628
1612 87848
7565 88173
16397 86231
18058 94201

output:

0

result:

ok 1 number(s): "0"

Test #79:

score: 0
Accepted
time: 94ms
memory: 13156kb

input:

99999 7
83612 83834
48150 93237
16546 36976
7556 34993
41918 64541
23926 62488
49997 93299

output:

18099

result:

ok 1 number(s): "18099"

Test #80:

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

input:

99995 1
28660 96346

output:

0

result:

ok 1 number(s): "0"

Test #81:

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

input:

99988 8
76690 83593
2115 16702
43526 86100
7195 9745
44489 64219
54938 69309
22559 83223
13671 60761

output:

94732

result:

ok 1 number(s): "94732"

Test #82:

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

input:

99994 8
68559 84308
34037 88284
29466 81524
24610 56697
23051 32989
20597 45920
85165 91957
22080 29106

output:

56059

result:

ok 1 number(s): "56059"

Test #83:

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

input:

100000 3
81093 84203
16395 64521
34305 87937

output:

16572

result:

ok 1 number(s): "16572"

Test #84:

score: 0
Accepted
time: 127ms
memory: 15536kb

input:

99981 9
74125 75500
11679 66944
33018 76173
23911 45069
38240 73143
61958 91364
28994 80450
61759 76356
35309 88438

output:

7181

result:

ok 1 number(s): "7181"

Test #85:

score: 0
Accepted
time: 84ms
memory: 11496kb

input:

99980 6
34083 61309
21577 23219
27605 66078
4202 31418
21727 30745
5169 9613

output:

22978

result:

ok 1 number(s): "22978"

Test #86:

score: 0
Accepted
time: 69ms
memory: 12416kb

input:

99992 5
12346 15025
51367 53077
16827 63428
17073 70795
19739 83424

output:

36342

result:

ok 1 number(s): "36342"

Test #87:

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

input:

99995 1
29543 96831

output:

0

result:

ok 1 number(s): "0"

Test #88:

score: 0
Accepted
time: 41ms
memory: 7872kb

input:

99997 3
41351 44663
46552 79908
71664 75162

output:

1889

result:

ok 1 number(s): "1889"

Test #89:

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

input:

99993 5
48634 72771
20078 40708
3579 34793
2526 27554
16445 26500

output:

7926

result:

ok 1 number(s): "7926"

Test #90:

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

input:

2 99997
2 2
1 1
2 2
1 1
1 1
2 2
2 2
1 1
1 1
2 2
2 2
2 2
1 1
2 2
2 2
1 1
2 2
2 2
2 2
1 1
1 1
2 2
2 2
2 2
1 1
1 1
1 1
1 1
2 2
1 1
1 1
2 2
1 1
1 1
2 2
2 2
1 1
1 1
2 2
2 2
1 1
1 1
1 1
2 2
2 2
2 2
2 2
1 1
1 1
2 2
1 1
2 2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 2
1 1
1 1
1 1
1 1
2 2
2 2
2 2
2 2
...

output:

49961

result:

ok 1 number(s): "49961"

Test #91:

score: 0
Accepted
time: 19ms
memory: 10156kb

input:

1 99998
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
...

output:

0

result:

ok 1 number(s): "0"

Test #92:

score: 0
Accepted
time: 22ms
memory: 10156kb

input:

1 99999
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
...

output:

0

result:

ok 1 number(s): "0"

Test #93:

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

input:

5 99998
3 5
5 5
5 5
4 4
2 4
4 4
1 4
1 3
2 3
2 2
5 5
4 4
2 4
4 4
1 1
3 5
2 3
5 5
4 4
4 4
3 5
4 4
5 5
3 4
2 3
4 5
4 4
4 4
2 2
3 3
1 1
4 4
4 5
2 4
3 5
2 2
4 4
1 1
1 1
4 5
1 1
1 4
3 5
4 5
5 5
4 4
2 5
1 5
5 5
5 5
2 4
3 3
3 3
1 1
4 5
1 5
1 2
5 5
5 5
3 4
2 3
4 4
4 4
1 1
5 5
5 5
1 2
3 5
2 5
3 3
2 5
3 3
2 3
...

output:

48244

result:

ok 1 number(s): "48244"

Test #94:

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

input:

7 99999
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
7 7
1 1
...

output:

299994

result:

ok 1 number(s): "299994"

Test #95:

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

input:

5 100000
1 1
3 5
2 2
3 4
2 3
5 5
2 3
4 5
3 3
3 4
1 3
3 4
2 2
3 5
1 1
4 5
1 2
5 5
1 3
3 4
1 2
3 5
2 2
4 5
2 3
3 5
2 3
3 5
3 3
3 3
2 2
4 5
1 3
4 5
3 3
4 5
1 2
3 5
1 1
4 5
1 3
5 5
1 3
3 4
1 2
3 4
1 3
3 4
2 2
3 5
1 2
4 5
1 2
4 5
1 3
4 5
2 3
3 3
1 2
3 5
3 3
3 5
3 3
3 4
2 2
3 4
1 1
3 4
1 2
3 3
1 3
3 3
2 3...

output:

55149

result:

ok 1 number(s): "55149"

Test #96:

score: 0
Accepted
time: 13ms
memory: 10112kb

input:

1 99995
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
...

output:

0

result:

ok 1 number(s): "0"

Test #97:

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

input:

9 99997
4 6
8 9
3 9
4 5
7 8
1 8
6 8
1 8
3 4
1 6
3 8
1 9
5 6
4 7
1 8
2 5
4 8
2 6
8 8
4 8
5 6
4 5
5 5
1 4
2 9
1 9
5 8
1 8
8 8
3 5
5 7
2 6
5 8
7 7
5 7
8 8
7 9
4 6
1 2
6 8
5 6
2 3
2 2
5 7
2 3
1 2
2 7
4 8
5 8
1 3
3 8
1 5
2 4
4 8
1 8
1 3
4 5
1 9
5 9
1 2
1 9
1 6
1 3
7 9
3 6
1 6
6 6
5 9
1 4
5 5
3 5
3 6
7 7
...

output:

45681

result:

ok 1 number(s): "45681"

Test #98:

score: 0
Accepted
time: 19ms
memory: 10148kb

input:

2 99995
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
...

output:

0

result:

ok 1 number(s): "0"

Test #99:

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

input:

10 99996
3 10
2 9
3 8
3 8
2 8
2 10
1 10
1 8
2 10
3 10
2 10
3 10
3 9
2 9
2 10
1 8
3 8
3 8
1 10
3 10
1 10
1 10
3 9
2 8
3 10
2 9
1 8
3 9
2 8
2 9
1 10
1 8
2 8
3 9
2 9
3 9
3 8
2 10
1 9
3 9
1 10
3 10
2 8
3 9
1 9
3 8
1 10
2 9
1 10
2 9
1 9
3 9
2 9
2 8
1 10
3 10
3 9
3 8
2 10
2 9
3 9
2 10
3 10
3 9
3 10
3 9
3 ...

output:

0

result:

ok 1 number(s): "0"

Test #100:

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

input:

6 99999
3 4
1 6
4 4
3 5
2 5
3 6
4 4
2 6
1 4
2 6
2 5
4 6
4 4
3 6
3 6
2 4
5 6
1 4
3 6
2 2
4 5
1 3
4 5
2 6
1 6
3 4
1 1
4 6
3 6
1 4
1 2
4 5
1 2
3 3
4 4
1 2
3 4
4 6
1 4
3 6
1 5
2 3
5 6
1 1
2 2
1 6
6 6
1 3
4 4
3 5
1 2
2 4
1 5
5 6
2 4
2 5
1 4
4 6
2 4
5 5
6 6
5 5
2 6
3 6
2 4
3 5
3 3
3 4
3 5
4 6
2 6
5 6
3 3
...

output:

30146

result:

ok 1 number(s): "30146"

Test #101:

score: 0
Accepted
time: 30ms
memory: 13324kb

input:

5 99999
3 5
1 2
1 4
2 4
1 5
4 4
1 2
3 5
4 5
1 5
2 3
3 4
1 2
1 1
1 5
2 3
3 5
2 5
3 5
1 2
1 3
2 5
1 5
2 4
2 3
2 5
3 3
1 5
3 3
3 5
2 4
5 5
2 4
1 4
1 4
4 5
2 4
1 2
3 5
2 2
3 4
2 3
1 5
2 3
3 5
1 1
1 1
3 4
1 5
1 3
5 5
2 4
1 5
2 4
3 4
2 5
1 5
3 5
1 4
2 5
1 4
1 3
1 2
1 4
1 2
3 3
4 4
1 1
1 1
3 5
1 4
3 5
1 3
...

output:

25268

result:

ok 1 number(s): "25268"

Test #102:

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

input:

1 99997
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
...

output:

0

result:

ok 1 number(s): "0"

Test #103:

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

input:

3 99997
2 3
1 3
3 3
2 3
2 3
2 3
3 3
1 2
2 3
3 3
3 3
1 3
1 1
2 2
2 3
1 3
1 2
1 1
2 3
1 2
2 3
1 2
3 3
3 3
1 2
1 3
1 3
1 2
1 1
2 3
2 2
3 3
3 3
1 2
2 3
3 3
1 1
1 3
1 2
2 3
2 2
2 3
1 2
3 3
1 3
1 2
1 3
1 3
1 2
3 3
1 2
1 2
1 3
1 3
1 3
1 3
2 2
2 3
1 1
2 3
2 3
1 1
1 3
1 3
1 3
2 3
1 3
1 2
2 3
1 2
3 3
3 3
1 2
...

output:

15276

result:

ok 1 number(s): "15276"

Test #104:

score: 0
Accepted
time: 54ms
memory: 16532kb

input:

9 99999
1 5
1 4
6 7
4 6
6 8
5 9
6 8
2 6
7 8
4 4
2 6
5 5
6 7
3 5
1 8
2 3
2 7
3 8
7 8
6 7
5 8
5 6
2 2
3 5
7 9
6 7
8 8
2 6
2 3
5 8
5 7
7 8
2 8
5 9
2 6
8 8
5 8
1 5
1 7
1 3
2 4
5 8
7 9
4 7
1 8
3 7
4 9
1 3
5 8
1 4
2 8
1 4
2 3
2 4
6 7
6 6
5 5
3 9
3 5
6 9
3 5
7 8
4 5
2 3
1 4
4 5
1 6
1 3
5 8
4 9
2 3
1 7
5 7
...

output:

45368

result:

ok 1 number(s): "45368"

Test #105:

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

input:

6 99997
3 6
1 4
5 6
1 6
4 4
6 6
1 2
1 5
1 5
3 3
1 4
2 4
3 4
2 5
4 5
1 1
4 5
4 5
1 6
4 5
5 6
2 6
2 3
2 3
6 6
1 2
2 4
1 2
6 6
1 4
2 6
2 3
1 4
1 5
1 2
1 3
5 6
1 3
2 4
4 5
6 6
2 6
4 4
3 5
2 4
2 5
1 6
3 4
4 5
1 2
1 6
2 6
2 6
2 5
2 4
1 6
5 5
2 5
1 5
1 2
5 5
3 6
1 2
1 4
1 4
3 4
3 4
1 3
2 5
3 4
3 5
4 6
1 6
...

output:

30319

result:

ok 1 number(s): "30319"