QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#115950#5305. Oscar is All You NeedPetroTarnavskyiAC ✓38ms11280kbC++172.9kb2023-06-27 19:39:122023-06-27 19:39:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-27 19:39:16]
  • 评测
  • 测评结果:AC
  • 用时:38ms
  • 内存:11280kb
  • [2023-06-27 19:39:12]
  • 提交

answer

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

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

map<VI, int> m;
map<VI, PII> op;

void brute(int n)
{
	VI v(n);
	iota(ALL(v), 1);
	m[v] = 0;
	queue<VI> q;
	q.push(v);
	while (!q.empty())
	{
		auto b = q.front();
		q.pop();
		int a = m[b];
		FOR (x, 1, n - 1)
		{
			FOR (y, 1, n - x)
			{
				VI vec;
				FOR (i, 0, y) vec.PB(b[n - y + i]);
				FOR (i, x, n - y) vec.PB(b[i]);
				FOR (i, 0, x) vec.PB(b[i]);
				if (!m.count(vec))
				{
					m[vec] = a + 1;
					op[vec] = {y, x};
					q.push(vec);
				}
			}
		}
	}
	
}

vector<PII> oper;

void zrobyty(VI& a, VI& sz, PII p)
{
	int n = SZ(a);
	int x = 0, y = 0;
	FOR (i, 0, p.first) x += sz[i];
	FOR (i, 0, p.second) y += sz[SZ(a) - 1 - i];
	oper.PB({x, y});
	
	VI na, nsz;
	FOR (i, 0, p.second)
	{
		na.PB(a[n - p.second + i]);
		nsz.PB(sz[n - p.second + i]);
	}
	
	FOR (i, p.first, n - p.second)
	{ 
		na.PB(a[i]);
		nsz.PB(sz[i]);
	}
	FOR (i, 0, p.first)
	{
		na.PB(a[i]);
		nsz.PB(sz[i]);
	}
	a = na;
	sz = nsz;
}

void comp(VI& a, VI& sz, int k)
{
	int n = SZ(a);
	VI na;
	VI nsz;
	FOR (i, 0, n)
	{ 
		if (a[i] != k) 
		{
			na.PB(a[i] < k ? a[i] : a[i] - 1);
			nsz.PB(sz[i]);
		}
		else
		{
			assert(na.back() == k - 1);
			nsz.back() += sz[i];
		}
	}
	a = na;
	sz = nsz;
}

