QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589630#5305. Oscar is All You Needlouhao088AC ✓6ms4004kbC++232.1kb2024-09-25 19:11:582024-09-25 19:11:58

Judging History

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

  • [2024-09-25 19:11:58]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:4004kb
  • [2024-09-25 19:11:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 1050;
int n, p[N], tmp[N], id[N];
vector <pair<int, int> > s;
int flag;

void work(int x, int y) {
    s.push_back(make_pair(x, y));
    tmp[0] = 0;
    for (int i = n - y + 1; i <= n; i++) tmp[++tmp[0]] = p[i];
    for (int i = x + 1; i <= n - y; i++) tmp[++tmp[0]] = p[i];
    for (int i = 1; i <= x; i++) tmp[++tmp[0]] = p[i];
    for (int i = 1; i <= n; i++) p[i] = tmp[i], id[p[i]] = i;
    // printf("%d %d\n", x, y);
    // for (int i = 1; i <= n; i++) printf("%d ", p[i]); printf("\n");
}

void write() {
    int mor = 0;
    if (n != 3 && p[n] != n) mor = 1;
    printf("%d\n", s.size() + mor);
    for (int i = 0; i < s.size(); i++) {
        printf("%d %d\n", s[i].first, s[i].second);
        if (mor && i == flag) printf("1 1\n");
    }
}

void slove() {
    s.clear();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]), id[p[i]] = i;

    if (n == 3) {
        if (p[1] > p[3]) work(1, 1);
        write(); return ;
    }

    flag = 0;
    if (id[n] == id[n - 1] + 1 || id[n - 1] == id[n] + 1) {
        int l = min(id[n], id[n - 1]), r = max(id[n], id[n - 1]);
        if (r != n) work(l, 1);
            else work(1, 1);
        flag = 1;
    }
    work(min(id[n], id[n - 1]), n - max(id[n], id[n - 1]) + 1);

    if (p[1] != 1) {
        if (id[1] == n) work(1, 1);
            else {
                if (id[1] == 2) work(id[1] - 1, n - id[1]);
                work(id[1] - 2, n - id[1] + 1);
            }
    }
    for (int i = 2; i <= n - 2; i++) {
        if (p[i] == i) continue;
        if (id[i] == n) {
            work(i - 1, 2);
            work(1, i - 1);
        }
        else {
            work(i - 1, 1);
            work(id[i] - 1, i - 1);
        }
    }

    // for (int i = 1; i <= n - 2; i++)
        // assert(p[i] == i);
    //  for (int i = 1; i <= n; i++) printf("%d ", p[i]);
    //  printf("\n");

    write();
}

