QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#518204#9189. Make them MeetQingyu100 ✓7ms4132kbC++235.9kb2024-08-13 18:04:322024-08-13 18:04:32

Judging History

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

  • [2024-08-13 18:04:32]
  • 评测
  • 测评结果:100
  • 用时:7ms
  • 内存:4132kb
  • [2024-08-13 18:04:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

const int MAXN = 201;
int n,m;
vector<vi> C(MAXN, vi());
int ADJ[MAXN][MAXN] = {0};
vector<vi> ANS;

int root, n1, n2; // root and its neighbours

int PAR[MAXN] = {0};
int DEPTH[MAXN] = {0};
int MAX_SUBTREE_DEPTH[MAXN] = {0};
int mark[MAXN] = {0};
vector<vi> TREE(MAXN, vi());

void dfs1(int i, int par){
    if(mark[i] == 1)return;
    mark[i] = 1;
    PAR[i] = par;
    if(par != -1)DEPTH[i] = DEPTH[par]+1;
    MAX_SUBTREE_DEPTH[i] = DEPTH[i];
    trav(y, C[i]){
        if(mark[y] == 0){
            TREE[i].push_back(y);
            dfs1(y, i);
            MAX_SUBTREE_DEPTH[i] = max(MAX_SUBTREE_DEPTH[i], MAX_SUBTREE_DEPTH[y]);
        }
    }
}

int F[MAXN] = {0};
int B[MAXN] = {0};
int f = 0; // number of f:s

void make_move(vi col){

    vi new_f(n,0);
    ANS.push_back(col);

    rep(c1,0,n){
        bool OR = 0;
        bool alone = 1;
        trav(y, C[c1]){
            if(col[y] == col[c1]){
                alone = 0;
                OR |= F[y];
            }
        }

        if(alone){
            new_f[c1] = F[c1];
        }
        else{
            new_f[c1] = OR;
        }
    }

    f = 0;
    rep(c1,0,n){
        F[c1] = new_f[c1];
        f += F[c1];
    }
}

void move_group(vi v){
    // color v the same, color everything else in different colors
    vi in_group(n,0);
    vi col(n,0);
    trav(y, v){
        in_group[y] = 1;
    }
    int c = 2;
    rep(c1,0,n){
        if(in_group[c1]){
            col[c1] = 1;
        }
        else{
            col[c1] = c;
            c++;
        }
    }
    make_move(col);
}

int max_depth = 0;

bool comp_tree(int i, int j){
    return MAX_SUBTREE_DEPTH[i] < MAX_SUBTREE_DEPTH[j];
}

bool last_visited[MAXN] = {0};
int last_seen = 0;

void last_dfs(int i){
    if(!last_visited[i]){
        last_visited[i] = 1;
        last_seen++;
    }
    if(last_seen == n)return;
    sort(all(TREE[i]), comp_tree);
    trav(y, TREE[i]){
        move_group({i, y});
        last_dfs(y);
        if(last_seen == n)return;
        move_group({i, y});
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> m;

    if(m == (n*n-n)/2){
        // Clique
        // Greedy matching seems to be linear
        // Can also be done with divide and conquer
        vector<vi> done(n, vi(n, 0));
        int matched = 0;
        while(matched < (n*n-n)/2){
            vi row(n,-1);
            int color = 1;
            rep(c1,0,n){
                if(row[c1] == -1){
                    row[c1] = color;
                    rep(c2,1,n){
                        int j = (c1+c2)%n;
                        if(row[j] == -1 && done[c1][j] == 0){
                            done[c1][j] = 1;
                            done[j][c1] = 1;
                            matched++;
                            row[j] = color;
                            break;
                        }
                    }
                    color++;
                }
            }
            ANS.push_back(row);
            ANS.push_back(row);
        }
    }
    else{
        // Non-clique
        rep(c1,0,m){
            int a,b;
            cin >> a >> b;
            C[a].push_back(b);
            C[b].push_back(a);
            ADJ[a][b] = 1;
            ADJ[b][a] = 1;
        }

        // Find root. n^3 because why not.
        rep(c1,0,n){
            rep(c2,0,n){
                rep(c3,0,n){
                    if(c1 != c2 && c1 != c3 && c2 != c3){
                        if(ADJ[c2][c1] && ADJ[c1][c3] && !ADJ[c2][c3]){
                            root = c1;
                            n1 = c2;
                            n2 = c3;
                            goto root_done;
                        }
                    }
                }
            }
        }

        root_done:

        swap(n1, root); // better if n1 is the root

        dfs1(root, -1);

        rep(c1,0,n){
            max_depth = max(max_depth, DEPTH[c1]);
            if(c1 != root)F[c1] = 1;
            int min_depth = n+1;
            trav(y, C[c1]){
                if(DEPTH[y] < min_depth){
                    min_depth = DEPTH[y];
                    B[c1] = y;
                }
            }
        }
        f = n-1;

        // make F[x] = 0 where for max_depth-1
        rep(d,0,max_depth-1){
            vi v;
            rep(c1,0,n){
                if(DEPTH[c1] == d || DEPTH[c1] == d+1){
                    v.push_back(c1);
                }
            }
            move_group(v);
        }

        for(int d = max_depth-1; d >= 1; d--){
            rep(c1,0,n){
                if(DEPTH[B[c1]] == d){
                    move_group({c1, B[c1], PAR[B[c1]]});
                    move_group({B[c1], PAR[B[c1]]});
                }
            }

            vi v;
            rep(c1,0,n){
                if(DEPTH[c1] == d || DEPTH[c1] == d-1){
                    v.push_back(c1);
                }
            }
            move_group(v);
        }

        // remove any extra F from n1
        move_group({root, n1});
        move_group({root, n1, n2});
        move_group({n1, n2});

        rep(c1,0,n){
            if(F[c1] == 1 && c1 != n2){
                // This should be a neighbour of the root
                move_group({c1, root});
                move_group({root, n1, n2});
                move_group({n1, n2});
            }
        }

        // this is a bit unnecessary, but only 2 queries so who cares
        move_group({n1, n2});
        move_group({n1, root});

        // everyone now at root

        assert(f == 1);

        last_dfs(root);

    }

    cout << sz(ANS) << "\n";
    trav(v, ANS){
        trav(c, v){
            cout << c << " ";
        }cout << "\n";
    }
	
 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

2 1
0 1

output:

2
1 1 
1 1 

result:

points 1.0

Test #2:

score: 10
Accepted
time: 1ms
memory: 3904kb

input:

3 2
0 1
0 2

output:

13
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 2 1 
1 2 1 
1 1 2 
1 1 2 
1 2 1 

result:

points 1.0

Test #3:

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

input:

4 3
0 1
0 2
0 3

output:

17
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 1 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 2 1 3 
1 2 1 3 
1 1 2 3 
1 1 2 3 
1 2 1 3 
1 2 1 3 
1 2 3 1 

result:

points 1.0

Test #4:

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

input:

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

output:

397
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 1 2 3 ...

result:

points 1.0

Test #5:

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

input:

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

output:

401
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 1 2...

result:

points 1.0

Subtask #2:

score: 13
Accepted

Test #6:

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

input:

2 1
0 1

output:

2
1 1 
1 1 

result:

points 1.0

Test #7:

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

input:

3 3
1 2
0 1
0 2

output:

6
1 1 2 
1 1 2 
1 2 1 
1 2 1 
1 2 2 
1 2 2 

result:

points 1.0

Test #8:

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

input:

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

output:

6
1 1 2 2 
1 1 2 2 
1 2 1 2 
1 2 1 2 
1 2 2 1 
1 2 2 1 

result:

points 1.0

Test #9:

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

input:

10 45
4 9
2 8
5 9
1 2
2 9
4 5
5 7
6 7
1 3
1 9
3 4
0 3
4 7
0 6
5 6
7 9
4 8
6 8
0 5
1 8
3 9
1 6
6 9
4 6
0 8
2 3
0 4
0 9
0 7
3 6
0 2
2 5
3 7
3 5
7 8
5 8
8 9
0 1
2 7
1 7
1 4
2 6
2 4
3 8
1 5

output:

30
1 1 2 2 3 3 4 4 5 5 
1 1 2 2 3 3 4 4 5 5 
1 2 1 2 3 4 3 4 5 6 
1 2 1 2 3 4 3 4 5 6 
1 2 2 1 3 4 4 3 5 6 
1 2 2 1 3 4 4 3 5 6 
1 2 3 4 1 2 3 4 5 6 
1 2 3 4 1 2 3 4 5 6 
1 2 3 4 2 1 4 3 5 6 
1 2 3 4 2 1 4 3 5 6 
1 2 3 4 3 4 1 2 5 6 
1 2 3 4 3 4 1 2 5 6 
1 2 3 4 4 3 2 1 5 6 
1 2 3 4 4 3 2 1 5 6 
1 2...

result:

points 1.0

Test #10:

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

input:

15 105
4 10
8 13
0 12
11 12
2 13
8 14
6 10
0 4
8 12
2 12
1 13
5 9
2 8
7 10
6 13
0 13
9 13
7 11
3 13
0 3
4 7
5 13
7 13
0 7
0 11
0 8
0 2
2 4
2 6
6 9
0 1
9 11
1 9
3 14
3 4
10 11
5 10
0 9
3 9
6 11
2 10
5 6
2 5
1 14
6 8
9 12
2 11
9 10
5 12
5 14
4 14
7 14
5 8
5 7
1 12
0 14
7 9
3 11
1 8
0 10
1 3
8 9
4 6
10...

output:

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

result:

points 1.0

Test #11:

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

input:

30 435
5 6
8 11
3 26
8 29
10 22
6 20
18 22
23 27
13 18
2 26
21 25
11 15
25 28
2 22
18 20
3 13
10 19
6 29
10 15
0 13
7 22
13 28
9 16
2 28
6 16
3 17
6 14
4 8
16 17
9 22
22 24
26 29
14 28
19 29
28 29
4 28
13 23
12 19
1 2
5 10
1 6
2 4
25 27
4 22
9 26
16 23
5 16
6 11
0 17
16 27
0 7
15 26
2 16
8 12
1 25
3...

output:

62
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 
1 2 2...

result:

points 1.0

Test #12:

score: 13
Accepted
time: 1ms
memory: 3944kb

input:

40 780
21 24
11 32
12 27
19 20
3 35
25 35
32 35
27 33
0 24
1 3
1 29
14 25
8 30
24 31
14 32
7 12
5 31
28 35
7 10
18 24
13 32
1 26
3 4
10 30
14 38
22 24
9 31
5 10
17 32
2 34
28 39
3 38
13 34
6 10
0 6
9 25
11 14
13 20
10 20
18 28
6 33
34 35
29 33
16 39
4 38
3 24
20 29
17 18
33 36
13 37
24 27
12 33
5 29...

output:

126
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 15 16 17 18 17 18 ...

result:

points 1.0

Test #13:

score: 13
Accepted
time: 1ms
memory: 3688kb

input:

50 1225
6 10
14 36
0 34
7 23
22 31
18 34
2 19
13 21
0 46
0 11
2 43
2 11
13 20
13 19
7 39
35 37
9 17
31 38
13 40
7 28
2 41
20 46
25 36
12 39
1 37
21 42
33 48
10 24
13 26
26 37
0 47
17 19
1 28
28 40
15 40
11 22
10 19
24 28
12 28
19 40
6 12
13 48
20 37
11 46
8 19
5 24
16 28
15 47
31 34
11 21
28 33
14 1...

output:

126
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 ...

result:

points 1.0

Test #14:

score: 13
Accepted
time: 2ms
memory: 4032kb

input:

100 4950
24 39
27 46
11 71
57 65
3 8
84 97
74 87
17 49
12 72
1 4
22 83
29 42
28 65
39 89
29 92
26 78
45 53
18 44
33 43
14 98
50 66
21 95
32 67
21 33
21 80
59 77
70 85
13 16
0 41
31 65
51 80
22 80
30 79
55 75
54 82
29 57
72 97
31 85
86 87
60 90
1 17
65 81
13 15
44 71
58 88
65 87
8 31
77 99
4 44
29 43...

output:

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

result:

points 1.0

Subtask #3:

score: 11
Accepted

Test #15:

score: 11
Accepted
time: 0ms
memory: 3896kb

input:

2 1
0 1

output:

2
1 1 
1 1 

result:

points 1.0

Test #16:

score: 11
Accepted
time: 0ms
memory: 3636kb

input:

3 2
0 1
1 2

output:

13
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 1 2 
1 1 2 
1 1 2 
1 1 1 
2 1 1 
2 1 1 
1 1 2 
1 1 2 
2 1 1 

result:

points 1.0

Test #17:

score: 11
Accepted
time: 0ms
memory: 3616kb

input:

4 3
0 1
1 2
2 3

output:

18
1 1 2 3 
2 1 1 3 
2 1 1 1 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
2 1 1 3 
2 3 1 1 

result:

points 1.0

Test #18:

score: 11
Accepted
time: 1ms
memory: 3704kb

input:

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

output:

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

result:

points 1.0

Test #19:

score: 11
Accepted
time: 3ms
memory: 3872kb

input:

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

output:

493
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
2 1 1 3 ...

result:

points 1.0

Test #20:

score: 11
Accepted
time: 3ms
memory: 3872kb

input:

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

output:

498
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #21:

score: 11
Accepted
time: 1ms
memory: 3764kb

input:

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

output:

318
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 
2 1 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 ...

result:

points 1.0

Subtask #4:

score: 36
Accepted

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Test #22:

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

input:

2 1
0 1

output:

2
1 1 
1 1 

result:

points 1.0

Test #23:

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

input:

3 2
0 1
0 2

output:

13
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 2 1 
1 2 1 
1 1 2 
1 1 2 
1 2 1 

result:

points 1.0

Test #24:

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

input:

4 3
0 1
0 2
0 3

output:

17
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 1 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 2 1 3 
1 2 1 3 
1 1 2 3 
1 1 2 3 
1 2 1 3 
1 2 1 3 
1 2 3 1 

result:

points 1.0

Test #25:

score: 36
Accepted
time: 2ms
memory: 4056kb

input:

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

output:

397
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 1 2 3 ...

result:

points 1.0

Test #26:

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

input:

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

output:

401
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 1 2...

result:

points 1.0

Test #27:

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

input:

3 2
0 1
1 2

output:

13
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 1 2 
1 1 2 
1 1 2 
1 1 1 
2 1 1 
2 1 1 
1 1 2 
1 1 2 
2 1 1 

result:

points 1.0

Test #28:

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

input:

4 3
0 1
1 2
2 3

output:

18
1 1 2 3 
2 1 1 3 
2 1 1 1 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
2 1 1 3 
2 3 1 1 

result:

points 1.0

Test #29:

score: 36
Accepted
time: 1ms
memory: 3768kb

input:

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

output:

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

result:

points 1.0

Test #30:

score: 36
Accepted
time: 3ms
memory: 3836kb

input:

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

output:

493
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
2 1 1 3 ...

result:

points 1.0

Test #31:

score: 36
Accepted
time: 3ms
memory: 4132kb

input:

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

output:

498
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #32:

score: 36
Accepted
time: 1ms
memory: 3992kb

input:

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

output:

318
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 
2 1 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 ...

result:

points 1.0

Test #33:

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

input:

5 4
2 1
3 2
4 1
1 0

output:

22
1 1 2 3 4 
2 1 1 3 1 
2 1 1 1 3 
2 1 1 3 4 
2 1 1 3 1 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
1 1 2 3 4 
1 1 2 3 1 
1 1 2 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
2 1 1 3 4 
2 1 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
2 1 3 4 1 
2 1 3 4 1 
2 1 1 3 4 
2 3 1 1 4 

result:

points 1.0

Test #34:

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

input:

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

output:

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

result:

points 1.0

Test #35:

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

input:

11 10
2 0
8 6
1 0
5 3
9 7
7 5
4 3
6 5
10 9
3 1

output:

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

result:

points 1.0

Test #36:

score: 36
Accepted
time: 2ms
memory: 3780kb

input:

100 99
2 1
91 16
24 19
45 0
55 9
21 19
7 2
97 9
40 3
61 47
34 9
36 10
27 0
73 24
53 6
79 67
51 4
18 3
25 5
67 26
15 9
82 65
19 17
43 11
92 36
62 29
59 20
22 0
32 21
66 25
50 19
5 0
23 7
78 64
42 28
28 6
8 1
98 94
10 8
84 50
88 0
87 51
89 61
72 28
14 6
63 31
33 23
57 38
11 9
38 33
16 2
86 8
69 66
54 ...

output:

409
1 1 1 1 2 3 4 5 1 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 1 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 
1 2 1 1 1...

result:

points 1.0

Test #37:

score: 36
Accepted
time: 3ms
memory: 3836kb

input:

100 99
65 64
90 89
96 95
29 28
61 60
50 49
95 93
37 36
42 40
45 43
94 93
16 15
8 7
67 66
54 52
15 13
38 37
77 76
1 0
89 88
39 37
21 20
63 62
49 48
58 56
53 51
10 9
46 44
9 7
20 19
70 69
73 71
56 54
57 56
24 23
48 46
60 58
83 82
6 4
34 33
12 11
19 18
82 81
23 21
55 53
41 39
18 17
91 89
14 12
26 25
64...

output:

467
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 1...

result:

points 1.0

Test #38:

score: 36
Accepted
time: 3ms
memory: 3828kb

input:

100 99
11 8
17 16
98 95
89 86
53 51
88 86
63 62
15 12
83 82
73 72
97 96
5 4
6 5
51 49
16 13
81 78
94 93
25 22
70 68
23 21
44 41
74 73
2 1
28 27
37 36
30 27
35 32
77 76
50 49
22 19
82 79
85 83
45 44
95 94
24 23
10 9
21 20
72 69
78 75
43 40
39 38
19 17
42 41
52 50
34 32
62 61
65 62
79 76
90 89
69 66
4...

output:

451
1 1 1 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
1 2 1 1...

result:

points 1.0

Test #39:

score: 36
Accepted
time: 3ms
memory: 3924kb

input:

100 99
82 47
37 20
37 44
37 86
37 56
99 58
80 13
56 39
37 93
37 64
3 73
53 32
91 75
97 78
37 30
59 90
15 22
37 52
37 79
25 4
37 71
37 3
37 51
12 2
37 91
37 34
37 38
37 36
37 40
95 67
37 28
14 83
42 26
37 14
37 9
37 42
34 74
37 72
1 81
86 7
98 87
29 17
37 31
92 62
79 45
37 59
31 50
20 96
69 24
37 97
...

output:

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

result:

points 1.0

Test #40:

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

input:

100 99
61 80
7 74
86 22
54 45
71 97
33 37
71 49
71 59
0 79
14 5
88 86
6 92
48 18
52 15
20 81
62 61
63 52
78 1
85 93
24 48
96 0
50 88
82 53
68 36
16 34
95 21
81 58
87 90
60 26
28 68
90 73
21 19
71 43
83 84
71 63
76 6
71 24
1 39
67 55
44 3
65 31
64 78
19 83
32 65
35 47
89 38
37 25
94 41
43 62
5 46
71 ...

output:

416
1 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #41:

score: 36
Accepted
time: 3ms
memory: 3828kb

input:

100 99
8 3
47 1
50 49
4 1
89 88
84 83
68 67
34 19
40 35
77 76
12 6
52 51
71 70
66 65
97 96
33 1
53 52
83 82
51 50
79 78
43 7
91 90
92 91
62 61
49 28
31 9
96 95
42 0
82 81
36 34
5 2
58 57
15 5
72 71
29 25
54 53
93 92
95 94
59 58
76 75
65 64
55 54
74 73
2 1
18 11
27 0
14 10
13 10
69 68
39 0
85 84
81 8...

output:

458
1 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 30 31 32 33 34 35 36 37 38 39 40 41 42 1 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 
1 2 1 1 1 ...

result:

points 1.0

Test #42:

score: 36
Accepted
time: 3ms
memory: 4132kb

input:

100 99
79 78
39 33
3 1
23 19
2 0
31 23
26 18
33 24
86 85
25 20
83 82
1 0
60 59
14 10
29 25
17 8
7 5
68 67
34 28
58 57
84 83
48 46
90 89
54 53
12 3
50 49
9 1
64 63
24 18
95 94
41 34
99 98
97 96
4 2
87 86
10 9
56 55
51 50
5 1
11 8
65 64
98 97
52 51
16 14
37 31
80 79
67 66
8 4
42 32
93 92
73 72
15 6
82...

output:

463
1 1 2 1 3 1 1 4 5 1 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 
1 2 1 1 3...

result:

points 1.0

Test #43:

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

input:

100 99
99 98
74 73
40 38
38 37
80 79
48 46
29 26
3 1
37 34
17 15
62 61
30 27
81 80
8 6
45 42
76 75
88 87
32 30
31 29
75 74
34 33
83 82
16 14
14 11
73 72
96 95
12 11
95 94
68 67
67 66
26 25
2 1
19 18
49 47
20 17
85 84
57 56
28 26
63 62
64 63
10 8
71 70
13 10
69 68
53 52
35 32
33 31
55 54
46 43
54 53
...

output:

473
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #44:

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

input:

100 99
38 39
9 10
96 45
57 8
35 36
54 32
85 50
8 9
84 46
97 35
32 33
74 4
22 23
18 19
39 40
75 17
12 13
66 37
63 27
11 12
42 43
25 26
29 30
21 22
49 50
6 7
95 32
82 50
89 19
4 5
16 17
93 50
70 22
53 26
81 41
68 27
94 21
41 42
15 16
17 18
72 2
60 48
47 48
28 29
19 20
99 6
13 14
88 50
64 44
34 35
30 3...

output:

450
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #45:

score: 36
Accepted
time: 2ms
memory: 3828kb

input:

100 99
34 35
10 11
86 0
69 0
24 25
78 0
92 0
19 20
30 31
20 21
25 26
45 46
81 0
32 33
51 0
61 0
90 0
41 42
4 5
57 0
64 0
23 24
8 9
98 0
53 0
42 43
76 0
0 1
21 22
56 0
22 23
43 44
89 0
5 6
9 10
70 0
74 0
37 38
14 15
65 0
71 0
1 2
39 40
44 45
91 0
46 47
49 50
29 30
83 0
48 49
13 14
36 37
58 0
2 3
15 1...

output:

449
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #46:

score: 36
Accepted
time: 2ms
memory: 3828kb

input:

100 99
7 0
33 0
70 2
98 2
13 0
32 0
77 2
88 2
49 0
5 0
89 2
54 2
61 2
94 2
64 2
48 0
12 0
86 2
28 0
52 2
22 0
38 0
74 2
4 0
80 2
41 0
6 0
43 0
35 0
44 0
92 2
78 2
99 2
19 0
11 0
68 2
23 0
26 0
87 2
73 2
0 1
85 2
57 2
67 2
69 2
76 2
21 0
56 2
60 2
91 2
90 2
51 2
47 0
14 0
59 2
30 0
79 2
96 2
95 2
53 ...

output:

402
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 1 2 ...

result:

points 1.0

Test #47:

score: 36
Accepted
time: 2ms
memory: 3928kb

input:

100 99
73 30
96 30
72 30
31 0
46 0
82 30
6 7
65 30
79 30
97 30
88 30
91 30
44 0
85 30
60 0
33 0
27 28
57 0
83 30
1 2
43 0
24 25
16 17
38 0
49 0
15 16
48 0
10 11
55 0
17 18
81 30
76 30
54 0
39 0
26 27
68 30
95 30
78 30
71 30
84 30
42 0
20 21
86 30
70 30
47 0
56 0
21 22
63 0
36 0
14 15
34 0
7 8
53 0
7...

output:

430
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #48:

score: 36
Accepted
time: 3ms
memory: 3828kb

input:

100 99
14 15
87 48
58 40
72 30
79 33
98 45
80 24
60 4
82 0
25 26
42 43
85 4
23 24
48 49
47 48
16 17
92 1
95 38
11 12
70 34
10 11
28 29
78 9
8 9
59 37
76 14
68 45
31 32
86 10
45 46
66 14
6 7
61 38
0 1
19 20
73 25
89 2
32 33
90 19
71 35
21 22
37 38
24 25
93 17
39 40
84 49
2 3
7 8
83 42
67 12
18 19
1 2...

output:

451
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1 91 92 93 94 95 96 97 
1 2 1 1...

result:

points 1.0

Test #49:

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

input:

100 99
96 94
89 87
74 73
64 62
33 31
21 19
42 41
45 44
12 11
50 48
77 76
58 57
84 83
93 92
97 95
6 4
32 30
9 7
52 51
53 52
38 36
3 2
43 42
94 93
27 26
15 13
60 59
28 27
82 80
95 94
16 14
68 67
85 83
72 70
44 43
25 23
73 72
55 54
81 80
40 39
78 77
47 45
35 34
10 8
79 78
75 73
61 59
57 55
39 37
22 21
...

output:

470
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 1...

result:

points 1.0

Test #50:

score: 36
Accepted
time: 2ms
memory: 3824kb

input:

100 99
22 45
25 51
9 19
23 48
38 77
37 75
14 29
29 59
39 79
25 52
27 55
33 68
8 17
15 31
36 74
21 44
0 1
5 11
17 35
35 71
36 73
32 66
7 16
5 12
18 37
39 80
3 8
43 87
21 43
40 82
45 92
35 72
10 21
11 23
16 34
18 38
13 27
15 32
41 84
31 63
20 41
12 25
28 57
32 65
7 15
3 7
20 42
2 5
42 85
31 64
0 2
19 ...

output:

408
1 1 2 1 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
1 2 1 1...

result:

points 1.0

Test #51:

score: 36
Accepted
time: 2ms
memory: 3780kb

input:

100 99
83 3
42 0
34 5
72 1
8 3
5 1
7 2
73 4
32 0
36 5
93 3
50 5
77 4
88 4
84 2
30 1
14 2
54 3
78 4
92 1
33 3
65 3
96 5
4 3
12 4
98 5
39 2
56 1
28 2
51 1
68 3
90 2
18 5
6 2
49 0
94 1
57 1
99 3
74 1
41 4
79 0
53 5
52 1
19 5
61 2
48 1
75 5
15 1
67 5
76 5
47 4
87 2
63 3
85 5
3 1
37 3
71 4
22 1
91 2
24 1...

output:

427
1 1 1 1 2 1 3 4 5 6 7 8 9 1 10 1 11 12 13 14 15 16 1 17 1 18 19 20 21 1 1 1 22 23 24 25 26 27 1 28 1 29 30 31 32 33 34 35 1 36 37 1 1 38 39 1 1 1 1 40 41 42 43 44 45 46 47 48 49 50 51 52 1 53 1 54 55 56 57 58 59 60 1 61 62 63 64 65 66 67 68 69 1 70 1 1 71 72 73 74 
1 2 1 1 1 1 1 1 1 1 1 1 3 1 1 ...

result:

points 1.0

Test #52:

score: 36
Accepted
time: 2ms
memory: 3888kb

input:

100 99
52 15
41 6
94 2
31 25
45 15
86 25
68 16
80 0
25 23
42 21
53 20
57 24
88 22
6 0
62 16
98 16
32 1
23 4
84 25
38 16
55 12
3 0
39 19
87 9
56 10
30 9
36 17
73 20
64 10
54 24
35 16
20 7
22 16
37 12
99 0
66 19
58 16
34 13
10 8
91 3
95 23
75 2
7 0
15 2
26 18
70 14
9 4
67 3
65 17
85 11
13 3
93 14
81 3...

output:

411
1 1 1 2 3 4 5 6 1 7 8 9 10 11 12 13 14 15 1 1 16 17 18 19 20 21 22 23 24 25 26 27 1 28 29 30 31 32 33 34 35 36 37 38 1 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 1 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 
1 2 1 1 1 3 ...

result:

points 1.0

Test #53:

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

input:

100 99
35 36
79 80
95 96
26 27
88 89
86 87
25 26
59 60
80 81
15 16
82 83
64 65
12 13
45 46
96 97
14 15
2 3
39 40
41 42
91 92
3 4
71 72
20 21
4 5
28 29
87 88
32 33
38 39
67 68
11 12
84 85
74 75
81 82
65 66
53 54
70 71
57 58
66 67
98 17
18 19
13 14
43 44
75 76
55 56
19 20
22 23
6 7
37 38
94 95
63 64
6...

output:

496
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #54:

score: 36
Accepted
time: 3ms
memory: 3780kb

input:

100 99
51 52
31 32
52 53
72 64
9 10
4 5
6 7
14 15
48 49
3 4
19 20
2 3
80 44
38 39
62 58
1 2
58 59
22 23
90 22
61 46
8 9
17 18
42 43
25 26
96 29
39 40
43 44
67 19
75 65
91 4
74 7
78 6
69 67
70 5
86 50
98 49
36 37
71 69
79 6
81 8
56 57
89 68
28 29
0 1
47 48
10 11
11 12
50 51
46 47
23 24
15 16
24 25
73...

output:

458
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #55:

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

input:

4 3
2 1
3 2
1 0

output:

18
1 1 2 3 
2 1 1 3 
2 1 1 1 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
2 1 1 3 
2 3 1 1 

result:

points 1.0

Test #56:

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

input:

4 3
3 0
1 0
2 1

output:

18
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 1 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 1 
1 2 3 1 
2 1 1 3 
1 1 2 1 
1 2 3 1 
1 2 3 1 
1 1 2 3 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 2 3 1 

result:

points 1.0

Test #57:

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

input:

5 4
4 3
1 0
2 0
3 1

output:

22
1 1 2 1 3 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
1 1 2 3 4 
2 1 3 1 1 
2 1 3 1 4 
1 1 2 1 3 
1 1 2 3 4 
1 1 1 2 3 
1 2 1 3 4 
2 1 3 1 4 
1 1 1 2 3 
1 2 1 3 4 
1 2 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 2 1 3 4 
1 2 1 3 4 
1 1 2 3 4 
2 1 3 1 4 
2 3 4 1 1 

result:

points 1.0

Test #58:

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

input:

5 4
1 0
3 2
2 1
4 3

output:

23
1 1 2 3 4 
2 1 1 3 4 
2 3 1 1 4 
2 3 1 1 1 
2 3 1 1 4 
2 3 1 1 4 
2 1 1 1 3 
2 1 1 3 4 
2 1 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
1 1 2 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
2 1 1 3 4 
2 1 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
2 1 1 3 4 
2 3 1 1 4 
2 3 4 1 1 

result:

points 1.0

Test #59:

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

input:

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

output:

26
1 1 1 2 3 4 
1 1 2 3 4 5 
1 1 2 3 4 5 
2 1 1 1 3 4 
2 1 1 3 4 5 
1 1 2 3 1 4 
1 1 2 3 4 5 
2 1 1 3 4 1 
2 1 1 3 4 5 
1 1 1 2 3 4 
1 1 2 3 4 5 
1 1 2 3 1 4 
1 2 3 4 1 5 
2 1 1 3 4 5 
1 1 2 3 1 4 
1 2 3 4 1 5 
1 2 3 4 1 5 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 2 3 4 1 5 
1 2 3 4 1 5 
1 1 2 3 4 5 
2 1 1 3 4 5...

result:

points 1.0

Test #60:

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

input:

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

output:

26
1 1 2 3 4 5 
1 2 1 1 3 1 
1 2 3 1 1 4 
1 2 3 1 4 5 
1 2 1 1 3 1 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 1 1 2 3 4 
1 1 2 3 4 5 
1 1 2 1 3 4 
1 1 2 3 4 5 
1 1 2 3 4 1 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 1 1 2 3 4 
1 2 1 3 4 5 
1 2 1 3 4 5 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 2 1 3 4 5 
1 2 1 3 4 5 
1 2 3 4 5 1...

result:

points 1.0

Test #61:

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

input:

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

output:

32
1 1 1 2 1 3 4 
1 2 1 1 1 1 3 
2 3 1 1 4 5 1 
2 3 1 1 4 5 6 
1 2 1 1 1 1 3 
2 1 1 3 4 5 6 
2 1 1 3 4 5 6 
2 1 1 1 3 4 5 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 1 2 1 3 4 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 6 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 6 
2 1 3 4 1 5 6 
1 1 2 3 4 1 ...

result:

points 1.0

Test #62:

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

input:

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

output:

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

result:

points 1.0

Test #63:

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

input:

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

output:

31
1 1 2 1 3 4 5 
1 2 1 1 1 3 1 
2 3 4 1 1 1 5 
2 3 4 1 1 5 6 
1 2 1 1 1 3 1 
2 1 3 1 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
2 1 3 1 1 4 5 
2 1 3 1 4 5 6 
1 1 2 3 4 5 1 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #64:

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

input:

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

output:

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

result:

points 1.0

Test #65:

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

input:

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

output:

31
1 1 1 2 3 4 5 
1 2 1 1 3 1 4 
2 3 1 1 1 4 5 
2 3 1 1 4 5 6 
2 3 1 1 4 5 1 
2 3 1 1 4 5 6 
1 2 1 1 3 1 4 
2 1 1 3 4 5 6 
2 1 1 3 4 5 6 
2 1 1 1 3 4 5 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 6 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 ...

result:

points 1.0

Test #66:

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

input:

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

output:

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

result:

points 1.0

Test #67:

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

input:

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

output:

31
1 1 2 1 3 4 5 
1 2 1 1 1 1 3 
1 2 3 4 1 5 1 
1 2 3 4 1 5 6 
1 2 1 1 1 1 3 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #68:

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

input:

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

output:

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

result:

points 1.0

Test #69:

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

input:

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

output:

31
1 1 2 3 4 1 5 
1 2 1 1 1 1 3 
1 2 1 3 4 5 1 
1 2 1 3 4 5 6 
1 2 1 1 1 1 3 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 4 5 1 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #70:

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

input:

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

output:

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

result:

points 1.0

Test #71:

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

input:

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

output:

32
1 1 2 1 3 1 1 
2 1 3 1 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 1 3 1 1 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 4 5 1 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 4 5 6 1 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #72:

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

input:

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

output:

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

result:

points 1.0

Test #73:

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

input:

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

output:

31
1 1 2 1 3 4 5 
1 2 1 1 1 3 1 
1 2 3 4 1 1 5 
1 2 3 4 1 5 6 
1 2 1 1 1 3 1 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 5 1 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #74:

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

input:

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

output:

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

result:

points 1.0

Subtask #5:

score: 30
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #75:

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

input:

2 1
0 1

output:

2
1 1 
1 1 

result:

points 1.0

Test #76:

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

input:

3 2
0 1
0 2

output:

13
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 2 1 
1 2 1 
1 1 2 
1 1 2 
1 2 1 

result:

points 1.0

Test #77:

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

input:

4 3
0 1
0 2
0 3

output:

17
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 1 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 2 1 3 
1 2 1 3 
1 1 2 3 
1 1 2 3 
1 2 1 3 
1 2 1 3 
1 2 3 1 

result:

points 1.0

Test #78:

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

input:

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

output:

397
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 1 2 3 ...

result:

points 1.0

Test #79:

score: 30
Accepted
time: 2ms
memory: 3892kb

input:

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

output:

401
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 1 2...

result:

points 1.0

Test #80:

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

input:

3 3
1 2
0 1
0 2

output:

6
1 1 2 
1 1 2 
1 2 1 
1 2 1 
1 2 2 
1 2 2 

result:

points 1.0

Test #81:

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

input:

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

output:

6
1 1 2 2 
1 1 2 2 
1 2 1 2 
1 2 1 2 
1 2 2 1 
1 2 2 1 

result:

points 1.0

Test #82:

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

input:

10 45
4 9
2 8
5 9
1 2
2 9
4 5
5 7
6 7
1 3
1 9
3 4
0 3
4 7
0 6
5 6
7 9
4 8
6 8
0 5
1 8
3 9
1 6
6 9
4 6
0 8
2 3
0 4
0 9
0 7
3 6
0 2
2 5
3 7
3 5
7 8
5 8
8 9
0 1
2 7
1 7
1 4
2 6
2 4
3 8
1 5

output:

30
1 1 2 2 3 3 4 4 5 5 
1 1 2 2 3 3 4 4 5 5 
1 2 1 2 3 4 3 4 5 6 
1 2 1 2 3 4 3 4 5 6 
1 2 2 1 3 4 4 3 5 6 
1 2 2 1 3 4 4 3 5 6 
1 2 3 4 1 2 3 4 5 6 
1 2 3 4 1 2 3 4 5 6 
1 2 3 4 2 1 4 3 5 6 
1 2 3 4 2 1 4 3 5 6 
1 2 3 4 3 4 1 2 5 6 
1 2 3 4 3 4 1 2 5 6 
1 2 3 4 4 3 2 1 5 6 
1 2 3 4 4 3 2 1 5 6 
1 2...

result:

points 1.0

Test #83:

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

input:

15 105
4 10
8 13
0 12
11 12
2 13
8 14
6 10
0 4
8 12
2 12
1 13
5 9
2 8
7 10
6 13
0 13
9 13
7 11
3 13
0 3
4 7
5 13
7 13
0 7
0 11
0 8
0 2
2 4
2 6
6 9
0 1
9 11
1 9
3 14
3 4
10 11
5 10
0 9
3 9
6 11
2 10
5 6
2 5
1 14
6 8
9 12
2 11
9 10
5 12
5 14
4 14
7 14
5 8
5 7
1 12
0 14
7 9
3 11
1 8
0 10
1 3
8 9
4 6
10...

output:

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

result:

points 1.0

Test #84:

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

input:

30 435
5 6
8 11
3 26
8 29
10 22
6 20
18 22
23 27
13 18
2 26
21 25
11 15
25 28
2 22
18 20
3 13
10 19
6 29
10 15
0 13
7 22
13 28
9 16
2 28
6 16
3 17
6 14
4 8
16 17
9 22
22 24
26 29
14 28
19 29
28 29
4 28
13 23
12 19
1 2
5 10
1 6
2 4
25 27
4 22
9 26
16 23
5 16
6 11
0 17
16 27
0 7
15 26
2 16
8 12
1 25
3...

output:

62
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 
1 2 2...

result:

points 1.0

Test #85:

score: 30
Accepted
time: 1ms
memory: 3652kb

input:

40 780
21 24
11 32
12 27
19 20
3 35
25 35
32 35
27 33
0 24
1 3
1 29
14 25
8 30
24 31
14 32
7 12
5 31
28 35
7 10
18 24
13 32
1 26
3 4
10 30
14 38
22 24
9 31
5 10
17 32
2 34
28 39
3 38
13 34
6 10
0 6
9 25
11 14
13 20
10 20
18 28
6 33
34 35
29 33
16 39
4 38
3 24
20 29
17 18
33 36
13 37
24 27
12 33
5 29...

output:

126
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12 11 12 13 14 13 14 15 16 15 16 17 18 17 18 ...

result:

points 1.0

Test #86:

score: 30
Accepted
time: 1ms
memory: 3716kb

input:

50 1225
6 10
14 36
0 34
7 23
22 31
18 34
2 19
13 21
0 46
0 11
2 43
2 11
13 20
13 19
7 39
35 37
9 17
31 38
13 40
7 28
2 41
20 46
25 36
12 39
1 37
21 42
33 48
10 24
13 26
26 37
0 47
17 19
1 28
28 40
15 40
11 22
10 19
24 28
12 28
19 40
6 12
13 48
20 37
11 46
8 19
5 24
16 28
15 47
31 34
11 21
28 33
14 1...

output:

126
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 
1 2 1 2 3 4 3 4 5 6 5 6 7 8 7 ...

result:

points 1.0

Test #87:

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

input:

100 4950
24 39
27 46
11 71
57 65
3 8
84 97
74 87
17 49
12 72
1 4
22 83
29 42
28 65
39 89
29 92
26 78
45 53
18 44
33 43
14 98
50 66
21 95
32 67
21 33
21 80
59 77
70 85
13 16
0 41
31 65
51 80
22 80
30 79
55 75
54 82
29 57
72 97
31 85
86 87
60 90
1 17
65 81
13 15
44 71
58 88
65 87
8 31
77 99
4 44
29 43...

output:

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

result:

points 1.0

Test #88:

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

input:

3 2
0 1
1 2

output:

13
1 1 2 
1 1 2 
1 1 2 
1 1 1 
1 1 2 
1 1 2 
1 1 2 
1 1 1 
2 1 1 
2 1 1 
1 1 2 
1 1 2 
2 1 1 

result:

points 1.0

Test #89:

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

input:

4 3
0 1
1 2
2 3

output:

18
1 1 2 3 
2 1 1 3 
2 1 1 1 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
2 1 1 3 
2 3 1 1 

result:

points 1.0

Test #90:

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

input:

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

output:

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

result:

points 1.0

Test #91:

score: 30
Accepted
time: 3ms
memory: 3788kb

input:

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

output:

493
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
2 1 1 3 ...

result:

points 1.0

Test #92:

score: 30
Accepted
time: 3ms
memory: 3840kb

input:

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

output:

498
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #93:

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

input:

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

output:

318
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 
2 1 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 ...

result:

points 1.0

Test #94:

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

input:

5 4
2 1
3 2
4 1
1 0

output:

22
1 1 2 3 4 
2 1 1 3 1 
2 1 1 1 3 
2 1 1 3 4 
2 1 1 3 1 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
1 1 2 3 4 
1 1 2 3 1 
1 1 2 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
2 1 1 3 4 
2 1 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
2 1 3 4 1 
2 1 3 4 1 
2 1 1 3 4 
2 3 1 1 4 

result:

points 1.0

Test #95:

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

input:

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

output:

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

result:

points 1.0

Test #96:

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

input:

11 10
2 0
8 6
1 0
5 3
9 7
7 5
4 3
6 5
10 9
3 1

output:

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

result:

points 1.0

Test #97:

score: 30
Accepted
time: 2ms
memory: 3924kb

input:

100 99
2 1
91 16
24 19
45 0
55 9
21 19
7 2
97 9
40 3
61 47
34 9
36 10
27 0
73 24
53 6
79 67
51 4
18 3
25 5
67 26
15 9
82 65
19 17
43 11
92 36
62 29
59 20
22 0
32 21
66 25
50 19
5 0
23 7
78 64
42 28
28 6
8 1
98 94
10 8
84 50
88 0
87 51
89 61
72 28
14 6
63 31
33 23
57 38
11 9
38 33
16 2
86 8
69 66
54 ...

output:

409
1 1 1 1 2 3 4 5 1 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 1 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 
1 2 1 1 1...

result:

points 1.0

Test #98:

score: 30
Accepted
time: 3ms
memory: 3896kb

input:

100 99
65 64
90 89
96 95
29 28
61 60
50 49
95 93
37 36
42 40
45 43
94 93
16 15
8 7
67 66
54 52
15 13
38 37
77 76
1 0
89 88
39 37
21 20
63 62
49 48
58 56
53 51
10 9
46 44
9 7
20 19
70 69
73 71
56 54
57 56
24 23
48 46
60 58
83 82
6 4
34 33
12 11
19 18
82 81
23 21
55 53
41 39
18 17
91 89
14 12
26 25
64...

output:

467
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 1...

result:

points 1.0

Test #99:

score: 30
Accepted
time: 3ms
memory: 3868kb

input:

100 99
11 8
17 16
98 95
89 86
53 51
88 86
63 62
15 12
83 82
73 72
97 96
5 4
6 5
51 49
16 13
81 78
94 93
25 22
70 68
23 21
44 41
74 73
2 1
28 27
37 36
30 27
35 32
77 76
50 49
22 19
82 79
85 83
45 44
95 94
24 23
10 9
21 20
72 69
78 75
43 40
39 38
19 17
42 41
52 50
34 32
62 61
65 62
79 76
90 89
69 66
4...

output:

451
1 1 1 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
1 2 1 1...

result:

points 1.0

Test #100:

score: 30
Accepted
time: 3ms
memory: 3780kb

input:

100 99
82 47
37 20
37 44
37 86
37 56
99 58
80 13
56 39
37 93
37 64
3 73
53 32
91 75
97 78
37 30
59 90
15 22
37 52
37 79
25 4
37 71
37 3
37 51
12 2
37 91
37 34
37 38
37 36
37 40
95 67
37 28
14 83
42 26
37 14
37 9
37 42
34 74
37 72
1 81
86 7
98 87
29 17
37 31
92 62
79 45
37 59
31 50
20 96
69 24
37 97
...

output:

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

result:

points 1.0

Test #101:

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

input:

100 99
61 80
7 74
86 22
54 45
71 97
33 37
71 49
71 59
0 79
14 5
88 86
6 92
48 18
52 15
20 81
62 61
63 52
78 1
85 93
24 48
96 0
50 88
82 53
68 36
16 34
95 21
81 58
87 90
60 26
28 68
90 73
21 19
71 43
83 84
71 63
76 6
71 24
1 39
67 55
44 3
65 31
64 78
19 83
32 65
35 47
89 38
37 25
94 41
43 62
5 46
71 ...

output:

416
1 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #102:

score: 30
Accepted
time: 3ms
memory: 3828kb

input:

100 99
8 3
47 1
50 49
4 1
89 88
84 83
68 67
34 19
40 35
77 76
12 6
52 51
71 70
66 65
97 96
33 1
53 52
83 82
51 50
79 78
43 7
91 90
92 91
62 61
49 28
31 9
96 95
42 0
82 81
36 34
5 2
58 57
15 5
72 71
29 25
54 53
93 92
95 94
59 58
76 75
65 64
55 54
74 73
2 1
18 11
27 0
14 10
13 10
69 68
39 0
85 84
81 8...

output:

458
1 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 30 31 32 33 34 35 36 37 38 39 40 41 42 1 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 
1 2 1 1 1 ...

result:

points 1.0

Test #103:

score: 30
Accepted
time: 3ms
memory: 4128kb

input:

100 99
79 78
39 33
3 1
23 19
2 0
31 23
26 18
33 24
86 85
25 20
83 82
1 0
60 59
14 10
29 25
17 8
7 5
68 67
34 28
58 57
84 83
48 46
90 89
54 53
12 3
50 49
9 1
64 63
24 18
95 94
41 34
99 98
97 96
4 2
87 86
10 9
56 55
51 50
5 1
11 8
65 64
98 97
52 51
16 14
37 31
80 79
67 66
8 4
42 32
93 92
73 72
15 6
82...

output:

463
1 1 2 1 3 1 1 4 5 1 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 
1 2 1 1 3...

result:

points 1.0

Test #104:

score: 30
Accepted
time: 3ms
memory: 3832kb

input:

100 99
99 98
74 73
40 38
38 37
80 79
48 46
29 26
3 1
37 34
17 15
62 61
30 27
81 80
8 6
45 42
76 75
88 87
32 30
31 29
75 74
34 33
83 82
16 14
14 11
73 72
96 95
12 11
95 94
68 67
67 66
26 25
2 1
19 18
49 47
20 17
85 84
57 56
28 26
63 62
64 63
10 8
71 70
13 10
69 68
53 52
35 32
33 31
55 54
46 43
54 53
...

output:

473
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #105:

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

input:

100 99
38 39
9 10
96 45
57 8
35 36
54 32
85 50
8 9
84 46
97 35
32 33
74 4
22 23
18 19
39 40
75 17
12 13
66 37
63 27
11 12
42 43
25 26
29 30
21 22
49 50
6 7
95 32
82 50
89 19
4 5
16 17
93 50
70 22
53 26
81 41
68 27
94 21
41 42
15 16
17 18
72 2
60 48
47 48
28 29
19 20
99 6
13 14
88 50
64 44
34 35
30 3...

output:

450
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #106:

score: 30
Accepted
time: 2ms
memory: 4004kb

input:

100 99
34 35
10 11
86 0
69 0
24 25
78 0
92 0
19 20
30 31
20 21
25 26
45 46
81 0
32 33
51 0
61 0
90 0
41 42
4 5
57 0
64 0
23 24
8 9
98 0
53 0
42 43
76 0
0 1
21 22
56 0
22 23
43 44
89 0
5 6
9 10
70 0
74 0
37 38
14 15
65 0
71 0
1 2
39 40
44 45
91 0
46 47
49 50
29 30
83 0
48 49
13 14
36 37
58 0
2 3
15 1...

output:

449
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #107:

score: 30
Accepted
time: 2ms
memory: 4056kb

input:

100 99
7 0
33 0
70 2
98 2
13 0
32 0
77 2
88 2
49 0
5 0
89 2
54 2
61 2
94 2
64 2
48 0
12 0
86 2
28 0
52 2
22 0
38 0
74 2
4 0
80 2
41 0
6 0
43 0
35 0
44 0
92 2
78 2
99 2
19 0
11 0
68 2
23 0
26 0
87 2
73 2
0 1
85 2
57 2
67 2
69 2
76 2
21 0
56 2
60 2
91 2
90 2
51 2
47 0
14 0
59 2
30 0
79 2
96 2
95 2
53 ...

output:

402
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 1 2 ...

result:

points 1.0

Test #108:

score: 30
Accepted
time: 2ms
memory: 4060kb

input:

100 99
73 30
96 30
72 30
31 0
46 0
82 30
6 7
65 30
79 30
97 30
88 30
91 30
44 0
85 30
60 0
33 0
27 28
57 0
83 30
1 2
43 0
24 25
16 17
38 0
49 0
15 16
48 0
10 11
55 0
17 18
81 30
76 30
54 0
39 0
26 27
68 30
95 30
78 30
71 30
84 30
42 0
20 21
86 30
70 30
47 0
56 0
21 22
63 0
36 0
14 15
34 0
7 8
53 0
7...

output:

430
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #109:

score: 30
Accepted
time: 3ms
memory: 4060kb

input:

100 99
14 15
87 48
58 40
72 30
79 33
98 45
80 24
60 4
82 0
25 26
42 43
85 4
23 24
48 49
47 48
16 17
92 1
95 38
11 12
70 34
10 11
28 29
78 9
8 9
59 37
76 14
68 45
31 32
86 10
45 46
66 14
6 7
61 38
0 1
19 20
73 25
89 2
32 33
90 19
71 35
21 22
37 38
24 25
93 17
39 40
84 49
2 3
7 8
83 42
67 12
18 19
1 2...

output:

451
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1 91 92 93 94 95 96 97 
1 2 1 1...

result:

points 1.0

Test #110:

score: 30
Accepted
time: 3ms
memory: 3908kb

input:

100 99
96 94
89 87
74 73
64 62
33 31
21 19
42 41
45 44
12 11
50 48
77 76
58 57
84 83
93 92
97 95
6 4
32 30
9 7
52 51
53 52
38 36
3 2
43 42
94 93
27 26
15 13
60 59
28 27
82 80
95 94
16 14
68 67
85 83
72 70
44 43
25 23
73 72
55 54
81 80
40 39
78 77
47 45
35 34
10 8
79 78
75 73
61 59
57 55
39 37
22 21
...

output:

470
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 1...

result:

points 1.0

Test #111:

score: 30
Accepted
time: 2ms
memory: 3828kb

input:

100 99
22 45
25 51
9 19
23 48
38 77
37 75
14 29
29 59
39 79
25 52
27 55
33 68
8 17
15 31
36 74
21 44
0 1
5 11
17 35
35 71
36 73
32 66
7 16
5 12
18 37
39 80
3 8
43 87
21 43
40 82
45 92
35 72
10 21
11 23
16 34
18 38
13 27
15 32
41 84
31 63
20 41
12 25
28 57
32 65
7 15
3 7
20 42
2 5
42 85
31 64
0 2
19 ...

output:

408
1 1 2 1 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 
1 2 1 1...

result:

points 1.0

Test #112:

score: 30
Accepted
time: 3ms
memory: 4124kb

input:

100 99
83 3
42 0
34 5
72 1
8 3
5 1
7 2
73 4
32 0
36 5
93 3
50 5
77 4
88 4
84 2
30 1
14 2
54 3
78 4
92 1
33 3
65 3
96 5
4 3
12 4
98 5
39 2
56 1
28 2
51 1
68 3
90 2
18 5
6 2
49 0
94 1
57 1
99 3
74 1
41 4
79 0
53 5
52 1
19 5
61 2
48 1
75 5
15 1
67 5
76 5
47 4
87 2
63 3
85 5
3 1
37 3
71 4
22 1
91 2
24 1...

output:

427
1 1 1 1 2 1 3 4 5 6 7 8 9 1 10 1 11 12 13 14 15 16 1 17 1 18 19 20 21 1 1 1 22 23 24 25 26 27 1 28 1 29 30 31 32 33 34 35 1 36 37 1 1 38 39 1 1 1 1 40 41 42 43 44 45 46 47 48 49 50 51 52 1 53 1 54 55 56 57 58 59 60 1 61 62 63 64 65 66 67 68 69 1 70 1 1 71 72 73 74 
1 2 1 1 1 1 1 1 1 1 1 1 3 1 1 ...

result:

points 1.0

Test #113:

score: 30
Accepted
time: 2ms
memory: 3828kb

input:

100 99
52 15
41 6
94 2
31 25
45 15
86 25
68 16
80 0
25 23
42 21
53 20
57 24
88 22
6 0
62 16
98 16
32 1
23 4
84 25
38 16
55 12
3 0
39 19
87 9
56 10
30 9
36 17
73 20
64 10
54 24
35 16
20 7
22 16
37 12
99 0
66 19
58 16
34 13
10 8
91 3
95 23
75 2
7 0
15 2
26 18
70 14
9 4
67 3
65 17
85 11
13 3
93 14
81 3...

output:

411
1 1 1 2 3 4 5 6 1 7 8 9 10 11 12 13 14 15 1 1 16 17 18 19 20 21 22 23 24 25 26 27 1 28 29 30 31 32 33 34 35 36 37 38 1 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 1 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 
1 2 1 1 1 3 ...

result:

points 1.0

Test #114:

score: 30
Accepted
time: 3ms
memory: 3936kb

input:

100 99
35 36
79 80
95 96
26 27
88 89
86 87
25 26
59 60
80 81
15 16
82 83
64 65
12 13
45 46
96 97
14 15
2 3
39 40
41 42
91 92
3 4
71 72
20 21
4 5
28 29
87 88
32 33
38 39
67 68
11 12
84 85
74 75
81 82
65 66
53 54
70 71
57 58
66 67
98 17
18 19
13 14
43 44
75 76
55 56
19 20
22 23
6 7
37 38
94 95
63 64
6...

output:

496
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #115:

score: 30
Accepted
time: 3ms
memory: 3784kb

input:

100 99
51 52
31 32
52 53
72 64
9 10
4 5
6 7
14 15
48 49
3 4
19 20
2 3
80 44
38 39
62 58
1 2
58 59
22 23
90 22
61 46
8 9
17 18
42 43
25 26
96 29
39 40
43 44
67 19
75 65
91 4
74 7
78 6
69 67
70 5
86 50
98 49
36 37
71 69
79 6
81 8
56 57
89 68
28 29
0 1
47 48
10 11
11 12
50 51
46 47
23 24
15 16
24 25
73...

output:

458
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #116:

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

input:

4 3
2 1
3 2
1 0

output:

18
1 1 2 3 
2 1 1 3 
2 1 1 1 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 3 
1 1 1 2 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 1 2 3 
2 1 1 3 
2 3 1 1 

result:

points 1.0

Test #117:

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

input:

4 3
3 0
1 0
2 1

output:

18
1 1 1 2 
1 1 2 3 
1 1 2 3 
1 1 2 1 
1 1 2 3 
1 1 1 2 
1 1 2 3 
1 1 2 1 
1 2 3 1 
2 1 1 3 
1 1 2 1 
1 2 3 1 
1 2 3 1 
1 1 2 3 
2 1 1 3 
2 1 1 3 
1 1 2 3 
1 2 3 1 

result:

points 1.0

Test #118:

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

input:

5 4
4 3
1 0
2 0
3 1

output:

22
1 1 2 1 3 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
1 1 2 3 4 
2 1 3 1 1 
2 1 3 1 4 
1 1 2 1 3 
1 1 2 3 4 
1 1 1 2 3 
1 2 1 3 4 
2 1 3 1 4 
1 1 1 2 3 
1 2 1 3 4 
1 2 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 2 1 3 4 
1 2 1 3 4 
1 1 2 3 4 
2 1 3 1 4 
2 3 4 1 1 

result:

points 1.0

Test #119:

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

input:

5 4
1 0
3 2
2 1
4 3

output:

23
1 1 2 3 4 
2 1 1 3 4 
2 3 1 1 4 
2 3 1 1 1 
2 3 1 1 4 
2 3 1 1 4 
2 1 1 1 3 
2 1 1 3 4 
2 1 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
1 1 2 3 4 
1 1 2 3 4 
1 1 2 3 4 
1 1 1 2 3 
2 1 1 3 4 
2 1 1 3 4 
1 1 2 3 4 
1 1 2 3 4 
2 1 1 3 4 
2 3 1 1 4 
2 3 4 1 1 

result:

points 1.0

Test #120:

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

input:

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

output:

26
1 1 1 2 3 4 
1 1 2 3 4 5 
1 1 2 3 4 5 
2 1 1 1 3 4 
2 1 1 3 4 5 
1 1 2 3 1 4 
1 1 2 3 4 5 
2 1 1 3 4 1 
2 1 1 3 4 5 
1 1 1 2 3 4 
1 1 2 3 4 5 
1 1 2 3 1 4 
1 2 3 4 1 5 
2 1 1 3 4 5 
1 1 2 3 1 4 
1 2 3 4 1 5 
1 2 3 4 1 5 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 2 3 4 1 5 
1 2 3 4 1 5 
1 1 2 3 4 5 
2 1 1 3 4 5...

result:

points 1.0

Test #121:

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

input:

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

output:

26
1 1 2 3 4 5 
1 2 1 1 3 1 
1 2 3 1 1 4 
1 2 3 1 4 5 
1 2 1 1 3 1 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 1 1 2 3 4 
1 1 2 3 4 5 
1 1 2 1 3 4 
1 1 2 3 4 5 
1 1 2 3 4 1 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 1 1 2 3 4 
1 2 1 3 4 5 
1 2 1 3 4 5 
1 1 2 3 4 5 
1 1 2 3 4 5 
1 2 1 3 4 5 
1 2 1 3 4 5 
1 2 3 4 5 1...

result:

points 1.0

Test #122:

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

input:

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

output:

32
1 1 1 2 1 3 4 
1 2 1 1 1 1 3 
2 3 1 1 4 5 1 
2 3 1 1 4 5 6 
1 2 1 1 1 1 3 
2 1 1 3 4 5 6 
2 1 1 3 4 5 6 
2 1 1 1 3 4 5 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 1 2 1 3 4 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 6 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 6 
2 1 3 4 1 5 6 
1 1 2 3 4 1 ...

result:

points 1.0

Test #123:

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

input:

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

output:

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

result:

points 1.0

Test #124:

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

input:

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

output:

31
1 1 2 1 3 4 5 
1 2 1 1 1 3 1 
2 3 4 1 1 1 5 
2 3 4 1 1 5 6 
1 2 1 1 1 3 1 
2 1 3 1 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
2 1 3 1 1 4 5 
2 1 3 1 4 5 6 
1 1 2 3 4 5 1 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #125:

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

input:

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

output:

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

result:

points 1.0

Test #126:

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

input:

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

output:

31
1 1 1 2 3 4 5 
1 2 1 1 3 1 4 
2 3 1 1 1 4 5 
2 3 1 1 4 5 6 
2 3 1 1 4 5 1 
2 3 1 1 4 5 6 
1 2 1 1 3 1 4 
2 1 1 3 4 5 6 
2 1 1 3 4 5 6 
2 1 1 1 3 4 5 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 6 
2 1 1 3 4 5 6 
1 1 2 3 4 1 5 
1 2 3 4 5 1 ...

result:

points 1.0

Test #127:

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

input:

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

output:

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

result:

points 1.0

Test #128:

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

input:

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

output:

31
1 1 2 1 3 4 5 
1 2 1 1 1 1 3 
1 2 3 4 1 5 1 
1 2 3 4 1 5 6 
1 2 1 1 1 1 3 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #129:

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

input:

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

output:

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

result:

points 1.0

Test #130:

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

input:

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

output:

31
1 1 2 3 4 1 5 
1 2 1 1 1 1 3 
1 2 1 3 4 5 1 
1 2 1 3 4 5 6 
1 2 1 1 1 1 3 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 1 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 4 5 1 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #131:

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

input:

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

output:

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

result:

points 1.0

Test #132:

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

input:

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

output:

32
1 1 2 1 3 1 1 
2 1 3 1 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 1 3 1 1 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 4 5 1 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 4 5 6 1 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #133:

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

input:

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

output:

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

result:

points 1.0

Test #134:

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

input:

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

output:

31
1 1 2 1 3 4 5 
1 2 1 1 1 3 1 
1 2 3 4 1 1 5 
1 2 3 4 1 5 6 
1 2 1 1 1 3 1 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 1 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 5 1 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 6 
2 1 3 1 4 5 6 
1 1 1 2 3 4 5 
1 2 1 3 4 5 ...

result:

points 1.0

Test #135:

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

input:

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

output:

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

result:

points 1.0

Test #136:

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

input:

10 20
4 5
6 0
1 0
6 8
0 3
5 9
8 1
7 2
0 4
1 3
3 2
2 1
4 7
9 6
6 7
4 1
8 9
3 4
7 9
5 0

output:

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

result:

points 1.0

Test #137:

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

input:

10 20
8 7
9 6
6 7
7 4
6 8
1 0
3 1
5 4
0 2
3 4
3 6
1 4
0 3
8 9
2 3
6 4
2 1
5 7
7 9
4 2

output:

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

result:

points 1.0

Test #138:

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

input:

11 33
1 0
1 4
6 4
3 7
7 4
4 9
3 8
3 9
2 9
3 6
4 0
9 1
0 10
3 5
4 8
1 6
1 2
5 9
8 0
2 0
6 8
5 2
9 10
3 10
7 9
3 4
8 9
1 10
5 6
3 1
0 9
0 7
10 6

output:

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

result:

points 1.0

Test #139:

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

input:

11 14
2 0
9 5
1 3
5 2
1 0
7 3
6 2
8 9
2 7
3 0
10 3
4 2
8 10
8 4

output:

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

result:

points 1.0

Test #140:

score: 30
Accepted
time: 3ms
memory: 3836kb

input:

100 122
47 45
60 55
58 57
51 48
3 1
99 96
14 9
79 74
15 13
18 15
4 3
19 15
9 11
25 24
30 29
72 68
2 0
97 96
37 36
77 76
5 10
80 75
7 3
44 41
13 11
85 84
90 88
10 8
20 21
98 99
14 17
46 41
52 50
81 80
75 73
31 27
88 84
26 24
89 91
91 90
84 83
22 20
8 3
78 73
36 40
59 58
74 69
32 29
61 57
11 6
1 0
89 ...

output:

448
1 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #141:

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

input:

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

output:

34
1 1 2 3 4 5 6 
2 1 1 3 4 5 6 
2 3 1 1 4 5 6 
2 3 4 1 1 5 6 
2 3 4 5 1 1 6 
2 3 4 5 1 1 6 
2 3 4 1 1 5 1 
2 3 4 1 1 5 6 
2 3 4 1 1 5 6 
2 3 1 1 4 1 5 
2 3 1 1 4 5 6 
2 3 1 1 4 5 6 
2 1 1 3 1 4 5 
2 1 1 3 4 5 6 
2 1 1 3 4 5 6 
1 1 2 3 4 5 6 
1 1 2 3 4 5 6 
1 1 2 1 3 4 5 
1 1 2 3 4 5 6 
1 1 2 3 4 5 ...

result:

points 1.0

Test #142:

score: 30
Accepted
time: 7ms
memory: 3852kb

input:

100 4949
8 0
56 54
84 36
67 55
53 25
43 8
52 4
73 12
24 19
93 91
71 24
73 6
90 9
78 36
78 34
94 70
93 25
64 37
69 8
67 61
78 47
16 15
79 44
68 52
83 38
97 19
72 9
78 10
51 13
47 40
50 47
75 12
80 40
65 35
86 58
82 39
93 51
91 17
52 34
14 12
56 49
80 19
34 22
37 28
89 36
41 9
94 85
95 3
46 11
49 34
4...

output:

595
2 3 4 5 6 7 8 9 10 1 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1 91 92 93 94 95 96 97 98 99 
2 3 4...

result:

points 1.0

Test #143:

score: 30
Accepted
time: 7ms
memory: 3932kb

input:

100 4948
80 52
76 10
90 1
36 32
72 10
81 71
99 24
83 77
83 82
52 24
53 31
63 48
72 16
37 16
36 12
88 37
87 5
96 68
69 25
41 22
98 32
56 4
51 34
48 35
90 21
64 37
20 2
88 75
64 5
54 15
79 5
98 77
65 17
20 3
41 21
86 49
42 5
1 0
90 42
66 29
76 66
98 35
46 3
95 90
79 15
62 23
49 44
66 3
35 3
68 21
89 2...

output:

595
2 3 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 3 4...

result:

points 1.0

Test #144:

score: 30
Accepted
time: 7ms
memory: 3960kb

input:

100 4910
79 73
93 26
13 4
81 13
71 20
46 39
55 33
63 62
83 63
70 37
96 58
94 25
99 97
29 9
34 28
78 62
45 44
99 19
30 17
67 65
89 49
83 59
82 76
68 22
98 29
79 54
96 6
72 23
15 2
69 6
98 43
67 49
98 7
92 32
49 24
43 20
95 31
80 66
92 91
86 55
89 71
43 30
75 9
90 31
61 4
96 31
50 23
83 31
80 11
99 49...

output:

595
2 3 4 5 6 7 1 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1 97 98 99 
2 3 4...

result:

points 1.0

Test #145:

score: 30
Accepted
time: 2ms
memory: 3928kb

input:

100 4015
38 71
28 30
44 10
92 55
48 82
20 3
40 37
78 10
61 84
25 26
79 77
98 45
41 0
92 42
43 45
69 82
59 66
41 67
43 5
22 34
82 86
34 86
77 59
17 97
92 36
45 9
55 89
40 39
34 87
57 46
13 44
75 10
53 58
72 36
76 95
81 71
56 82
88 94
11 38
4 34
13 16
88 90
47 82
48 44
48 95
72 11
13 98
13 43
58 0
95 ...

output:

496
2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 1 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1 96 97 98 
2 1 3 ...

result:

points 1.0

Test #146:

score: 30
Accepted
time: 4ms
memory: 3892kb

input:

100 1810
18 79
44 32
83 82
94 36
47 17
72 24
61 99
55 35
14 99
48 51
88 76
45 43
12 87
51 79
21 9
40 48
88 16
37 27
74 6
86 59
0 33
47 67
24 67
28 69
72 83
31 83
21 16
56 79
14 45
60 43
72 14
69 67
72 12
86 28
12 56
40 18
25 59
15 84
48 59
24 69
33 34
23 32
47 94
54 60
8 2
54 51
72 90
76 39
49 79
86...

output:

480
2 3 4 1 5 6 7 8 9 10 11 12 13 14 15 1 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 1 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
2 3 4 ...

result:

points 1.0

Test #147:

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

input:

100 270
67 31
67 93
94 28
79 91
93 1
67 43
93 28
84 25
16 95
23 11
23 15
5 68
21 94
31 28
82 0
41 28
31 2
67 2
19 92
46 37
30 53
30 11
11 2
15 2
43 2
67 86
94 1
1 2
62 63
67 15
28 2
24 81
69 2
69 43
85 30
70 44
43 94
85 21
1 86
69 30
43 86
41 86
43 39
90 10
43 15
6 33
31 86
85 11
43 93
86 2
18 49
43...

output:

497
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1 92 93 94 95 96 97 98 
1 2 3 ...

result:

points 1.0

Test #148:

score: 30
Accepted
time: 3ms
memory: 3844kb

input:

100 4852
1 0
2 0
2 1
3 0
3 1
3 2
4 0
4 1
4 2
4 3
5 0
5 1
5 2
5 3
5 4
6 0
6 1
6 2
6 3
6 4
6 5
7 0
7 1
7 2
7 3
7 4
7 5
7 6
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 0
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 0
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 0
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
12 0
...

output:

594
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 1...

result:

points 1.0

Test #149:

score: 30
Accepted
time: 5ms
memory: 3880kb

input:

100 3180
1 0
2 0
2 1
3 0
3 1
3 2
4 0
4 1
4 2
4 3
5 0
5 1
5 2
5 3
5 4
6 0
6 1
6 2
6 3
6 4
6 5
7 0
7 1
7 2
7 3
7 4
7 5
7 6
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 0
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 0
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9
11 0
11 1
11 2
11 3
11 4
11 5
11 6
11 7
11 8
11 9
11 10
12 0
...

output:

556
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 1...

result:

points 1.0

Test #150:

score: 30
Accepted
time: 4ms
memory: 3872kb

input:

100 2403
16 39
12 25
90 94
11 29
70 75
29 33
54 58
92 94
59 81
51 72
22 31
58 87
56 78
58 93
54 86
62 82
31 41
78 79
60 99
64 98
11 49
76 83
7 23
5 22
66 94
61 73
61 83
80 89
9 35
65 96
59 99
59 71
60 73
11 14
80 2
79 85
14 27
79 92
53 63
74 93
10 43
19 27
33 49
6 46
73 96
87 94
66 69
11 48
78 85
76...

output:

450
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #151:

score: 30
Accepted
time: 3ms
memory: 3864kb

input:

100 1255
70 85
73 80
39 55
74 96
36 62
47 57
73 99
5 6
38 61
49 61
35 58
58 64
36 38
57 64
41 56
35 41
44 0
78 95
71 78
32 64
54 56
35 49
53 60
65 67
55 58
45 48
33 34
77 91
80 95
85 89
73 82
46 49
82 90
59 64
34 58
52 63
78 85
79 99
71 83
81 93
93 96
80 85
66 78
74 89
80 81
67 74
66 82
47 59
35 50
...

output:

464
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #152:

score: 30
Accepted
time: 3ms
memory: 3872kb

input:

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

output:

482
1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 
1 2 1 ...

result:

points 1.0

Test #153:

score: 30
Accepted
time: 3ms
memory: 4128kb

input:

100 100
70 71
64 65
12 13
72 73
55 56
74 75
86 87
16 17
69 70
53 54
57 58
71 72
41 42
48 49
2 3
23 24
77 78
87 88
28 29
31 32
84 85
27 28
52 53
9 10
62 63
65 66
94 95
7 8
91 92
17 18
19 20
44 45
6 7
15 16
59 60
40 41
25 26
4 5
43 44
29 30
80 81
56 57
92 93
93 94
18 19
39 40
45 46
75 76
22 23
58 59
1...

output:

499
2 1 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 3 1...

result:

points 1.0

Test #154:

score: 30
Accepted
time: 5ms
memory: 3976kb

input:

100 2500
9 69
46 86
0 99
25 56
11 95
17 90
15 71
40 51
2 92
15 90
22 98
17 71
23 68
43 68
19 52
2 82
42 66
41 64
38 89
37 70
10 91
49 55
28 86
16 51
2 97
30 51
29 68
24 67
1 60
28 79
46 65
13 87
43 69
21 84
16 86
34 77
36 65
24 74
42 67
8 70
24 82
13 51
49 56
37 74
15 78
1 83
15 56
13 98
16 97
27 73...

output:

547
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 3 4...

result:

points 1.0

Test #155:

score: 30
Accepted
time: 2ms
memory: 3832kb

input:

100 152
6 7
9 0
26 0
36 37
86 0
93 94
51 0
34 0
3 0
12 0
11 0
56 57
57 0
4 5
99 0
39 40
17 0
47 0
43 0
37 0
49 50
88 0
83 0
33 0
60 61
84 0
12 13
21 0
97 0
90 91
21 22
53 54
91 0
96 97
75 76
45 0
25 26
97 98
62 0
68 0
67 0
94 95
89 0
34 35
31 0
13 0
79 0
46 0
1 0
73 0
16 0
14 0
16 17
27 28
73 74
92 ...

output:

405
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 3...

result:

points 1.0

Test #156:

score: 30
Accepted
time: 3ms
memory: 3808kb

input:

100 198
81 99
42 43
68 99
10 11
18 99
73 99
13 99
91 99
56 57
2 99
95 96
79 80
83 99
30 99
73 74
25 99
62 99
61 62
68 69
19 20
52 53
8 9
83 84
86 99
24 99
33 99
50 51
97 98
93 94
44 45
72 99
31 32
84 85
79 99
98 0
93 99
82 83
35 36
57 58
65 99
14 99
12 99
49 99
42 99
35 99
9 10
60 99
18 19
0 1
43 44...

output:

489
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 2 3...

result:

points 1.0

Test #157:

score: 30
Accepted
time: 3ms
memory: 4128kb

input:

100 101
46 63
46 56
46 65
46 53
46 88
46 60
46 13
46 94
46 54
46 29
46 3
46 21
46 82
46 45
46 12
46 23
46 35
46 31
46 84
46 16
46 98
46 96
46 17
46 18
82 5
46 91
46 95
46 73
46 80
46 14
46 19
46 40
46 39
46 27
46 2
46 97
12 65
46 22
46 25
46 20
46 69
46 1
46 75
46 51
46 67
46 89
46 11
46 30
46 66
46...

output:

402
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 1 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #158:

score: 30
Accepted
time: 3ms
memory: 3788kb

input:

100 109
49 48
57 18
12 15
17 16
91 89
50 49
67 65
78 76
42 40
66 64
36 35
61 59
45 44
95 94
54 53
73 71
13 11
64 63
32 30
81 79
35 33
83 82
58 56
55 53
2 1
14 12
56 55
27 30
94 92
28 27
24 23
31 29
8 6
63 61
22 21
46 45
96 94
79 77
34 33
27 26
38 36
11 9
43 41
59 57
26 25
39 38
29 27
70 69
9 7
40 38...

output:

453
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 1 1...

result:

points 1.0

Test #159:

score: 30
Accepted
time: 3ms
memory: 3852kb

input:

100 1203
68 52
12 6
54 51
9 2
96 75
40 28
99 80
98 96
62 56
92 86
22 16
40 25
88 82
63 61
15 7
17 4
60 54
10 5
43 32
56 52
99 92
73 71
65 55
97 78
48 27
11 10
24 5
35 32
23 21
47 37
81 79
21 11
64 50
28 25
12 1
71 54
68 65
49 33
20 11
48 39
56 50
16 1
57 52
39 33
37 29
33 28
72 67
77 76
74 58
94 92
...

output:

466
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 3 4...

result:

points 1.0

Test #160:

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

input:

100 459
4 0
52 50
58 54
66 60
75 74
7 5
87 83
63 62
31 30
9 0
49 46
42 41
34 31
35 30
59 56
18 12
64 62
49 40
16 10
36 33
93 92
19 17
46 42
88 80
76 73
69 65
54 52
15 10
43 42
69 66
88 81
18 16
39 38
87 86
99 94
98 94
53 51
15 13
4 2
99 96
19 15
38 34
9 3
37 30
38 32
96 94
99 95
46 41
66 62
94 93
27...

output:

426
1 2 3 4 1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2 3 1...

result:

points 1.0

Test #161:

score: 30
Accepted
time: 2ms
memory: 3776kb

input:

100 174
7 4
38 37
2 14
29 28
70 69
85 84
98 97
33 32
94 93
65 64
0 56
91 88
10 8
46 45
73 72
15 14
2 60
51 49
41 40
95 92
0 9
47 46
49 48
6 5
77 76
46 44
99 98
71 69
1 0
23 22
82 81
30 29
86 85
1 36
95 93
93 92
79 78
43 41
99 96
79 77
87 86
50 48
53 52
19 18
90 89
2 16
59 57
0 35
90 88
31 30
74 72
8...

output:

413
1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 1 36 37 38 39 40 41 42 43 44 45 46 47 48 49 1 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1 1 81 82 83 84 85 86 1 87 88 89 90 91 92 93 94 
1 2 1 3 4 ...

result:

points 1.0

Test #162:

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

input:

3 3
2 1
0 2
1 0

output:

6
1 1 2 
1 1 2 
1 2 1 
1 2 1 
1 2 2 
1 2 2 

result:

points 1.0

Test #163:

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

input:

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

output:

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

result:

points 1.0

Test #164:

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

input:

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

output:

6
1 1 2 2 
1 1 2 2 
1 2 1 2 
1 2 1 2 
1 2 2 1 
1 2 2 1 

result:

points 1.0

Test #165:

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

input:

3 3
2 0
2 1
1 0

output:

6
1 1 2 
1 1 2 
1 2 1 
1 2 1 
1 2 2 
1 2 2 

result:

points 1.0

Extra Test:

score: 0
Extra Test Passed