void solve(VI a, VI sz)
{
	int n = SZ(a);
	if (SZ(a) <= 7)
	{
		assert(m[a] < 2 * SZ(a) + 2);
		while (m[a] != 0)
		{
			PII p = op[a];
			zrobyty(a, sz, p);
		}
		return;
	}
	VI pos(n);
	FOR(i, 0, n)
		pos[a[i] - 1] = i;
		
	FOR(it,	1, n){
		int i = pos[it - 1];
		int j = pos[it];
		if(j > i || i >= n - 2) continue;
	
			int k = a[j];
			zrobyty(a, sz, {i + 1, 1});
			zrobyty(a, sz, {n - 1 - (i - j), 1});
			
			comp(a, sz, k);
			assert(SZ(a) == n - 1);
			
			solve(a, sz);
			
			return;
	}
	
	FOR(it,	1, n){
		int i = pos[it];
		int j = pos[it - 1];
		if(j > i || i >= n - 1) continue;

		int k = a[i];
		zrobyty(a, sz, {j + 1, 1});
		zrobyty(a, sz, {i - j, 1});
	
		comp(a, sz, k);
		assert(SZ(a) == n - 1);
		solve(a, sz);
				
		return;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	for (int i = 4; i <= 7; i++) brute(i);
	
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		VI a(n);
		FOR (i, 0, n) cin >> a[i];
		if (n == 3)
		{
			if (a[2] < a[0])
				cout << "1\n1 1\n";
			else
				cout << "0\n";
			continue;
		}
		VI sz(n, 1);
		solve(a, sz);
		cout << SZ(oper) << '\n';
		FOR (i, 0, SZ(oper))
		{
			cout << oper[i].first << ' ' << oper[i].second << '\n';
		}
		oper.clear();
	}
	
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 28ms
memory: 5092kb

input:

2
3
1 3 2
5
4 1 2 3 5

output:

0
2
2 1
1 1

result:

ok OK in maximum 2 operations

Test #2:

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

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
0
14
8 1
6 1
10 1
7 1
4 1
8 1
7 1
9 1
7 1
8 2
5 3
4 2
8 2
6 3
63
15 1
24 1
6 1
30 1
20 1
22 1
33 1
5 3
21 2
30 1
31 1
11 1
20 1
16 4
33 1
14 2
32 1
4 7
21 1
27 1
34 1
2 10
24 1
28 1
16 1
34 1
29 1
7 1
25 1
11 2
25 1
11 1
23 1
13 12
31 1
31 1
28 1
17 18
29 1
30 2
32 1
4 19
34 1
31 1
33 ...

result:

ok OK in maximum 1 operations

Test #3:

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

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:

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

result:

ok OK in maximum 0 operations

Test #4:

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

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: 24ms
memory: 5108kb

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:

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

result:

ok OK in maximum 4 operations

Test #6:

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

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:

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

result:

ok OK in maximum 2 operations

Test #7:

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

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:

3
2 1
2 2
3 1
1
1 1
3
2 1
4 1
2 2
3
3 1
3 1
3 1
1
1 1
3
3 2
3 2
1 1
4
1 3
2 3
3 1
3 1
5
3 2
4 2
2 1
3 1
1 1
4
4 1
3 2
3 1
1 1
4
1 1
2 1
2 1
1 1
4
2 2
2 1
2 1
3 1
3
1 4
2 3
1 1
1
1 3
5
1 1
1 2
1 1
2 1
1 1
0
0
3
1 2
2 2
1 1
1
1 1
0
5
2 2
3 1
2 2
4 1
1 1
3
4 2
5 1
2 4
1
2 1
4
1 1
3 2
1 1
2 1
4
3 1
3 1
...

result:

ok OK in maximum 3 operations

Test #8:

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

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
4
1 1
2 2
1 2
1 1
1
1 1
3
2 1
2 2
3 1
5
1 1
2 1
3 1
3 1
1 1
1
1 1
1
1 1
4
1 1
2 1
2 1
1 1
5
1 3
3 2
1 1
2 2
1 1
3
2 2
3 1
1 1
0
1
1 2
1
1 2
1
1 1
4
1 1
2 2
1 1
1 2
1
1 1
3
4 1
4 1
4 1
1
1 1
0
0
3
2 2
3 1
2 2
0
4
2 1
3 3
2 2
2 1
2
2 1
1 1
5
2 3
5 1
3 3
2 1
4 1
3
3 1
3 1
1 1
3
2 3
1 4
1 1
4
3 1
2 2
...

result:

ok OK in maximum 2 operations

Test #9:

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

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
3
2 1
2 1
2 2
4
1 4
2 3
3 1
1 1
4
1 2
1 1
2 1
2 1
0
5
4 2
5 1
2 2
1 3
1 1
0
4
1 3
1 1
2 2
1 3
3
1 1
2 1
2 1
1
1 1
1
2 1
5
1 5
1 1
3 2
3 1
1 1
4
1 4
3 2
5 1
3 1
4
1 2
2 2
3 1
1 1
3
1 1
1 2
1 1
4
2 1
1 1
2 2
3 1
2
1 2
2 2
3
2 1
2 3
3 1
3
3 1
3 1
2 1
4
2 2
5 1
4 2
1 2
3
1 4
2 3
4 1
5
1 2
1 1
2 ...

result:

ok OK in maximum 2 operations

Test #10:

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

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:

3
1 3
1 1
2 2
4
1 3
2 2
5 1
2 1
4
2 2
1 1
3 2
3 1
4
1 3
1 4
1 1
2 1
0
4
1 1
2 2
3 1
1 1
1
1 1
5
1 5
1 3
4 2
2 1
1 1
4
1 3
1 1
2 3
1 1
2
2 2
2 1
4
1 3
4 2
3 3
1 2
3
1 3
1 1
2 1
4
4 2
3 1
2 2
5 1
2
1 2
2 2
2
1 1
1 2
4
3 2
1 4
2 4
3 1
3
1 1
2 1
2 2
2
2 1
1 1
1
2 1
0
4
1 3
2 2
1 1
1 2
4
3 2
1 3
1 2
1 3
...

result:

ok OK in maximum 4 operations

Test #11:

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

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:

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

result:

ok OK in maximum 6 operations

Test #12:

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

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:

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

result:

ok OK in maximum 1 operations

Test #13:

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

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
6 1
5 1
3 3
5 1
6 1
5 1
1 2
8
2 1
7 1
7 1
5 1
2 5
2 3
5 1
5 2
0
0
10
6 1
4 1
4 1
6 1
7 1
6 1
2 4
1 3
7 2
4 4
5
4 1
6 1
5 1
5 2
1 3
0
1
1 2
1
1 1
5
2 3
5 1
5 1
4 2
1 1
3
1 3
3 2
1 1
9
7 1
2 1
7 1
2 1
5 2
3 1
2 2
7 1
1 1
5
1 1
1 2
1 1
2 1
1 1
9
3 1
7 1
7 1
4 1
3 4
2 4
3 1
4 2
2 2
2
1 3
1 3
4
2 2
3 1...

result:

ok OK in maximum 0 operations

Test #14:

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

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
2 1
1 1
1 2
1 1
7
4 1
4 1
2 5
1 4
5 2
4 1
2 1
8
7 1
6 1
7 1
6 1
3 4
3 4
1 1
1 3
4
4 1
6 1
3 2
5 1
10
2 1
8 1
7 1
8 1
5 1
5 1
4 1
2 4
7 1
2 2
2
2 1
1 1
5
1 2
1 1
2 1
2 1
1 1
2
1 4
1 1
2
1 2
1 1
5
6 1
4 1
2 3
1 3
1 4
4
3 2
1 2
1 3
1 2
4
2 1
2 2
1 2
1 1
4
3 1
2 2
1 2
1 1
6
6 1
4 1
6 1
2 1
3 3
5 2
3
2...

result:

ok OK in maximum 0 operations

Test #15:

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

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:

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

result:

ok OK in maximum 3 operations

Test #16:

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

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
9 1
11 1
14 1
3 1
4 1
13 1
12 1
12 1
10 1
15 1
7 1
12 4
10 2
14 2
15 1
2 5
13 1
12 1
5 8
12 1
5 1
12 1
14 2
4 8
22
11 1
5 1
8 1
8 1
9 1
12 1
14 1
5 3
13 1
8 1
6 1
10 1
5 4
11 1
9 2
11 4
7 4
9 2
12 1
2 1
10 1
1 7
20
9 1
8 1
8 1
7 1
13 1
6 1
7 1
8 1
10 3
10 1
13 1
2 3
11 1
4 3
8 1
4 8
9 4
4 10
10 1...

result:

ok OK in maximum 16 operations

Test #17:

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

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:

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

result:

ok OK in maximum 7 operations

Test #18:

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

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:

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

result:

ok OK in maximum 24 operations

Test #19:

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

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:

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

result:

ok OK in maximum 1986 operations

Test #20:

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

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:

1990
998 1
998 1
4 1
996 1
4 1
996 1
6 1
998 1
995 4
998 1
10 1
996 1
4 4
996 2
8 2
992 4
998 1
998 1
15 1
987 1
13 2
987 2
13 1
987 8
17 1
996 1
4 1
996 2
5 12
995 1
17 1
983 12
19 1
998 1
982 17
998 1
23 1
996 1
4 17
996 2
21 2
979 17
998 1
998 1
28 1
974 1
26 2
974 2
26 1
974 21
30 1
996 1
4 1
99...

result:

ok OK in maximum 1990 operations

Test #21:

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

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:

1986
2 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
9...

result:

ok OK in maximum 1986 operations

Test #22:

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

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:

1989
3 1
997 1
4 1
996 1
5 1
995 1
6 1
994 1
7 1
993 1
8 1
992 1
9 1
991 1
10 1
990 1
11 1
989 1
12 1
988 1
13 1
987 1
14 1
986 1
15 1
985 1
16 1
984 1
17 1
983 1
18 1
982 1
19 1
981 1
20 1
980 1
21 1
979 1
22 1
978 1
23 1
977 1
24 1
976 1
25 1
975 1
26 1
974 1
27 1
973 1
28 1
972 1
29 1
971 1
30 1
...

result:

ok OK in maximum 1989 operations

Test #23:

score: 0
Accepted
time: 34ms
memory: 11152kb

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:

1987
3 1
996 1
4 1
995 1
5 1
994 1
6 1
993 1
7 1
992 1
8 1
991 1
9 1
990 1
10 1
989 1
11 1
988 1
12 1
987 1
13 1
986 1
14 1
985 1
15 1
984 1
16 1
983 1
17 1
982 1
18 1
981 1
19 1
980 1
20 1
979 1
21 1
978 1
22 1
977 1
23 1
976 1
24 1
975 1
25 1
974 1
26 1
973 1
27 1
972 1
28 1
971 1
29 1
970 1
30 1
...

result:

ok OK in maximum 1987 operations

Test #24:

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

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:

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

result:

ok OK in maximum 1984 operations

Test #25:

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

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:

1988
997 1
997 1
4 1
995 1
4 1
995 1
6 1
997 1
994 4
997 1
10 1
995 1
4 4
995 2
8 2
991 4
997 1
997 1
15 1
986 1
13 2
986 2
13 1
986 8
17 1
995 1
4 1
995 2
5 12
994 1
17 1
982 12
19 1
997 1
981 17
997 1
23 1
995 1
4 17
995 2
21 2
978 17
997 1
997 1
28 1
973 1
26 2
973 2
26 1
973 21
30 1
995 1
4 1
99...

result:

ok OK in maximum 1988 operations

Test #26:

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

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:

1984
2 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
9...

result:

ok OK in maximum 1984 operations

Test #27:

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

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:

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

result:

ok OK in maximum 1982 operations

Test #28:

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

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:

1987
996 1
996 1
4 1
994 1
4 1
994 1
6 1
996 1
993 4
996 1
10 1
994 1
4 4
994 2
8 2
990 4
996 1
996 1
15 1
985 1
13 2
985 2
13 1
985 8
17 1
994 1
4 1
994 2
5 12
993 1
17 1
981 12
19 1
996 1
980 17
996 1
23 1
994 1
4 17
994 2
21 2
977 17
996 1
996 1
28 1
972 1
26 2
972 2
26 1
972 21
30 1
994 1
4 1
99...

result:

ok OK in maximum 1987 operations

Test #29:

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

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:

1986
2 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
9...

result:

ok OK in maximum 1986 operations

Test #30:

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

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:

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

result:

ok OK in maximum 1980 operations

Test #31:

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

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:

1985
995 1
995 1
4 1
993 1
4 1
993 1
6 1
995 1
992 4
995 1
10 1
993 1
4 4
993 2
8 2
989 4
995 1
995 1
15 1
984 1
13 2
984 2
13 1
984 8
17 1
993 1
4 1
993 2
5 12
992 1
17 1
980 12
19 1
995 1
979 17
995 1
23 1
993 1
4 17
993 2
21 2
976 17
995 1
995 1
28 1
971 1
26 2
971 2
26 1
971 21
30 1
993 1
4 1
99...

result:

ok OK in maximum 1985 operations

Test #32:

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

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:

1981
2 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
9...

result:

ok OK in maximum 1981 operations

Test #33:

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

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:

1986
392 1
704 1
326 1
727 1
160 1
910 1
205 1
971 1
914 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
115 1
885 1
1...

result:

ok OK in maximum 1986 operations

Test #34:

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

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:

1989
998 1
998 1
4 1
996 1
4 1
996 1
6 1
998 1
995 4
998 1
10 1
996 1
4 4
996 2
8 2
992 4
998 1
998 1
15 1
987 1
13 2
987 2
13 1
987 8
17 1
996 1
4 1
996 2
5 12
995 1
17 1
983 12
19 1
998 1
982 17
998 1
23 1
996 1
4 17
996 2
21 2
979 17
998 1
998 1
28 1
974 1
26 2
974 2
26 1
974 21
30 1
996 1
4 1
99...

result:

ok OK in maximum 1989 operations

Test #35:

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

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:

1990
2 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
998 1
5 1
9...

result:

ok OK in maximum 1990 operations

Test #36:

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

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:

1990
676 1
361 1
742 1
577 1
316 1
789 1
320 1
898 1
993 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
109 1
891 1
1...

result:

ok OK in maximum 1990 operations

Test #37:

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

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:

1986
463 1
844 1
527 1
525 1
476 1
630 1
352 1
845 1
161 1
851 1
150 1
995 1
179 1
983 1
25 1
992 1
9 1
993 1
8 2
992 1
13 1
997 1
990 2
13 1
987 1
13 1
988 2
15 1
989 3
996 2
15 1
985 1
16 1
989 1
12 5
988 1
19 1
2 2
3 1
1 3
4 1
1 4
5 1
1 5
6 1
1 6
7 1
1 7
8 1
1 8
9 1
1 9
10 1
1 10
11 1
1 11
12 1
1...

result:

ok OK in maximum 1986 operations

Test #38:

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

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:

1987
512 1
950 1
191 1
989 1
867 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 2
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
142 1
857 1
1...

result:

ok OK in maximum 1987 operations

Test #39:

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

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:

1988
997 1
997 1
4 1
995 1
4 1
995 1
6 1
997 1
994 4
997 1
10 1
995 1
4 4
995 2
8 2
991 4
997 1
997 1
15 1
986 1
13 2
986 2
13 1
986 8
17 1
995 1
4 1
995 2
5 12
994 1
17 1
982 12
19 1
997 1
981 17
997 1
23 1
995 1
4 17
995 2
21 2
978 17
997 1
997 1
28 1
973 1
26 2
973 2
26 1
973 21
30 1
995 1
4 1
99...

result:

ok OK in maximum 1988 operations

Test #40:

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

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:

1986
2 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
997 1
5 1
9...

result:

ok OK in maximum 1986 operations

Test #41:

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

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:

1985
426 1
636 1
533 1
728 1
258 1
761 1
251 1
828 1
171 1
985 1
415 1
596 1
403 1
597 1
402 2
596 1
405 1
1 1
2 1
1 2
3 1
1 3
4 1
1 4
5 1
1 5
6 1
1 6
7 1
1 7
8 1
1 8
9 1
1 9
10 1
1 10
11 1
1 11
12 1
1 12
13 1
1 13
14 1
1 14
15 1
1 15
16 1
1 16
17 1
1 17
18 1
1 18
19 1
1 19
20 1
1 20
21 1
1 21
22 1
...

result:

ok OK in maximum 1985 operations

Test #42:

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

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:

1985
996 1
996 1
4 1
994 1
4 1
994 1
6 1
996 1
993 4
996 1
10 1
994 1
4 4
994 2
8 2
990 4
996 1
996 1
15 1
985 1
13 2
985 2
13 1
985 8
17 1
994 1
4 1
994 2
5 12
993 1
17 1
981 12
19 1
996 1
980 17
996 1
23 1
994 1
4 17
994 2
21 2
977 17
996 1
996 1
28 1
972 1
26 2
972 2
26 1
972 21
30 1
994 1
4 1
99...

result:

ok OK in maximum 1985 operations

Test #43:

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

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:

1985
2 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
996 1
5 1
9...

result:

ok OK in maximum 1985 operations

Test #44:

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

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:

1983
333 1
845 1
265 1
931 1
950 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
113 1
884 1
1...

result:

ok OK in maximum 1983 operations

Test #45:

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

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:

1985
995 1
995 1
4 1
993 1
4 1
993 1
6 1
995 1
992 4
995 1
10 1
993 1
4 4
993 2
8 2
989 4
995 1
995 1
15 1
984 1
13 2
984 2
13 1
984 8
17 1
993 1
4 1
993 2
5 12
992 1
17 1
980 12
19 1
995 1
979 17
995 1
23 1
993 1
4 17
993 2
21 2
976 17
995 1
995 1
28 1
971 1
26 2
971 2
26 1
971 21
30 1
993 1
4 1
99...

result:

ok OK in maximum 1985 operations

Test #46:

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

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:

1980
2 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
995 1
5 1
9...

result:

ok OK in maximum 1980 operations

Test #47:

score: 0
Accepted
time: 34ms
memory: 8976kb

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:

1561
188 1
616 1
299 1
526 1
261 1
658 1
583 1
271 1
175 1
625 1
401 1
412 1
375 1
547 1
301 1
629 1
198 1
745 1
42 1
746 1
41 2
745 1
59 1
770 1
743 2
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
727 1
59 1
...

result:

ok OK in maximum 1561 operations

Test #48:

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

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:

1948
977 1
977 1
4 1
975 1
4 1
975 1
6 1
977 1
974 4
977 1
10 1
975 1
4 4
975 2
8 2
971 4
977 1
977 1
15 1
966 1
13 2
966 2
13 1
966 8
17 1
975 1
4 1
975 2
5 12
974 1
17 1
962 12
19 1
977 1
961 17
977 1
23 1
975 1
4 17
975 2
21 2
958 17
977 1
977 1
28 1
953 1
26 2
953 2
26 1
953 21
30 1
975 1
4 1
97...

result:

ok OK in maximum 1948 operations

Test #49:

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

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:

1584
2 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
796 1
5 1
7...

result:

ok OK in maximum 1584 operations

Test #50:

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

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:

1984
758 1
504 1
566 1
458 1
656 1
463 1
216 1
803 1
468 1
741 1
979 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
274 1
723 1
2...

result:

ok OK in maximum 1984 operations

Test #51:

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

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:

1741
874 1
874 1
4 1
872 1
4 1
872 1
6 1
874 1
871 4
874 1
10 1
872 1
4 4
872 2
8 2
868 4
874 1
874 1
15 1
863 1
13 2
863 2
13 1
863 8
17 1
872 1
4 1
872 2
5 12
871 1
17 1
859 12
19 1
874 1
858 17
874 1
23 1
872 1
4 17
872 2
21 2
855 17
874 1
874 1
28 1
850 1
26 2
850 2
26 1
850 21
30 1
872 1
4 1
87...

result:

ok OK in maximum 1741 operations

Test #52:

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

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:

1968
2 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
989 1
5 1
9...

result:

ok OK in maximum 1968 operations

Test #53:

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

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:

1977
964 1
271 1
348 1
757 1
613 1
618 1
377 1
619 1
376 2
618 1
408 1
964 1
616 2
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
408 1
586 1
4...

result:

ok OK in maximum 1977 operations

Test #54:

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

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:

1968
987 1
987 1
4 1
985 1
4 1
985 1
6 1
987 1
984 4
987 1
10 1
985 1
4 4
985 2
8 2
981 4
987 1
987 1
15 1
976 1
13 2
976 2
13 1
976 8
17 1
985 1
4 1
985 2
5 12
984 1
17 1
972 12
19 1
987 1
971 17
987 1
23 1
985 1
4 17
985 2
21 2
968 17
987 1
987 1
28 1
963 1
26 2
963 2
26 1
963 21
30 1
985 1
4 1
98...

result:

ok OK in maximum 1968 operations

Test #55:

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

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:

1979
2 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
993 1
5 1
9...

result:

ok OK in maximum 1979 operations

Test #56:

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

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:

1546
480 1
517 1
450 1
445 1
218 1
585 1
312 1
592 1
188 1
662 1
200 1
755 1
720 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696 1
83 1
696...

result:

ok OK in maximum 1546 operations

Test #57:

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

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:

1584
795 1
795 1
4 1
793 1
4 1
793 1
6 1
795 1
792 4
795 1
10 1
793 1
4 4
793 2
8 2
789 4
795 1
795 1
15 1
784 1
13 2
784 2
13 1
784 8
17 1
793 1
4 1
793 2
5 12
792 1
17 1
780 12
19 1
795 1
779 17
795 1
23 1
793 1
4 17
793 2
21 2
776 17
795 1
795 1
28 1
771 1
26 2
771 2
26 1
771 21
30 1
793 1
4 1
79...

result:

ok OK in maximum 1584 operations

Test #58:

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

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
2 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
5 1
664 1
568 1
104 1
4 1
664 1
3 2
663 1
5 1
661 2
664 1
7 2
659 5
7 2
659 1
7 2
659 1
7 2
659 5
7 2
659 1
7 2
659 1
7 2
659 5
7 2
659 1
7 2
659 1
7 2
659 5
7 2
659...

result:

ok OK in maximum 1321 operations

Test #59:

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

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:

1990
856 1
192 1
759 1
241 1
710 1
290 1
444 1
556 1
846 1
640 1
982 1
18 1
946 1
54 1
521 1
479 5
972 1
672 1
365 1
635 9
986 1
635 1
645 1
558 1
188 1
812 11
800 1
985 2
228 1
772 13
909 1
180 1
927 1
73 16
883 1
600 1
747 1
253 1
536 1
464 18
784 1
391 1
846 1
154 21
704 1
922 1
736 1
264 1
398 1...

result:

ok OK in maximum 1990 operations

Test #60:

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

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:

1988
851 1
994 1
706 1
590 1
704 1
295 2
507 1
548 1
947 1
52 4
897 1
207 1
965 1
34 1
901 1
98 6
403 1
912 1
951 1
48 1
693 1
306 9
826 1
656 1
528 1
471 12
835 1
236 1
941 1
144 14
915 1
330 2
768 1
283 15
950 1
749 3
315 1
684 16
437 1
818 1
763 1
236 20
934 1
572 1
832 1
355 1
327 1
672 22
814 1...

result:

ok OK in maximum 1988 operations

Test #61:

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

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:

1991
440 1
581 1
184 1
951 1
867 1
133 2
671 1
784 1
621 1
379 1
550 1
450 4
944 1
165 1
898 1
117 7
987 1
779 2
242 1
758 8
846 1
234 1
931 1
69 11
498 1
971 1
544 1
456 13
978 1
249 1
788 1
826 15
787 1
291 1
938 1
371 16
693 1
778 2
575 1
425 1
548 1
452 18
800 1
826 1
785 1
215 1
397 1
603 22
84...

result:

ok OK in maximum 1991 operations

Test #62:

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

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:

1988
683 1
714 1
818 1
181 1
910 1
913 1
178 1
821 3
904 1
755 1
360 1
639 1
345 1
654 5
857 1
960 1
982 1
17 1
190 1
809 8
737 1
973 1
600 1
399 1
300 1
699 11
716 1
649 1
647 1
440 14
913 1
437 2
663 1
336 15
884 1
256 1
876 1
505 18
868 1
622 1
527 1
599 19
874 1
219 2
926 1
73 21
953 1
445 1
624...

result:

ok OK in maximum 1988 operations

Test #63:

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

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:

1989
463 1
987 1
344 1
681 1
977 1
23 2
832 1
986 1
186 1
814 4
913 1
497 1
596 1
404 6
976 1
656 1
497 1
503 1
377 1
623 8
941 1
716 1
354 1
646 11
467 1
971 1
575 1
425 13
937 1
298 1
780 1
418 15
804 1
557 2
655 1
345 16
368 1
693 1
832 1
475 1
693 1
307 1
653 1
347 19
697 1
973 2
352 1
648 22
93...

result:

ok OK in maximum 1989 operations

Test #64:

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

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:

1988
790 1
389 1
490 1
981 1
756 1
243 1
555 1
444 1
531 1
468 2
698 1
310 1
996 1
3 6
153 1
996 1
857 1
142 8
904 1
451 1
653 1
346 10
962 1
897 1
174 1
923 1
54 1
945 12
952 1
449 1
611 1
889 14
950 1
725 1
828 1
171 1
824 1
175 2
342 1
657 16
692 1
916 1
411 1
588 21
796 1
551 1
674 1
761 23
565 ...

result:

ok OK in maximum 1988 operations

Test #65:

score: 0
Accepted
time: 34ms
memory: 11192kb

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:

1990
658 1
698 1
920 1
272 1
810 1
235 2
957 1
236 2
916 1
393 1
502 1
498 3
695 1
687 3
623 1
377 5
957 1
937 1
115 1
885 9
968 1
899 1
964 1
36 1
145 1
855 11
851 1
979 1
513 1
487 1
482 1
518 1
186 1
814 14
728 1
722 1
568 1
432 18
901 1
446 1
673 1
327 20
855 1
573 1
594 1
406 22
994 1
69 1
961 ...

result:

ok OK in maximum 1990 operations

Test #66:

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

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:

1988
637 1
531 1
888 1
253 1
862 1
789 1
349 1
856 2
992 1
105 1
905 1
790 4
305 1
728 2
971 1
28 6
885 1
701 1
583 1
416 1
422 1
577 9
878 1
630 1
596 1
403 1
503 1
496 12
670 1
855 1
488 1
511 15
776 1
695 1
872 1
127 1
545 1
454 17
883 1
482 1
653 1
346 20
992 1
273 1
923 1
76 1
756 1
243 22
699 ...

result:

ok OK in maximum 1988 operations

Test #67:

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

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:

1990
830 1
486 1
793 1
799 1
410 1
590 2
813 1
621 1
570 1
430 4
963 1
81 1
962 1
38 6
796 1
800 1
412 1
588 8
668 1
592 1
750 1
558 10
694 1
861 2
456 1
544 11
461 1
863 1
769 1
231 1
691 1
309 14
985 1
397 1
635 1
462 17
905 1
122 2
991 1
28 18
984 1
324 3
711 1
289 19
410 1
950 1
663 1
337 23
989...

result:

ok OK in maximum 1990 operations

Test #68:

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

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
582 1
947 1
635 1
364 1
828 1
444 1
729 1
270 3
329 1
703 1
971 1
28 5
894 1
354 1
757 1
242 7
609 1
745 1
653 1
493 9
854 1
720 2
498 1
501 1
435 1
564 10
909 1
118 1
985 1
38 14
977 1
994 2
42 1
957 15
664 1
911 1
441 1
573 18
986 1
131 2
900 1
99 19
520 1
739 1
761 1
238 22
797 1
666 1
917 1...

result:

ok OK in maximum 1989 operations

Test #69:

score: 0
Accepted
time: 38ms
memory: 11260kb

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:

1990
513 1
746 1
168 1
832 1
464 1
822 1
861 1
139 1
718 1
282 3
901 1
588 1
527 1
473 1
518 1
482 6
533 1
555 1
921 1
335 9
746 1
940 2
324 1
676 10
767 1
710 1
536 1
464 13
429 1
608 1
978 1
22 15
736 1
875 1
502 1
498 1
407 1
593 17
851 1
387 1
950 1
50 1
950 1
50 1
784 1
216 20
682 1
841 1
969 1...

result:

ok OK in maximum 1990 operations

Test #70:

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

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:

1988
695 1
761 1
966 1
579 1
455 1
544 2
933 1
699 1
370 1
629 4
727 1
556 1
721 1
278 6
984 1
607 1
415 1
584 8
799 1
324 1
905 1
647 1
333 1
666 10
449 1
611 2
950 1
49 12
558 1
601 1
854 1
145 15
314 1
933 1
793 1
206 1
769 1
230 17
854 1
789 1
847 1
152 1
376 1
623 20
748 1
504 1
769 1
490 23
74...

result:

ok OK in maximum 1988 operations

Test #71:

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

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:

1990
855 1
389 1
579 1
421 1
988 1
763 1
252 1
786 3
964 1
819 2
221 1
779 4
341 1
896 1
770 1
230 7
464 1
895 1
650 1
350 9
789 1
443 1
995 1
151 1
634 1
366 11
857 1
572 2
584 1
416 13
915 1
172 1
929 1
71 16
913 1
178 1
927 1
73 18
857 1
553 1
610 1
390 20
908 1
619 1
644 1
356 1
570 1
430 1
497 ...

result:

ok OK in maximum 1990 operations

Test #72:

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

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:

1988
898 1
576 1
38 1
961 1
471 1
777 1
753 1
246 3
891 1
844 1
684 1
315 1
627 1
372 1
270 1
729 5
489 1
593 1
925 1
74 9
371 1
925 1
713 1
356 11
931 1
603 2
476 1
523 12
809 1
234 1
970 1
783 15
962 1
951 1
725 1
274 1
333 1
666 2
104 1
895 16
915 1
963 1
143 1
856 1
142 1
857 21
520 1
594 1
908 ...

result:

ok OK in maximum 1988 operations