int main() {
    int t; scanf("%d", &t);
    while (t--) slove();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3920kb

input:

2
3
1 3 2
5
4 1 2 3 5

output:

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

result:

ok OK in maximum 6 operations

Test #2:

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

input:

120
3
1 3 2
3
3 2 1
3
2 3 1
5
1 2 3 4 5
12
11 9 2 8 3 10 6 1 4 7 5 12
36
24 9 7 3 31 15 13 1 4 33 11 29 16 23 2 25 35 21 32 14 6 18 17 26 28 8 27 22 20 36 10 19 34 12 30 5
4
4 2 3 1
5
3 5 2 1 4
4
1 2 4 3
10
5 7 4 9 6 8 1 3 10 2
5
3 1 5 2 4
5
3 5 1 2 4
3
3 1 2
13
3 1 2 11 12 13 8 6 5 4 10 9 7
16
12 8...

output:

0
1
1 1
1
1 1
6
1 1
1 2
1 3
2 2
1 1
3 1
18
1 1
6 5
1 1
8 1
2 1
2 2
3 1
2 3
4 1
2 4
5 1
2 5
6 1
5 6
7 1
4 7
8 2
1 8
66
17 7
25 10
1 1
7 1
2 1
26 2
3 1
3 3
4 1
15 4
5 1
4 5
6 1
11 6
7 1
24 7
8 1
5 8
9 1
12 9
10 1
19 10
11 1
10 11
12 1
21 12
13 1
7 13
14 1
10 14
15 1
3 15
16 1
11 16
17 2
1 17
18 1
14 1...

result:

ok OK in maximum 1 operations

Test #3:

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

input:

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

output:

8
6 1
1 6
1 1
3 1
2 1
3 2
3 1
2 3
25
4 4
1 1
2 12
1 1
6 1
2 1
2 2
3 1
9 3
4 1
2 4
5 1
8 5
6 1
7 6
7 1
6 7
8 1
5 8
9 1
2 9
10 2
1 10
11 2
1 11
1
1 1
11
2 1
1 1
3 4
1 1
4 1
2 1
2 2
4 1
2 4
5 2
1 5
6
2 1
2 1
1 1
1 2
1 1
2 1
10
3 3
3 4
2 2
1 2
3 1
3 3
4 1
3 4
5 2
1 5
6
2 1
1 3
1 1
3 1
2 1
2 2
5
2 1
2 1
...

result:

ok OK in maximum 0 operations

Test #4:

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

input:

6
3
1 3 2
3
3 1 2
3
1 2 3
3
2 3 1
3
2 1 3
3
3 2 1

output:

0
1
1 1
0
1
1 1
0
1
1 1

result:

ok OK in maximum 1 operations

Test #5:

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

input:

24
4
1 2 4 3
4
3 2 4 1
4
4 1 3 2
4
3 1 2 4
4
2 3 4 1
4
3 2 1 4
4
2 4 1 3
4
3 4 1 2
4
4 2 1 3
4
2 1 4 3
4
4 3 2 1
4
2 3 1 4
4
1 2 3 4
4
1 3 2 4
4
3 1 4 2
4
4 1 2 3
4
4 3 1 2
4
1 4 3 2
4
3 4 2 1
4
1 4 2 3
4
4 2 3 1
4
1 3 4 2
4
2 1 3 4
4
2 4 3 1

output:

7
1 1
1 2
1 1
1 2
1 2
1 2
1 1
6
1 2
1 1
1 2
1 2
1 2
1 1
4
1 2
1 2
1 1
2 1
6
1 1
1 1
1 2
1 2
1 2
1 1
5
2 1
2 1
1 2
1 1
2 1
5
1 1
1 1
1 2
1 1
2 1
5
2 1
1 2
1 2
1 2
1 1
6
1 1
2 1
1 2
1 2
1 2
1 1
4
1 1
1 2
1 1
2 1
6
1 1
1 2
1 1
1 2
1 1
2 1
6
1 1
2 1
1 1
1 2
1 1
2 1
6
2 1
1 1
1 2
1 2
1 2
1 1
6
1 1
1 2
1 ...

result:

ok OK in maximum 6 operations

Test #6:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

120
5
5 2 4 3 1
5
2 4 5 1 3
5
3 2 5 4 1
5
5 1 3 2 4
5
4 5 2 3 1
5
2 4 3 1 5
5
3 1 5 2 4
5
1 4 2 5 3
5
2 5 1 4 3
5
4 1 2 5 3
5
3 1 2 4 5
5
1 3 5 2 4
5
5 4 2 3 1
5
2 3 5 1 4
5
5 4 3 2 1
5
2 1 4 3 5
5
3 5 2 4 1
5
1 5 4 2 3
5
3 1 4 5 2
5
4 2 3 1 5
5
3 4 1 2 5
5
4 5 1 2 3
5
2 4 5 3 1
5
4 5 1 3 2
5
2 3 1 ...

output:

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

result:

ok OK in maximum 4 operations

Test #7:

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

input:

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

output:

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

result:

ok OK in maximum 7 operations

Test #8:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

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

output:

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

result:

ok OK in maximum 6 operations

Test #9:

score: 0
Accepted
time: 1ms
memory: 3976kb

input:

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

output:

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

result:

ok OK in maximum 13 operations

Test #10:

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

input:

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

output:

5
1 2
1 1
1 3
2 1
2 2
8
5 1
2 1
1 1
2 4
2 2
1 2
4 1
2 4
9
4 1
2 1
2 3
1 1
3 1
2 1
3 2
3 2
1 3
4
2 3
1 4
3 1
2 3
0
8
1 1
2 1
1 3
2 2
1 2
1 1
2 2
1 2
1
1 1
11
4 2
1 1
4 2
1 1
5 1
2 2
1 2
3 1
3 3
4 1
2 4
10
1 1
2 1
1 1
2 3
1 2
1 1
2 1
3 2
3 1
2 3
5
1 1
1 2
1 3
2 1
2 2
9
4 2
1 1
2 4
1 1
2 1
2 1
4 2
4 1
...

result:

ok OK in maximum 8 operations

Test #11:

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

input:

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

output:

11
5 1
2 1
5 2
1 1
5 1
3 1
3 3
4 1
3 4
5 2
1 5
13
4 1
2 1
1 1
1 5
4 2
1 1
3 1
2 1
3 2
3 2
1 3
4 2
1 4
1
1 1
9
2 1
1 1
2 3
1 1
3 1
2 1
3 2
3 2
1 3
6
2 1
2 1
1 1
1 2
1 1
2 1
12
2 2
1 1
1 7
6 2
1 1
4 1
3 2
1 3
4 1
3 4
5 1
3 5
7
1 4
1 1
3 2
1 1
4 1
3 1
2 3
15
1 3
1 1
2 7
2 1
3 2
3 1
3 3
4 1
4 4
5 1
4 5
...

result:

ok OK in maximum 12 operations

Test #12:

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

input:

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

output:

5
3 1
1 3
2 2
1 1
3 1
8
2 3
3 5
4 2
1 4
5 2
1 5
6 1
2 6
11
2 2
1 1
3 4
1 2
1 1
2 1
4 2
3 1
4 3
4 1
3 4
10
2 3
1 1
1 4
3 2
1 2
1 1
2 2
1 2
3 2
1 3
5
1 1
1 2
1 2
1 2
1 1
0
0
13
1 1
1 1
6 2
1 1
5 1
2 1
2 2
4 1
2 4
5 1
3 5
6 2
1 6
0
10
4 2
4 3
2 1
2 2
3 1
4 3
4 2
1 4
5 2
1 5
8
2 4
3 3
2 2
1 2
3 2
1 3
4 ...

result:

ok OK in maximum 1 operations

Test #13:

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

input:

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

output:

7
3 4
1 6
5 2
1 1
5 1
4 1
3 4
13
5 2
1 1
4 4
1 1
4 1
2 1
3 2
3 1
2 3
4 2
1 4
5 2
1 5
0
0
16
4 1
7 2
1 1
5 1
2 1
4 2
3 2
1 3
4 1
4 4
5 1
4 5
6 1
3 6
7 2
1 7
11
5 2
1 1
2 5
1 1
3 1
2 2
1 2
3 1
2 3
4 1
2 4
6
1 1
1 2
1 2
1 2
1 2
1 1
5
1 3
1 3
2 2
1 1
3 1
1
1 1
10
2 2
4 2
1 1
4 1
2 1
4 2
3 1
3 3
4 2
1 4
...

result:

ok OK in maximum 0 operations

Test #14:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

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

output:

4
1 2
1 2
1 1
2 1
11
2 1
1 1
4 3
1 1
6 1
2 1
2 2
3 1
2 3
4 1
2 4
16
4 4
1 1
1 7
6 2
1 1
5 1
2 1
3 2
3 2
1 3
4 1
3 4
5 1
2 5
6 2
1 6
11
6 1
2 1
5 2
1 2
1 1
2 2
1 2
3 1
4 3
5 1
2 5
14
7 1
3 6
1 1
6 1
2 1
4 2
3 1
6 3
4 1
4 4
5 2
1 5
6 1
3 6
6
1 1
1 1
1 3
2 2
1 1
3 1
5
1 1
1 2
1 2
1 1
2 1
10
2 1
2 1
1 1...

result:

ok OK in maximum 0 operations

Test #15:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

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

output:

23
3 3
1 1
2 12
1 1
3 1
2 1
7 2
3 1
10 3
4 1
10 4
5 1
9 5
6 1
8 6
7 1
3 7
8 2
1 8
11 2
1 11
12 1
2 12
24
12 4
10 7
1 1
16 1
2 2
1 2
3 2
1 3
4 1
13 4
5 1
6 5
6 1
5 6
7 1
4 7
8 1
8 8
9 1
2 9
12 1
4 12
13 1
2 13
20
7 4
7 6
1 1
9 1
2 2
1 2
3 1
10 3
4 1
9 4
5 1
7 5
6 1
7 6
7 1
6 7
8 1
2 8
11 2
1 11
16
8 ...

result:

ok OK in maximum 7 operations

Test #16:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

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

output:

24
14 1
6 10
1 1
13 1
2 1
7 2
3 1
6 3
4 1
7 4
5 1
4 5
6 1
9 6
7 2
1 7
10 2
1 10
11 1
4 11
12 1
2 12
13 2
1 13
24
3 3
1 1
1 14
13 2
1 1
4 1
2 1
3 2
3 1
4 3
4 1
3 4
5 1
6 5
6 1
2 6
9 1
2 9
10 1
5 10
11 2
1 11
12 2
1 12
22
1 5
3 11
1 1
8 1
2 1
8 2
3 1
6 3
4 1
5 4
5 1
3 5
6 1
7 6
7 1
5 7
8 1
6 8
10 1
4 ...

result:

ok OK in maximum 13 operations

Test #17:

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

input:

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

output:

9
2 1
2 1
1 1
1 3
2 2
1 2
1 1
2 2
1 2
12
3 3
3 5
1 1
2 1
2 2
1 2
3 1
3 3
4 1
3 4
5 2
1 5
17
3 4
1 1
1 9
1 1
9 1
2 1
6 2
3 1
6 3
4 1
4 4
5 1
5 5
6 2
1 6
8 2
1 8
27
1 6
1 1
3 13
1 1
5 1
2 1
11 2
3 1
8 3
4 1
11 4
5 1
9 5
6 1
4 6
7 1
7 7
9 1
4 9
10 1
6 10
11 1
4 11
12 1
3 12
13 2
1 13
23
1 4
1 1
3 10
1 ...

result:

ok OK in maximum 14 operations

Test #18:

score: 0
Accepted
time: 1ms
memory: 3976kb

input:

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

output:

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

result:

ok OK in maximum 26 operations

Test #19:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

1
1000
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 100 1...

output:

6
1 1
1 2
1 998
997 2
1 1
3 1

result:

ok OK in maximum 6 operations

Test #20:

score: 0
Accepted
time: 3ms
memory: 4004kb

input:

1
1000
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 ...

output:

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

result:

ok OK in maximum 1997 operations

Test #21:

score: 0
Accepted
time: 6ms
memory: 3936kb

input:

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

output:

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

result:

ok OK in maximum 1997 operations

Test #22:

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

input:

1
1000
999 1 998 2 1000 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 9...

output:

10
1 996
995 4
1 1
2 1
2 1
4 2
996 1
3 996
997 1
2 997

result:

ok OK in maximum 10 operations

Test #23:

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

input:

1
999
998 1 997 2 999 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 ...

output:

10
1 995
994 4
1 1
2 1
2 1
4 2
995 1
3 995
996 1
2 996

result:

ok OK in maximum 10 operations

Test #24:

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

input:

1
999
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 100 10...

output:

6
1 1
1 2
1 997
996 2
1 1
3 1

result:

ok OK in maximum 6 operations

Test #25:

score: 0
Accepted
time: 6ms
memory: 3852kb

input:

1
999
999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 92...

output:

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

result:

ok OK in maximum 1995 operations

Test #26:

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

input:

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

output:

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

result:

ok OK in maximum 1994 operations

Test #27:

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

input:

1
998
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 100 10...

output:

6
1 1
1 2
1 996
995 2
1 1
3 1

result:

ok OK in maximum 6 operations

Test #28:

score: 0
Accepted
time: 6ms
memory: 3820kb

input:

1
998
998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 92...

output:

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

result:

ok OK in maximum 1993 operations

Test #29:

score: 0
Accepted
time: 6ms
memory: 3992kb

input:

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

output:

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

result:

ok OK in maximum 1993 operations

Test #30:

score: 0
Accepted
time: 1ms
memory: 3940kb

input:

1
997
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 100 10...

output:

6
1 1
1 2
1 995
994 2
1 1
3 1

result:

ok OK in maximum 6 operations

Test #31:

score: 0
Accepted
time: 6ms
memory: 3948kb

input:

1
997
997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 92...

output:

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

result:

ok OK in maximum 1991 operations

Test #32:

score: 0
Accepted
time: 6ms
memory: 3948kb

input:

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

output:

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

result:

ok OK in maximum 1990 operations

Test #33:

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

input:

1
1000
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 392 97 98 99 100 ...

output:

26
1 1
1 2
1 998
997 2
1 1
3 1
95 1
297 95
96 1
610 96
147 1
273 147
148 1
582 148
216 1
91 216
217 1
695 217
306 2
1 306
391 1
608 391
392 1
2 392
420 2
1 420

result:

ok OK in maximum 26 operations

Test #34:

score: 0
Accepted
time: 6ms
memory: 3944kb

input:

1
1000
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 ...

output:

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

result:

ok OK in maximum 1991 operations

Test #35:

score: 0
Accepted
time: 3ms
memory: 3928kb

input:

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

output:

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

result:

ok OK in maximum 1993 operations

Test #36:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

1
1000
999 1 998 2 1000 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 673 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 ...

output:

30
1 996
995 4
1 1
2 1
2 1
4 2
33 1
640 33
34 1
329 34
351 1
423 351
352 1
228 352
455 1
212 455
456 1
335 456
666 2
1 666
672 1
327 672
673 1
2 673
774 2
1 774
996 1
3 996
997 1
2 997

result:

ok OK in maximum 30 operations

Test #37:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

1
1000
999 1 998 2 1000 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 9...

output:

44
1 996
995 4
1 1
2 1
2 1
4 2
303 1
157 303
304 1
542 304
354 1
475 354
355 1
173 355
459 1
540 459
460 1
2 460
655 1
156 655
656 1
191 656
666 1
149 666
667 1
187 667
810 1
189 810
811 1
2 811
815 2
1 815
829 2
1 829
971 1
18 971
972 1
13 972
988 2
1 988
996 1
3 996
997 1
2 997

result:

ok OK in maximum 44 operations

Test #38:

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

input:

1
999
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 100 10...

output:

24
1 1
1 2
1 997
996 2
1 1
3 1
462 1
50 462
463 1
489 463
511 2
1 511
642 1
11 642
643 1
348 643
652 2
1 652
720 1
102 720
721 1
179 721
821 2
1 821

result:

ok OK in maximum 24 operations

Test #39:

score: 0
Accepted
time: 6ms
memory: 3952kb

input:

1
999
999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 92...

output:

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

result:

ok OK in maximum 1989 operations

Test #40:

score: 0
Accepted
time: 3ms
memory: 3812kb

input:

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

output:

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

result:

ok OK in maximum 1990 operations

Test #41:

score: 0
Accepted
time: 1ms
memory: 3972kb

input:

1
998
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 426 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 100 1...

output:

26
1 1
1 2
1 996
995 2
1 1
3 1
63 1
363 63
64 1
574 64
325 1
270 325
326 1
405 326
345 1
237 345
346 1
418 346
425 1
571 425
426 1
3 426
582 2
1 582
595 2
1 595

result:

ok OK in maximum 26 operations

Test #42:

score: 0
Accepted
time: 3ms
memory: 3948kb

input:

1
998
998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 92...

output:

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

result:

ok OK in maximum 1991 operations

Test #43:

score: 0
Accepted
time: 6ms
memory: 4004kb

input:

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

output:

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

result:

ok OK in maximum 1987 operations

Test #44:

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

input:

1
997
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 100 10...

output:

26
1 1
1 2
1 995
994 2
1 1
3 1
180 1
153 180
181 1
666 181
332 2
1 332
378 1
67 378
379 1
554 379
411 1
190 411
412 1
398 412
444 1
552 444
445 1
2 445
601 2
1 601

result:

ok OK in maximum 26 operations

Test #45:

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

input:

1
997
997 996 995 994 993 992 991 990 989 988 987 986 176 984 983 982 981 980 979 978 977 976 975 974 973 756 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 92...

output:

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

result:

ok OK in maximum 1987 operations

Test #46:

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

input:

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

output:

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

result:

ok OK in maximum 1984 operations

Test #47:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

1
786
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 188 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 316 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 100 ...

output:

50
1 1
1 2
1 784
783 2
1 1
3 1
17 1
171 17
18 1
600 18
55 1
260 55
56 1
473 56
187 1
598 187
188 1
2 188
254 1
515 254
255 1
19 255
267 1
161 267
268 1
360 268
293 1
373 293
294 1
122 294
315 1
468 315
316 1
4 316
428 1
357 428
429 1
2 429
571 1
157 571
572 1
60 572
667 1
118 667
668 1
2 668
728 2
1...

result:

ok OK in maximum 50 operations

Test #48:

score: 0
Accepted
time: 6ms
memory: 3956kb

input:

1
979
979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 81 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 900 932 931 930 929 928 927 926 925 924 923 509 921 920 919 918 917 916 915 914 913 912 911 910 909 908 907 906...

output:

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

result:

ok OK in maximum 1945 operations

Test #49:

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

input:

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

output:

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

result:

ok OK in maximum 1583 operations

Test #50:

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

input:

1
997
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 100 10...

output:

54
1 1
1 2
1 995
994 2
1 1
3 1
264 1
494 264
265 1
241 265
290 1
539 290
291 1
170 291
411 1
533 411
412 1
55 412
432 1
195 432
433 1
372 433
626 2
1 626
643 1
255 643
644 1
101 644
677 1
234 677
678 1
88 678
757 1
236 757
758 1
5 758
802 1
37 802
803 1
160 803
829 1
164 829
830 1
5 830
839 2
1 839
...

result:

ok OK in maximum 54 operations

Test #51:

score: 0
Accepted
time: 5ms
memory: 3936kb

input:

1
876
876 875 874 873 872 871 870 402 868 867 866 865 864 863 862 861 860 859 858 857 856 855 854 853 852 851 850 849 848 847 846 845 844 843 842 841 840 839 838 837 836 835 834 833 832 831 830 829 828 827 826 825 824 823 822 821 820 819 818 817 816 815 814 813 812 811 810 809 808 807 806 805 804 80...

output:

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

result:

ok OK in maximum 1743 operations

Test #52:

score: 0
Accepted
time: 6ms
memory: 3948kb

input:

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

output:

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

result:

ok OK in maximum 1974 operations

Test #53:

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

input:

1
994
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 100 10...

output:

18
1 1
1 2
1 992
991 2
1 1
3 1
240 1
724 240
241 1
32 241
350 1
238 350
351 1
408 351
587 2
1 587
963 2
1 963

result:

ok OK in maximum 18 operations

Test #54:

score: 0
Accepted
time: 6ms
memory: 3936kb

input:

1
989
989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 91...

output:

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

result:

ok OK in maximum 1973 operations

Test #55:

score: 0
Accepted
time: 6ms
memory: 3940kb

input:

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

output:

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

result:

ok OK in maximum 1974 operations

Test #56:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

1
779
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 100 10...

output:

32
1 1
1 2
1 777
776 2
1 1
3 1
217 1
263 217
218 1
301 218
332 1
334 332
333 1
115 333
355 1
194 355
356 1
232 356
479 1
298 479
480 1
3 480
549 2
1 549
666 2
1 666
724 1
25 724
725 1
32 725
748 2
1 748

result:

ok OK in maximum 32 operations

Test #57:

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

input:

1
797
797 796 795 794 793 792 791 790 789 788 787 786 785 784 783 782 781 780 779 778 777 776 775 774 773 772 771 770 769 768 767 766 765 764 763 762 761 760 759 758 757 756 755 754 753 752 751 750 749 748 747 746 745 744 743 742 741 740 739 738 737 736 735 734 733 732 731 730 729 180 727 726 725 72...

output:

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

result:

ok OK in maximum 1587 operations

Test #58:

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

input:

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

output:

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

result:

ok OK in maximum 1321 operations

Test #59:

score: 0
Accepted
time: 6ms
memory: 3948kb

input:

1
1000
578 309 830 993 658 748 234 814 841 592 32 353 750 217 807 478 970 442 676 274 850 638 367 776 63 165 649 945 475 773 528 491 986 918 68 966 448 992 879 503 364 564 290 675 47 586 891 954 5 982 305 628 34 881 593 130 409 431 824 757 931 948 751 188 434 69 19 190 825 855 253 732 663 65 133 835...

output:

1983
640 208
1 1
847 152
1 1
476 1
2 1
689 2
3 1
50 3
4 1
344 4
5 1
426 5
6 1
35 6
7 1
225 7
8 1
787 8
9 1
961 9
10 1
667 10
11 1
255 11
12 1
402 12
13 1
317 13
14 1
827 14
15 1
972 15
16 1
893 16
17 1
795 17
18 1
363 18
19 1
853 19
20 1
382 20
21 1
761 21
22 1
371 22
23 1
189 23
24 1
491 24
25 1
90...

result:

ok OK in maximum 1983 operations

Test #60:

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

input:

1
999
587 632 199 969 304 657 430 733 692 680 378 704 506 884 832 959 150 898 242 641 968 818 77 584 806 529 74 29 338 205 555 410 72 82 964 487 774 111 765 625 835 580 992 437 65 602 958 517 800 637 795 128 350 626 450 694 262 812 287 289 468 603 432 561 942 827 714 101 54 996 656 874 681 932 718 2...

output:

1984
186 355
205 793
1 1
996 1
2 1
517 2
3 1
236 3
4 1
46 4
5 1
360 5
6 1
65 6
7 1
472 7
8 1
555 8
9 1
258 9
10 1
319 10
11 1
719 11
12 1
814 12
13 1
292 13
14 1
496 14
15 1
282 15
16 1
575 16
17 1
673 17
18 1
668 18
19 1
733 19
20 1
417 20
21 1
799 21
22 1
498 22
23 1
798 23
25 1
591 25
26 1
725 26...

result:

ok OK in maximum 1984 operations

Test #61:

score: 0
Accepted
time: 6ms
memory: 3948kb

input:

1
1000
942 663 980 943 478 437 896 721 40 616 613 423 487 344 424 269 639 813 335 35 359 2 115 701 366 940 495 545 879 42 296 826 370 859 599 861 996 530 459 724 412 622 136 548 918 171 160 343 547 14 658 807 681 636 448 928 132 893 982 227 388 757 543 814 985 585 742 301 815 897 831 298 950 925 758...

output:

1984
248 546
736 263
1 1
36 1
2 1
182 2
3 1
950 3
4 1
71 4
5 1
390 5
6 1
780 6
7 1
117 7
8 1
818 8
9 1
161 9
10 1
770 10
11 1
591 11
12 1
467 12
13 1
690 13
14 1
105 14
15 1
489 15
16 1
137 16
17 1
438 17
18 1
566 18
19 1
613 19
20 1
275 20
21 1
760 21
22 1
591 22
23 1
184 23
24 1
565 24
25 1
286 25...

result:

ok OK in maximum 1984 operations

Test #62:

score: 0
Accepted
time: 6ms
memory: 3928kb

input:

1
999
113 438 987 12 663 156 157 317 757 698 170 134 491 495 80 899 426 750 437 979 938 121 199 210 399 96 76 286 855 47 242 416 728 352 271 562 203 755 116 981 643 161 816 840 49 385 681 331 306 179 50 213 695 929 628 807 952 884 349 34 43 92 326 639 850 474 104 806 963 737 898 45 409 629 809 20 95...

output:

1980
323 220
891 107
1 1
687 1
2 1
714 2
3 1
685 3
4 1
911 4
5 1
16 5
6 1
884 6
7 1
295 7
8 1
474 8
9 1
55 9
10 1
952 10
11 1
84 11
12 1
642 12
13 1
962 13
14 1
755 14
15 1
713 15
16 1
852 16
17 1
205 17
18 1
723 18
19 1
144 19
20 1
235 20
21 1
470 21
22 1
384 22
23 1
417 23
24 1
928 24
25 1
423 25
...

result:

ok OK in maximum 1980 operations

Test #63:

score: 0
Accepted
time: 6ms
memory: 3892kb

input:

1
1000
546 417 781 732 488 684 86 603 677 529 678 253 756 307 819 476 757 899 838 976 755 246 418 55 904 512 727 440 960 642 969 294 163 434 873 317 87 91 329 840 243 459 522 959 694 689 278 620 472 591 766 54 425 147 128 213 315 95 267 365 825 295 533 900 380 502 291 862 788 872 938 800 21 419 995 ...

output:

1980
238 7
230 769
1 1
989 1
2 1
340 2
3 1
680 3
4 1
829 4
5 1
983 5
6 1
898 6
7 1
499 7
8 1
120 8
9 1
847 9
10 1
649 10
11 1
928 11
12 1
705 12
13 1
456 13
14 1
959 14
15 1
414 15
16 1
507 16
17 1
283 17
18 1
535 18
19 1
40 19
20 1
832 20
21 1
108 21
22 1
355 22
23 1
665 23
24 1
953 24
25 1
875 25
...

result:

ok OK in maximum 1980 operations

Test #64:

score: 0
Accepted
time: 6ms
memory: 3948kb

input:

1
999
774 166 908 231 496 472 465 16 102 978 49 570 597 411 168 299 378 561 429 668 676 250 362 784 840 650 326 370 377 548 134 845 183 793 809 934 928 980 619 404 331 173 256 644 382 901 426 232 200 144 780 617 743 609 431 17 520 24 425 794 334 450 786 135 280 490 245 236 215 25 380 719 155 126 471...

output:

1977
667 119
1 1
240 758
1 1
271 1
2 1
25 2
3 1
202 3
4 1
381 4
5 1
858 5
6 1
690 6
7 1
307 7
8 1
262 8
9 1
989 9
10 1
895 10
11 1
322 11
12 1
23 12
13 1
922 13
14 1
4 14
15 1
885 15
16 1
48 16
17 1
433 17
18 1
5 18
19 1
239 19
20 1
56 20
21 1
548 21
22 1
897 22
23 1
761 23
24 1
12 24
25 1
525 25
26...

result:

ok OK in maximum 1977 operations

Test #65:

score: 0
Accepted
time: 6ms
memory: 3956kb

input:

1
1000
766 935 587 770 502 232 760 629 561 481 89 664 571 241 87 326 708 605 79 721 871 752 669 555 123 990 269 400 583 290 594 346 933 719 859 830 181 510 61 658 706 399 911 411 778 948 306 707 781 47 740 434 645 18 944 847 668 336 886 811 548 155 599 404 461 278 211 589 884 672 785 989 941 17 260 ...

output:

1988
198 234
692 307
1 1
700 1
2 1
235 2
3 1
104 3
4 1
159 4
5 1
420 5
6 1
271 6
7 1
429 7
8 1
487 8
9 1
947 9
10 1
929 10
11 1
586 11
12 1
370 12
13 1
889 13
14 1
296 14
15 1
32 15
16 1
273 16
17 1
964 17
18 1
152 18
19 1
515 19
20 1
880 20
21 1
617 21
22 1
639 22
23 1
557 23
24 1
251 24
25 1
718 2...

result:

ok OK in maximum 1988 operations

Test #66:

score: 0
Accepted
time: 6ms
memory: 3936kb

input:

1
999
543 320 106 886 488 688 182 305 911 670 598 134 828 201 627 69 124 132 811 768 65 423 281 189 801 599 312 567 999 487 762 764 405 778 898 365 957 743 990 951 516 28 388 477 261 296 464 619 984 227 504 329 391 507 317 612 560 1 557 649 20 376 945 744 881 926 260 322 831 271 781 950 144 262 789 ...

output:

1985
29 301
1 1
328 670
1 1
253 1
2 1
326 2
3 1
531 3
4 1
3 4
5 1
817 5
6 1
167 6
7 1
102 7
8 1
753 8
9 1
132 9
10 1
742 10
11 1
663 11
12 1
93 12
13 1
771 13
14 1
620 14
15 1
682 15
16 1
813 16
17 1
354 17
18 1
403 18
19 1
678 19
20 1
889 20
21 1
436 21
22 1
169 22
23 1
800 23
24 1
253 24
25 1
563 ...

result:

ok OK in maximum 1985 operations

Test #67:

score: 0
Accepted
time: 6ms
memory: 3952kb

input:

1
1000
608 358 52 308 498 40 688 621 736 287 525 969 537 769 681 653 309 330 490 385 232 585 472 379 406 704 522 667 291 593 260 206 72 162 443 399 801 230 127 718 421 721 415 471 968 159 110 38 838 587 880 172 281 900 335 144 987 568 119 196 62 299 145 545 864 922 211 635 649 822 793 134 403 640 11...

output:

1986
525 134
437 562
1 1
353 1
2 1
791 2
3 1
458 3
4 1
286 4
5 1
484 5
6 1
956 6
7 1
77 7
8 1
787 8
9 1
455 9
10 1
39 10
11 1
100 11
12 1
449 12
13 1
852 13
14 1
78 14
15 1
501 15
16 1
716 16
17 1
590 17
18 1
543 18
19 1
815 19
20 1
512 20
21 1
618 21
22 1
640 22
23 1
519 23
24 1
929 24
25 1
55 25
2...

result:

ok OK in maximum 1986 operations

Test #68:

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

input:

1
999
911 432 290 796 764 61 990 509 200 218 304 386 312 204 690 672 655 883 532 365 667 675 457 840 900 842 437 536 766 925 637 287 346 232 523 721 190 770 483 481 908 740 952 954 514 213 700 51 216 16 297 586 593 55 502 240 889 746 472 858 831 423 138 689 89 739 407 972 613 201 914 490 518 340 961...

output:

1989
637 232
1 1
526 472
1 1
416 1
2 1
947 2
3 1
824 3
4 1
313 4
5 1
455 5
6 1
568 6
7 1
253 7
8 1
121 8
9 1
490 9
10 1
63 10
11 1
274 11
12 1
506 12
13 1
712 13
14 1
36 14
15 1
857 15
16 1
107 16
17 1
979 17
18 1
798 18
19 1
697 19
20 1
271 20
21 1
736 21
22 1
625 22
23 1
718 23
24 1
356 24
25 1
28...

result:

ok OK in maximum 1989 operations

Test #69:

score: 0
Accepted
time: 6ms
memory: 3996kb

input:

1
1000
553 48 915 421 206 713 491 894 864 951 261 512 602 976 136 283 132 380 824 617 955 681 51 514 158 601 900 945 9 534 995 268 33 473 825 54 476 26 999 981 399 223 649 263 167 948 253 679 120 13 734 949 917 609 575 838 646 359 369 312 478 485 802 246 931 680 774 632 286 201 961 723 763 585 724 7...

output:

1972
39 757
181 818
1 1
87 1
2 1
748 2
3 1
144 3
4 1
314 4
5 1
819 5
6 1
10 6
7 1
884 7
8 1
787 8
9 1
133 9
10 1
185 10
11 1
511 11
12 1
930 12
13 1
788 13
14 1
699 14
15 1
412 15
16 1
598 16
17 1
94 17
18 1
626 18
19 1
818 19
20 1
206 20
22 1
656 22
23 1
373 23
24 1
462 24
25 1
392 25
26 1
615 26
2...

result:

ok OK in maximum 1972 operations

Test #70:

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

input:

1
999
801 440 924 519 4 420 320 244 674 455 838 164 783 603 676 967 352 407 973 727 29 929 875 970 792 138 152 552 312 978 807 489 61 648 177 717 424 691 186 825 123 454 684 206 944 240 491 873 709 314 582 216 613 479 960 872 214 98 921 209 39 818 403 380 841 327 854 704 548 42 365 371 135 387 640 1...

output:

1987
519 34
1 1
208 790
1 1
728 1
2 1
964 2
3 1
578 3
4 1
961 4
5 1
698 5
6 1
686 6
7 1
584 7
8 1
975 8
9 1
566 9
10 1
55 10
11 1
613 11
12 1
122 12
13 1
348 13
14 1
567 14
15 1
574 15
16 1
554 16
17 1
25 17
18 1
307 18
19 1
915 19
20 1
436 20
21 1
361 21
22 1
772 22
23 1
521 23
24 1
740 24
25 1
917...

result:

ok OK in maximum 1987 operations

Test #71:

score: 0
Accepted
time: 6ms
memory: 4000kb

input:

1
1000
671 474 830 79 544 973 560 315 103 804 954 850 756 890 450 395 773 792 256 407 928 983 682 621 388 378 67 718 243 640 812 4 788 511 230 503 456 150 246 496 454 738 217 411 204 876 305 9 940 290 280 498 849 980 986 327 85 110 285 647 80 552 691 586 479 786 190 293 976 151 188 581 783 311 639 3...

output:

1974
845 101
975 24
1 1
135 1
2 1
289 2
3 1
785 3
4 1
199 4
5 1
707 5
6 1
870 6
7 1
333 7
8 1
890 8
9 1
454 9
10 1
887 10
11 1
215 11
12 1
151 12
13 1
411 13
14 1
432 14
15 1
560 15
16 1
900 16
17 1
156 17
18 1
894 18
19 1
162 19
20 1
834 20
21 1
536 21
22 1
75 22
23 1
174 23
24 1
636 24
25 1
595 25...

result:

ok OK in maximum 1974 operations

Test #72:

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

input:

1
999
673 776 646 216 614 126 24 515 606 840 979 826 527 349 524 512 679 735 355 972 152 105 772 844 850 784 672 857 775 136 155 761 174 71 798 977 851 628 62 153 892 23 953 97 717 786 237 315 800 869 60 142 802 446 351 299 55 861 852 251 505 900 880 936 482 101 376 236 338 952 653 661 310 503 803 2...

output:

1985
223 205
1 1
492 506
1 1
610 1
2 1
354 2
3 1
689 3
4 1
552 4
5 1
154 5
6 1
58 6
7 1
673 7
8 1
839 8
9 1
700 9
10 1
364 10
11 1
578 11
12 1
4 12
13 1
915 13
14 1
366 14
15 1
582 15
16 1
211 16
17 1
221 17
18 1
617 18
19 1
878 19
20 1
934 20
21 1
2 21
22 1
890 22
23 1
942 23
24 1
695 24
25 1
370 2...

result:

ok OK in maximum 1985 operations