QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168820#6545. Connect the DotsPhantomThresholdAC ✓44ms9336kbC++203.5kb2023-09-08 22:47:472023-09-08 22:47:48

Judging History

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

  • [2023-09-08 22:47:48]
  • 评测
  • 测评结果:AC
  • 用时:44ms
  • 内存:9336kb
  • [2023-09-08 22:47:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
//	cin.tie(0);
	int T;
	cin>>T;
	while(T--)
	{
		int n,m;
		cin>>n>>m;
		vector<pair<int,int>> ans;
		vector<int> now;
		vector<int> c(n+5);
		int nowc=0;
		for(int i=1;i<=n;i++)
		{
			cin>>c[i];
//			cerr<<"? "<<i<<' '<<nowc<<' '<<now.size()<<endl;
			if(nowc==0)
			{
				now.push_back(i);
				nowc++;
			}
			else if(nowc==1)
			{
				if(c[i]==c[now.back()])
					now.push_back(i);
				else
				{
					nowc++;
					int u=0;
					while(not now.empty())
					{
						u=now.back();now.pop_back();
						ans.emplace_back(u,i);
					}
					now.push_back(u);
					now.push_back(i);
				}
			}
			else if(nowc==2)
			{
				int bid=now.size()-1;
				if(c[i]==c[now[bid]])
				{
					ans.emplace_back(now[bid-1],i);
					now.pop_back();
					now.push_back(i);
				}
				else if(c[i]==c[now[bid-1]])
				{
					ans.emplace_back(now[bid],i);
					now.push_back(i);
				}
				else
				{
					nowc++;
					int u=0;
					while(now.size()>1u)
					{
						u=now.back();now.pop_back();
						ans.emplace_back(u,i);
					}
					now.push_back(u);
					now.push_back(i);
				}
			}
			else
			{
				if(c[i]!=c[now[0]] and c[i]!=c[now[1]] and c[i]!=c[now[2]])
				{
					if(now.size()==4u)
					{
						ans.emplace_back(now.back(),i);
						now.pop_back();
					}
					ans.emplace_back(now.back(),i);now.pop_back();
					ans.emplace_back(now.back(),i);
					now.push_back(i);
				}
				else
				{
					if(now.size()==3u)
					{
						if(c[i]==c[now[2]])
						{
							ans.emplace_back(now[1],i);
							now.pop_back();
							now.push_back(i);
						}
						else
						{
							ans.emplace_back(now.back(),i);
							now.push_back(i);
						}
					}
					else
					{
						if(c[now[3]]==c[now[0]])
						{
							if(c[i]==c[now[0]])
							{
								ans.emplace_back(now[2],i);
								now.pop_back();
								now.push_back(i);
							}
							else if(c[i]==c[now[1]])
							{
								ans.emplace_back(now[2],i);
								ans.emplace_back(now[3],i);
								now.pop_back();
								now.push_back(i);
							}
							else
							{
								ans.emplace_back(now[1],now[3]);
								ans.emplace_back(now[1],i);
								ans.emplace_back(now[3],i);
								now.pop_back();
								now.pop_back();
								now.push_back(i);
							}
						}
						else if(c[now[3]]==c[now[1]])
						{
							if(c[i]==c[now[0]])
							{
								ans.emplace_back(now[2],i);
								ans.emplace_back(now[3],i);
								now.pop_back();
								now.push_back(i);
							}
							else if(c[i]==c[now[1]])
							{
								ans.emplace_back(now[2],i);
								now.pop_back();
								now.push_back(i);
							}
							else
							{
								ans.emplace_back(now[0],now[2]);
								ans.emplace_back(now[0],now[3]);
								ans.emplace_back(now[3],i);
								now[1]=now[3];
								now.pop_back();
								now.pop_back();
								now.push_back(i);
							}
						}
					}
				}
			}
		}
		//fin
		if(nowc==2)
		{
			int i=now.back();now.pop_back();now.pop_back();
			while(not now.empty())
			{
				if(c[i]!=c[now.back()])
					ans.emplace_back(now.back(),i);
				now.pop_back();
			}
		}
		else
		{
			ans.emplace_back(now[0],now[2]);
			if(now.size()==4u)
			{
				if(c[now.front()]!=c[now.back()])ans.emplace_back(now.front(),now.back());
			}
		}
		cout<<ans.size()<<"\n";
		for(auto [u,v]:ans)
			cout<<u<<' '<<v<<"\n";
	}
	return 0;
}

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

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #2:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #3:

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

input:

10
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1

output:

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

result:

ok all 10 test passed

Test #4:

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

input:

10
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2 1 2 2 2 2
7 2
2 2 1 2 1 2 1
7 2
2 1 1 2 1 2 2
7 2
2 2 1 2 1 1 2

output:

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

result:

ok all 10 test passed

Test #5:

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

input:

10
9 2
1 1 1 2 1 2 2 1 2
9 2
1 2 1 1 2 2 2 2 1
9 2
2 1 2 1 1 2 1 2 1
9 2
1 1 2 1 1 1 1 2 2
9 2
1 1 2 2 1 2 1 2 2
9 2
2 2 1 2 1 2 2 2 2
9 2
1 1 2 2 2 1 2 1 2
9 2
1 1 2 1 1 2 2 2 2
9 2
1 1 1 1 2 1 1 2 1
9 2
2 1 2 2 1 1 2 2 1

output:

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

result:

ok all 10 test passed

Test #6:

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

input:

1
5 2
1 1 2 2 1

output:

4
2 3
1 3
1 4
4 5

result:

ok all 1 test passed

Test #7:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #8:

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

input:

1
9 2
2 1 1 2 1 1 1 2 2

output:

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

result:

ok all 1 test passed

Test #9:

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

input:

4
20 2
2 1 1 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2
20 2
2 1 2 2 2 1 1 2 2 2 1 2 2 2 2 1 2 2 1 2
20 2
2 2 1 1 2 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1
20 2
2 1 2 2 2 1 2 2 1 1 1 2 1 2 2 1 2 1 1 2

output:

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

result:

ok all 4 test passed

Test #10:

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

input:

4
100 2
2 2 2 1 2 1 1 1 1 2 2 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 1 2 2 2 1 2 2 2 1 1 1 2 1 2 1 2 2 1 2 2 1 1 2 1 1 1 1 2 2 1 2 1 1 2 2 1 2 2 1 2 1 2 2 2
100 2
2 1 1 1 1 1 2 2 2 1 2 1 2 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 1 ...

output:

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

result:

ok all 4 test passed

Test #11:

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

input:

1
100 2
2 2 1 1 2 2 2 1 1 2 1 1 1 2 2 1 2 2 2 1 1 2 2 1 1 2 2 2 1 2 1 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2 2 2 2 1 2 1 2 1 1 2 1 1 1 1 1 2 2 2 1 1 2 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 1 2 2 1 2 1 2 1 2 2 2 1 2 2 2 1 1

output:

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

result:

ok all 1 test passed

Test #12:

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

input:

1
100 2
1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1

output:

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

result:

ok all 1 test passed

Test #13:

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

input:

1
200 2
1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 ...

output:

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

result:

ok all 1 test passed

Test #14:

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

input:

4
7 3
2 2 3 1 3 1 1
7 3
3 1 2 2 3 1 3
7 3
2 1 3 3 2 3 2
7 3
3 2 3 1 3 1 3

output:

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

result:

ok all 4 test passed

Test #15:

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

input:

4
20 3
1 2 3 1 3 2 1 1 2 3 1 2 2 1 1 2 2 1 2 2
20 3
1 2 1 2 3 3 2 1 1 3 3 2 2 1 2 3 1 1 2 2
20 3
3 1 1 3 3 1 3 2 1 1 2 3 3 3 1 1 2 1 1 1
20 3
3 2 2 1 3 1 1 3 3 2 2 2 1 1 2 1 2 2 2 2

output:

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

result:

ok all 4 test passed

Test #16:

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

input:

4
100 3
1 3 3 2 1 1 1 1 3 1 1 2 2 3 2 3 3 1 1 1 1 1 3 2 2 3 2 1 3 3 3 1 1 2 3 1 2 1 2 3 2 1 2 2 2 3 2 3 3 2 3 1 1 2 3 1 3 1 3 3 2 1 1 3 3 1 2 2 2 2 3 1 2 3 3 3 3 2 3 1 3 1 2 1 1 3 2 1 2 1 1 1 1 1 1 3 2 1 3 1
100 3
2 1 3 3 1 3 3 3 1 2 1 1 2 3 1 1 1 2 3 2 3 3 3 2 2 1 2 2 2 1 1 1 1 2 3 3 2 3 1 3 1 3 3 ...

output:

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

result:

ok all 4 test passed

Test #17:

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

input:

1
200 3
1 3 3 3 2 3 3 3 1 3 3 3 1 3 1 1 2 2 2 3 2 2 3 3 2 2 2 1 3 1 3 1 3 3 1 1 1 2 2 1 2 1 3 3 3 3 3 1 2 1 1 1 3 3 3 1 1 2 2 1 1 3 2 3 2 1 3 3 1 1 3 1 2 1 2 2 2 1 3 2 2 1 3 1 2 3 2 2 1 2 1 3 3 3 2 1 1 3 3 2 2 3 2 3 3 1 2 3 1 2 2 3 2 2 1 2 2 1 2 3 1 2 2 3 1 2 3 1 2 1 1 3 1 3 1 3 2 1 3 2 1 2 2 1 3 2 ...

output:

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

result:

ok all 1 test passed

Test #18:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #19:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #20:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #21:

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

input:

1
200 200
77 83 76 63 45 147 185 154 69 89 78 59 118 39 161 48 165 99 120 68 74 159 162 43 168 30 82 199 101 103 33 61 31 34 180 88 149 3 71 114 166 64 145 23 15 54 97 111 75 72 38 112 129 122 107 148 79 25 2 13 109 10 60 173 20 44 117 94 175 26 121 93 153 151 172 108 194 73 140 135 57 18 164 171 13...

output:

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

result:

ok all 1 test passed

Test #22:

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

input:

4
20 4
2 2 4 3 1 2 1 3 2 2 1 3 3 4 4 3 2 2 2 3
20 4
3 3 3 1 1 3 2 2 2 2 1 4 4 2 1 4 3 4 4 3
20 4
1 1 3 4 3 3 1 3 1 4 2 1 1 2 2 4 3 4 4 2
20 4
3 4 3 3 1 4 4 2 2 2 4 1 1 3 4 3 4 2 2 3

output:

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

result:

ok all 4 test passed

Test #23:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #24:

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

input:

1
300 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #25:

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

input:

1
100 3
1 2 2 3 3 1 2 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 1 2 3 3 1 1 2 2 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1

output:

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

result:

ok all 1 test passed

Test #26:

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

input:

1
100 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3

output:

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

result:

ok all 1 test passed

Test #27:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #28:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #29:

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

input:

1
1000 2
2 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1...

output:

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

result:

ok all 1 test passed

Test #30:

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

input:

1
3000 2
1 2 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 2 1 1 2 2 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 2 2 2 1 2 1 1 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 1 1 2 1 2 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 2 1 2 1 1 2 2 1 2 1 1 2 2 2 2 1 2 2 2 1 2 1 1 2 1 2 2 2...

output:

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

result:

ok all 1 test passed

Test #31:

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

input:

1
2000 2
2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2...

output:

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

result:

ok all 1 test passed

Test #32:

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

input:

1
1000 2
2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2...

output:

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

result:

ok all 1 test passed

Test #33:

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

input:

1
1000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

999
96 97
95 97
94 97
93 97
92 97
91 97
90 97
89 97
88 97
87 97
86 97
85 97
84 97
83 97
82 97
81 97
80 97
79 97
78 97
77 97
76 97
75 97
74 97
73 97
72 97
71 97
70 97
69 97
68 97
67 97
66 97
65 97
64 97
63 97
62 97
61 97
60 97
59 97
58 97
57 97
56 97
55 97
54 97
53 97
52 97
51 97
50 97
49 97
48 97
47...

result:

ok all 1 test passed

Test #34:

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

input:

1
22000 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 ...

output:

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

result:

ok all 1 test passed

Test #35:

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

input:

1
12000 2
2 1 1 2 2 1 2 1 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 2 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 1 2 2 1 1 2 2 1 2 2 2 2 1 2 2 2 2 2 2 1 1 1 2 2 2 2 2 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 2 1 2 2 2 2 ...

output:

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

result:

ok all 1 test passed

Test #36:

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

input:

1
300 150
21 91 61 3 124 47 39 37 35 86 28 74 50 79 125 146 38 32 60 111 114 29 103 121 126 55 61 47 149 9 149 124 92 29 78 104 54 34 54 27 1 59 44 123 9 36 29 25 124 88 125 145 113 137 119 108 27 132 124 114 143 143 77 97 84 83 40 132 77 62 72 37 51 139 56 80 34 87 69 131 100 57 120 148 42 42 123 2...

output:

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

result:

ok all 1 test passed

Test #37:

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

input:

1
1000 3
3 2 3 3 2 1 2 1 2 1 2 3 1 1 2 3 1 3 3 2 1 3 1 1 3 3 1 2 1 2 1 1 3 2 2 1 2 3 2 2 3 1 2 2 1 1 2 2 1 2 1 1 3 1 1 3 3 2 1 2 3 2 1 3 3 2 2 2 3 2 3 3 1 2 1 1 2 1 2 3 1 2 1 3 1 3 3 1 2 1 1 2 2 1 1 2 2 2 1 1 3 1 1 1 3 2 2 1 1 3 2 3 1 2 3 3 3 2 3 3 1 2 3 3 2 2 2 2 2 1 2 3 3 3 2 2 3 3 1 1 2 3 1 1 1 2...

output:

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

result:

ok all 1 test passed

Test #38:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #39:

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

input:

1
30000 3
3 3 1 1 3 2 2 2 3 2 2 2 3 3 3 2 3 1 2 2 1 1 3 1 1 3 3 1 2 2 3 1 1 3 3 3 3 1 2 2 2 3 3 2 1 3 1 2 1 1 2 2 2 2 1 3 1 2 1 1 2 2 3 2 1 2 2 2 1 2 3 2 2 2 1 3 1 3 3 3 2 2 3 1 3 2 3 2 2 3 3 2 2 1 2 3 1 1 2 1 3 2 3 2 3 3 3 2 3 2 1 3 2 3 1 3 3 3 2 3 2 1 2 1 3 2 2 1 1 1 1 2 1 3 2 2 1 1 2 1 3 1 1 2 1 ...

output:

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

result:

ok all 1 test passed

Test #40:

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

input:

1
15000 3
1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 ...

output:

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

result:

ok all 1 test passed

Test #41:

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

input:

1
13998 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

13998
1263 1264
1262 1264
1261 1264
1260 1264
1259 1264
1258 1264
1257 1264
1256 1264
1255 1264
1254 1264
1253 1264
1252 1264
1251 1264
1250 1264
1249 1264
1248 1264
1247 1264
1246 1264
1245 1264
1244 1264
1243 1264
1242 1264
1241 1264
1240 1264
1239 1264
1238 1264
1237 1264
1236 1264
1235 1264
1234...

result:

ok all 1 test passed

Test #42:

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

input:

1
10000 5000
1401 1401 1402 1402 1403 1403 1404 1404 1405 1405 1406 1406 1407 1407 1408 1408 1409 1409 1410 1410 1411 1411 1412 1412 1413 1413 1414 1414 1415 1415 1416 1416 1417 1417 1418 1418 1419 1419 1420 1420 1421 1421 1422 1422 1423 1423 1424 1424 1425 1425 1426 1426 1427 1427 1428 1428 1429 14...

output:

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

result:

ok all 1 test passed

Test #43:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #44:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #45:

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

input:

10
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1

output:

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

result:

ok all 10 test passed

Test #46:

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

input:

10
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2 1 2 2 2 2
7 2
2 2 1 2 1 2 1
7 2
2 1 1 2 1 2 2
7 2
2 2 1 2 1 1 2

output:

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

result:

ok all 10 test passed

Test #47:

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

input:

10
9 2
1 1 1 2 1 2 2 1 2
9 2
1 2 1 1 2 2 2 2 1
9 2
2 1 2 1 1 2 1 2 1
9 2
1 1 2 1 1 1 1 2 2
9 2
1 1 2 2 1 2 1 2 2
9 2
2 2 1 2 1 2 2 2 2
9 2
1 1 2 2 2 1 2 1 2
9 2
1 1 2 1 1 2 2 2 2
9 2
1 1 1 1 2 1 1 2 1
9 2
2 1 2 2 1 1 2 2 1

output:

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

result:

ok all 10 test passed

Test #48:

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

input:

1
5 2
1 1 2 2 1

output:

4
2 3
1 3
1 4
4 5

result:

ok all 1 test passed

Test #49:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #50:

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

input:

1
9 2
2 1 1 2 1 1 1 2 2

output:

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

result:

ok all 1 test passed

Test #51:

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

input:

4
20 2
2 1 1 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2
20 2
2 1 2 2 2 1 1 2 2 2 1 2 2 2 2 1 2 2 1 2
20 2
2 2 1 1 2 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1
20 2
2 1 2 2 2 1 2 2 1 1 1 2 1 2 2 1 2 1 1 2

output:

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

result:

ok all 4 test passed

Test #52:

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

input:

4
100 2
2 2 2 1 2 1 1 1 1 2 2 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 1 2 2 2 1 2 2 2 1 1 1 2 1 2 1 2 2 1 2 2 1 1 2 1 1 1 1 2 2 1 2 1 1 2 2 1 2 2 1 2 1 2 2 2
100 2
2 1 1 1 1 1 2 2 2 1 2 1 2 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 1 ...

output:

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

result:

ok all 4 test passed

Test #53:

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

input:

1
300 2
2 2 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 2 2 2 2 2 1 1 2 1 1 2 2 1 2 2 2 1 1 2 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 2 1 ...

output:

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

result:

ok all 1 test passed

Test #54:

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

input:

1
300 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 ...

output:

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

result:

ok all 1 test passed

Test #55:

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

input:

1
300 2
2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 ...

output:

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

result:

ok all 1 test passed

Test #56:

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

input:

4
7 3
2 2 3 1 3 1 1
7 3
3 1 2 2 3 1 3
7 3
2 1 3 3 2 3 2
7 3
3 2 3 1 3 1 3

output:

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

result:

ok all 4 test passed

Test #57:

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

input:

4
20 3
1 2 3 1 3 2 1 1 2 3 1 2 2 1 1 2 2 1 2 2
20 3
1 2 1 2 3 3 2 1 1 3 3 2 2 1 2 3 1 1 2 2
20 3
3 1 1 3 3 1 3 2 1 1 2 3 3 3 1 1 2 1 1 1
20 3
3 2 2 1 3 1 1 3 3 2 2 2 1 1 2 1 2 2 2 2

output:

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

result:

ok all 4 test passed

Test #58:

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

input:

4
100 3
1 3 3 2 1 1 1 1 3 1 1 2 2 3 2 3 3 1 1 1 1 1 3 2 2 3 2 1 3 3 3 1 1 2 3 1 2 1 2 3 2 1 2 2 2 3 2 3 3 2 3 1 1 2 3 1 3 1 3 3 2 1 1 3 3 1 2 2 2 2 3 1 2 3 3 3 3 2 3 1 3 1 2 1 1 3 2 1 2 1 1 1 1 1 1 3 2 1 3 1
100 3
2 1 3 3 1 3 3 3 1 2 1 1 2 3 1 1 1 2 3 2 3 3 3 2 2 1 2 2 2 1 1 1 1 2 3 3 2 3 1 3 1 3 3 ...

output:

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

result:

ok all 4 test passed

Test #59:

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

input:

1
300 3
2 1 2 1 2 2 1 2 3 1 1 2 3 3 3 2 3 1 1 2 1 1 1 3 3 3 2 1 1 2 2 1 1 3 2 3 1 3 2 2 2 3 1 3 2 1 3 1 1 3 1 2 1 2 1 3 2 1 3 3 1 2 1 2 2 1 1 3 2 1 2 3 1 2 2 2 1 3 3 1 2 3 1 3 1 1 3 1 3 1 2 1 1 3 1 3 3 2 2 2 1 2 1 2 2 3 2 1 3 3 1 2 1 3 2 3 1 2 1 1 2 2 1 1 2 3 1 1 3 2 3 3 1 1 1 3 2 1 1 2 1 3 3 2 3 1 ...

output:

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

result:

ok all 1 test passed

Test #60:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #61:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #62:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #63:

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

input:

1
300 300
77 46 15 213 13 258 21 73 122 114 55 238 294 179 97 175 25 104 83 153 80 36 135 216 252 100 50 169 5 211 253 146 223 82 76 44 90 288 261 174 14 222 127 298 203 151 286 178 68 28 85 75 42 167 112 226 106 123 220 230 242 160 132 2 161 232 229 291 22 170 158 57 193 263 266 71 184 289 195 136 ...

output:

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

result:

ok all 1 test passed

Test #64:

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

input:

4
20 4
2 2 4 3 1 2 1 3 2 2 1 3 3 4 4 3 2 2 2 3
20 4
3 3 3 1 1 3 2 2 2 2 1 4 4 2 1 4 3 4 4 3
20 4
1 1 3 4 3 3 1 3 1 4 2 1 1 2 2 4 3 4 4 2
20 4
3 4 3 3 1 4 4 2 2 2 4 1 1 3 4 3 4 2 2 3

output:

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

result:

ok all 4 test passed

Test #65:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #66:

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

input:

1
300 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #67:

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

input:

1
300 3
2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 ...

output:

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

result:

ok all 1 test passed

Test #68:

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

input:

1
300 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #69:

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

input:

1
300 10
9 9 9 9 5 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4...

output:

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

result:

ok all 1 test passed

Test #70:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #71:

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

input:

1
1000 2
2 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1...

output:

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

result:

ok all 1 test passed

Test #72:

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

input:

1
3000 2
1 2 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 2 1 1 2 2 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 2 2 2 1 2 1 1 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 1 1 2 1 2 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 2 1 2 1 1 2 2 1 2 1 1 2 2 2 2 1 2 2 2 1 2 1 1 2 1 2 2 2...

output:

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

result:

ok all 1 test passed

Test #73:

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

input:

1
2000 2
2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2...

output:

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

result:

ok all 1 test passed

Test #74:

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

input:

1
1000 2
2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2...

output:

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

result:

ok all 1 test passed

Test #75:

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

input:

1
1000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

999
96 97
95 97
94 97
93 97
92 97
91 97
90 97
89 97
88 97
87 97
86 97
85 97
84 97
83 97
82 97
81 97
80 97
79 97
78 97
77 97
76 97
75 97
74 97
73 97
72 97
71 97
70 97
69 97
68 97
67 97
66 97
65 97
64 97
63 97
62 97
61 97
60 97
59 97
58 97
57 97
56 97
55 97
54 97
53 97
52 97
51 97
50 97
49 97
48 97
47...

result:

ok all 1 test passed

Test #76:

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

input:

1
22000 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 ...

output:

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

result:

ok all 1 test passed

Test #77:

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

input:

1
12000 2
2 1 1 2 2 1 2 1 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 2 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 1 2 2 1 1 2 2 1 2 2 2 2 1 2 2 2 2 2 2 1 1 1 2 2 2 2 2 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 2 1 2 2 2 2 ...

output:

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

result:

ok all 1 test passed

Test #78:

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

input:

1
300 150
21 91 61 3 124 47 39 37 35 86 28 74 50 79 125 146 38 32 60 111 114 29 103 121 126 55 61 47 149 9 149 124 92 29 78 104 54 34 54 27 1 59 44 123 9 36 29 25 124 88 125 145 113 137 119 108 27 132 124 114 143 143 77 97 84 83 40 132 77 62 72 37 51 139 56 80 34 87 69 131 100 57 120 148 42 42 123 2...

output:

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

result:

ok all 1 test passed

Test #79:

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

input:

1
1000 3
3 2 3 3 2 1 2 1 2 1 2 3 1 1 2 3 1 3 3 2 1 3 1 1 3 3 1 2 1 2 1 1 3 2 2 1 2 3 2 2 3 1 2 2 1 1 2 2 1 2 1 1 3 1 1 3 3 2 1 2 3 2 1 3 3 2 2 2 3 2 3 3 1 2 1 1 2 1 2 3 1 2 1 3 1 3 3 1 2 1 1 2 2 1 1 2 2 2 1 1 3 1 1 1 3 2 2 1 1 3 2 3 1 2 3 3 3 2 3 3 1 2 3 3 2 2 2 2 2 1 2 3 3 3 2 2 3 3 1 1 2 3 1 1 1 2...

output:

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

result:

ok all 1 test passed

Test #80:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #81:

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

input:

1
30000 3
3 3 1 1 3 2 2 2 3 2 2 2 3 3 3 2 3 1 2 2 1 1 3 1 1 3 3 1 2 2 3 1 1 3 3 3 3 1 2 2 2 3 3 2 1 3 1 2 1 1 2 2 2 2 1 3 1 2 1 1 2 2 3 2 1 2 2 2 1 2 3 2 2 2 1 3 1 3 3 3 2 2 3 1 3 2 3 2 2 3 3 2 2 1 2 3 1 1 2 1 3 2 3 2 3 3 3 2 3 2 1 3 2 3 1 3 3 3 2 3 2 1 2 1 3 2 2 1 1 1 1 2 1 3 2 2 1 1 2 1 3 1 1 2 1 ...

output:

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

result:

ok all 1 test passed

Test #82:

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

input:

1
15000 3
1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 ...

output:

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

result:

ok all 1 test passed

Test #83:

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

input:

1
13998 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

13998
1263 1264
1262 1264
1261 1264
1260 1264
1259 1264
1258 1264
1257 1264
1256 1264
1255 1264
1254 1264
1253 1264
1252 1264
1251 1264
1250 1264
1249 1264
1248 1264
1247 1264
1246 1264
1245 1264
1244 1264
1243 1264
1242 1264
1241 1264
1240 1264
1239 1264
1238 1264
1237 1264
1236 1264
1235 1264
1234...

result:

ok all 1 test passed

Test #84:

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

input:

1
10000 5000
1401 1401 1402 1402 1403 1403 1404 1404 1405 1405 1406 1406 1407 1407 1408 1408 1409 1409 1410 1410 1411 1411 1412 1412 1413 1413 1414 1414 1415 1415 1416 1416 1417 1417 1418 1418 1419 1419 1420 1420 1421 1421 1422 1422 1423 1423 1424 1424 1425 1425 1426 1426 1427 1427 1428 1428 1429 14...

output:

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

result:

ok all 1 test passed

Test #85:

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

input:

101
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3
2 2
1 2
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 ...

output:

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

result:

ok all 101 test passed

Test #86:

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

input:

87
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3
2 2
1 2
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2...

output:

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

result:

ok all 87 test passed

Test #87:

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

input:

101
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3
2 2
1 2
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 ...

output:

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

result:

ok all 101 test passed

Test #88:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #89:

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

input:

1
100000 2
2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1...

output:

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

result:

ok all 1 test passed

Test #90:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #91:

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

input:

10
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1

output:

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

result:

ok all 10 test passed

Test #92:

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

input:

10
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2 1 2 2 2 2
7 2
2 2 1 2 1 2 1
7 2
2 1 1 2 1 2 2
7 2
2 2 1 2 1 1 2

output:

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

result:

ok all 10 test passed

Test #93:

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

input:

10
9 2
1 1 1 2 1 2 2 1 2
9 2
1 2 1 1 2 2 2 2 1
9 2
2 1 2 1 1 2 1 2 1
9 2
1 1 2 1 1 1 1 2 2
9 2
1 1 2 2 1 2 1 2 2
9 2
2 2 1 2 1 2 2 2 2
9 2
1 1 2 2 2 1 2 1 2
9 2
1 1 2 1 1 2 2 2 2
9 2
1 1 1 1 2 1 1 2 1
9 2
2 1 2 2 1 1 2 2 1

output:

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

result:

ok all 10 test passed

Test #94:

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

input:

1
5 2
1 1 2 2 1

output:

4
2 3
1 3
1 4
4 5

result:

ok all 1 test passed

Test #95:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #96:

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

input:

1
9 2
2 1 1 2 1 1 1 2 2

output:

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

result:

ok all 1 test passed

Test #97:

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

input:

10
20 2
2 1 1 1 2 2 1 1 2 1 2 1 2 1 1 2 1 2 2 2
20 2
2 1 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 1 2
20 2
2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 2 1 2 2 2
20 2
2 2 1 2 2 2 2 1 1 2 2 2 1 2 1 1 1 2 1 2
20 2
1 1 2 2 2 1 2 1 1 2 1 2 2 2 1 1 2 1 1 1
20 2
2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 2 1
20 2
1 1 1 2 1 2 2 1 2 1 2 ...

output:

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

result:

ok all 10 test passed

Test #98:

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

input:

10
100 2
2 1 1 2 2 1 1 2 2 1 2 1 1 2 1 1 2 1 2 2 2 1 2 2 1 1 2 1 1 2 2 2 2 2 1 1 1 1 2 2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 2 2 1 1 2 1 2 1 1 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 2 1 2 1 1 1 1 2 2 2 2 1 1
100 2
1 1 2 1 1 1 1 1 2 2 1 2 2 1 1 1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 1 2 1 2 1 2 2 1 2 2 2 1 2...

output:

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

result:

ok all 10 test passed

Test #99:

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

input:

1
300 2
2 2 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 2 2 2 2 2 1 1 2 1 1 2 2 1 2 2 2 1 1 2 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 2 1 ...

output:

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

result:

ok all 1 test passed

Test #100:

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

input:

10
7 3
2 3 1 2 2 3 3
7 3
1 2 3 1 3 3 2
7 3
1 3 1 2 1 2 1
7 3
3 1 2 3 1 2 2
7 3
1 2 3 2 1 1 2
7 3
3 2 2 3 3 1 1
7 3
3 1 2 2 1 3 3
7 3
3 3 3 2 2 1 1
7 3
2 1 3 1 3 1 2
7 3
3 2 3 1 1 1 1

output:

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

result:

ok all 10 test passed

Test #101:

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

input:

10
20 3
2 1 2 1 3 2 2 1 3 3 3 1 3 3 2 3 3 3 1 2
20 3
3 2 2 1 2 1 3 1 3 1 3 2 2 2 1 2 2 1 1 3
20 3
3 3 2 2 2 2 3 1 2 1 3 1 1 1 2 1 1 3 3 2
20 3
1 1 1 3 2 3 2 3 3 1 3 2 2 2 2 3 3 2 1 1
20 3
2 3 1 2 3 3 3 1 2 3 1 3 2 3 2 2 3 3 1 1
20 3
2 3 2 2 1 3 1 2 1 3 3 1 3 1 3 1 1 3 1 2
20 3
3 1 2 1 3 3 3 1 3 3 1 ...

output:

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

result:

ok all 10 test passed

Test #102:

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

input:

10
100 3
3 1 3 3 2 3 1 3 3 3 1 2 1 1 1 2 2 2 1 1 1 2 3 1 2 1 3 2 1 2 2 2 2 1 3 1 3 3 1 3 2 2 1 1 3 3 1 1 3 2 1 1 1 2 1 1 3 2 2 3 2 3 1 3 3 3 3 1 2 3 1 2 1 3 1 2 3 2 1 3 3 1 1 3 2 1 2 3 2 2 3 3 1 1 3 3 2 1 2 2
100 3
1 2 3 2 3 2 1 3 2 1 2 2 1 3 2 1 3 2 2 1 1 3 1 3 3 2 3 2 2 2 3 2 1 1 1 3 3 3 1 1 2 1 3...

output:

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

result:

ok all 10 test passed

Test #103:

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

input:

1
300 3
2 1 2 1 2 2 1 2 3 1 1 2 3 3 3 2 3 1 1 2 1 1 1 3 3 3 2 1 1 2 2 1 1 3 2 3 1 3 2 2 2 3 1 3 2 1 3 1 1 3 1 2 1 2 1 3 2 1 3 3 1 2 1 2 2 1 1 3 2 1 2 3 1 2 2 2 1 3 3 1 2 3 1 3 1 1 3 1 3 1 2 1 1 3 1 3 3 2 2 2 1 2 1 2 2 3 2 1 3 3 1 2 1 3 2 3 1 2 1 1 2 2 1 1 2 3 1 1 3 2 3 3 1 1 1 3 2 1 1 2 1 3 3 2 3 1 ...

output:

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

result:

ok all 1 test passed

Test #104:

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

input:

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

output:

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

result:

ok all 10 test passed

Test #105:

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

input:

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

output:

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

result:

ok all 10 test passed

Test #106:

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

input:

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

output:

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

result:

ok all 10 test passed

Test #107:

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

input:

1
300 300
77 46 15 213 13 258 21 73 122 114 55 238 294 179 97 175 25 104 83 153 80 36 135 216 252 100 50 169 5 211 253 146 223 82 76 44 90 288 261 174 14 222 127 298 203 151 286 178 68 28 85 75 42 167 112 226 106 123 220 230 242 160 132 2 161 232 229 291 22 170 158 57 193 263 266 71 184 289 195 136 ...

output:

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

result:

ok all 1 test passed

Test #108:

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

input:

10
20 4
4 1 1 3 1 4 2 3 2 2 1 3 2 2 3 2 3 2 2 1
20 4
4 1 3 2 4 4 4 3 2 4 1 4 3 4 2 2 3 4 1 4
20 4
4 2 2 1 3 1 2 4 1 2 1 2 1 3 1 3 4 4 1 3
20 4
1 1 1 3 4 1 4 2 3 1 4 4 2 4 2 1 2 3 4 1
20 4
1 2 3 1 1 1 3 1 1 2 1 4 2 4 3 3 3 1 3 2
20 4
1 1 4 2 1 3 1 1 3 1 3 4 2 1 2 4 2 3 1 4
20 4
2 3 2 2 1 1 2 2 2 2 4 ...

output:

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

result:

ok all 10 test passed

Test #109:

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

input:

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

output:

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

result:

ok all 10 test passed

Test #110:

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

input:

1
300 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 ...

output:

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

result:

ok all 1 test passed

Test #111:

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

input:

1
300 2
2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 ...

output:

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

result:

ok all 1 test passed

Test #112:

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

input:

1
300 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #113:

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

input:

1
300 3
2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 ...

output:

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

result:

ok all 1 test passed

Test #114:

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

input:

1
300 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #115:

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

input:

1
300 10
9 9 9 9 5 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4...

output:

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

result:

ok all 1 test passed

Test #116:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #117:

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

input:

1
300 150
21 91 61 3 124 47 39 37 35 86 28 74 50 79 125 146 38 32 60 111 114 29 103 121 126 55 61 47 149 9 149 124 92 29 78 104 54 34 54 27 1 59 44 123 9 36 29 25 124 88 125 145 113 137 119 108 27 132 124 114 143 143 77 97 84 83 40 132 77 62 72 37 51 139 56 80 34 87 69 131 100 57 120 148 42 42 123 2...

output:

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

result:

ok all 1 test passed

Test #118:

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

input:

1
1000 3
3 2 3 3 2 1 2 1 2 1 2 3 1 1 2 3 1 3 3 2 1 3 1 1 3 3 1 2 1 2 1 1 3 2 2 1 2 3 2 2 3 1 2 2 1 1 2 2 1 2 1 1 3 1 1 3 3 2 1 2 3 2 1 3 3 2 2 2 3 2 3 3 1 2 1 1 2 1 2 3 1 2 1 3 1 3 3 1 2 1 1 2 2 1 1 2 2 2 1 1 3 1 1 1 3 2 2 1 1 3 2 3 1 2 3 3 3 2 3 3 1 2 3 3 2 2 2 2 2 1 2 3 3 3 2 2 3 3 1 1 2 3 1 1 1 2...

output:

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

result:

ok all 1 test passed

Test #119:

score: 0
Accepted
time: 7ms
memory: 4340kb

input:

1
50000 3
1 1 1 2 3 1 3 3 3 2 3 1 2 1 1 3 2 3 3 3 2 3 3 3 3 1 2 3 1 3 2 2 1 2 3 2 3 3 2 1 1 3 3 2 2 2 3 1 2 3 3 3 2 2 2 2 1 3 1 1 2 1 3 3 3 2 1 3 3 3 3 3 1 3 1 1 1 2 2 1 2 1 2 3 1 2 2 3 3 3 3 2 3 2 2 3 2 1 3 2 2 3 3 2 1 1 2 3 1 2 1 1 3 3 3 3 1 3 3 3 3 3 3 1 3 1 2 2 1 3 2 2 1 1 3 2 1 1 3 3 1 2 3 3 3 ...

output:

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

result:

ok all 1 test passed

Test #120:

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

input:

1
200000 3
2 2 3 2 2 2 3 2 3 2 3 2 1 2 3 3 3 2 2 2 1 1 1 3 1 1 2 2 2 3 1 2 3 2 1 2 3 1 2 2 2 2 1 3 1 2 3 1 1 3 3 1 1 3 1 1 3 1 3 2 2 1 3 1 3 1 1 3 1 3 1 2 1 1 3 2 1 1 3 2 2 2 1 3 2 1 3 2 1 2 3 2 2 1 2 2 2 1 1 1 2 2 3 1 2 2 2 3 1 2 3 1 2 1 3 2 2 2 1 1 1 3 2 2 3 1 3 2 1 3 2 3 1 3 3 3 3 1 1 1 3 1 1 3 3...

output:

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

result:

ok all 1 test passed

Test #121:

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

input:

1
200000 200000
71411 193310 53795 23615 45771 160252 44119 78297 131589 51364 26492 146125 67205 6162 46301 154524 63313 17662 99459 174369 2147 116145 193734 83070 149201 160201 50714 37506 63554 72954 57451 105091 66834 1649 190400 22397 45745 20241 100997 1097 105227 109475 49745 49889 23931 153...

output:

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

result:

ok all 1 test passed

Test #122:

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

input:

1
1000 2
2 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1...

output:

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

result:

ok all 1 test passed

Test #123:

score: 0
Accepted
time: 7ms
memory: 4216kb

input:

1
50000 2
1 1 1 1 2 2 2 1 1 1 2 2 2 1 2 2 1 1 2 2 2 2 2 1 1 1 1 2 1 2 2 1 1 2 1 1 1 2 2 1 2 2 1 1 2 1 1 1 2 1 1 1 2 2 2 1 2 2 2 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 1 2 1 2 2 1 1 1 2 2 2 1 2 2 2 2 1 2 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 2 1 2 2 2 2 1 2 2 2 2 ...

output:

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

result:

ok all 1 test passed

Test #124:

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

input:

1
200000 2
2 2 2 2 1 1 2 2 1 2 2 1 2 1 1 2 1 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 1 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 1 2 1 2 1 1 2 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 1 1 1 1 2 1 2 1 1 2 2 1 2 1 1 2 1 2 1 1 2 2 2 2 2 2 1 1 2 2 1 2 2 1 2 1 1 1 2 1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 2 1 1...

output:

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

result:

ok all 1 test passed

Test #125:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #126:

score: 0
Accepted
time: 14ms
memory: 4348kb

input:

1
50000 200
92 72 198 135 4 150 28 113 136 17 48 43 90 30 110 25 115 86 44 35 138 189 3 76 10 53 29 11 62 175 62 165 82 10 95 72 89 76 17 43 186 140 87 199 131 196 171 4 137 65 11 31 152 154 28 181 39 31 71 62 175 169 125 37 37 96 100 60 173 93 9 162 186 100 104 172 90 134 75 14 199 109 101 167 191 ...

output:

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

result:

ok all 1 test passed

Test #127:

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

input:

1
200000 400
194 273 81 167 64 136 269 276 68 53 308 233 254 201 322 244 330 315 106 300 38 267 60 206 206 1 177 19 53 219 8 378 45 190 250 55 203 159 295 243 262 86 36 83 269 154 178 255 12 224 368 371 108 11 55 208 216 110 177 101 99 50 54 196 96 399 138 78 93 292 87 218 293 192 207 60 163 325 159...

output:

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

result:

ok all 1 test passed

Test #128:

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

input:

1
200000 2
2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2...

output:

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

result:

ok all 1 test passed

Test #129:

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

input:

1
100000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

100050
308 309
307 309
306 309
305 309
304 309
303 309
302 309
301 309
300 309
299 309
298 309
297 309
296 309
295 309
294 309
293 309
292 309
291 309
290 309
289 309
288 309
287 309
286 309
285 309
284 309
283 309
282 309
281 309
280 309
279 309
278 309
277 309
276 309
275 309
274 309
273 309
272 3...

result:

ok all 1 test passed

Test #130:

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

input:

1
200000 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

200003
50100 50101
50099 50101
50098 50101
50097 50101
50096 50101
50095 50101
50094 50101
50093 50101
50092 50101
50091 50101
50090 50101
50089 50101
50088 50101
50087 50101
50086 50101
50085 50101
50084 50101
50083 50101
50082 50101
50081 50101
50080 50101
50079 50101
50078 50101
50077 50101
50076...

result:

ok all 1 test passed

Test #131:

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

input:

1
150000 3
2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2...

output:

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

result:

ok all 1 test passed

Test #132:

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

input:

1
150000 3
3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2...

output:

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

result:

ok all 1 test passed

Test #133:

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

input:

1
199998 3
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

200002
11589 11590
11588 11590
11587 11590
11586 11590
11585 11590
11584 11590
11583 11590
11582 11590
11581 11590
11580 11590
11579 11590
11578 11590
11577 11590
11576 11590
11575 11590
11574 11590
11573 11590
11572 11590
11571 11590
11570 11590
11569 11590
11568 11590
11567 11590
11566 11590
11565...

result:

ok all 1 test passed

Test #134:

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

input:

1
200000 100
78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78...

output:

200097
778 779
777 779
776 779
775 779
774 779
773 779
772 779
771 779
770 779
769 779
768 779
767 779
766 779
765 779
764 779
763 779
762 779
761 779
760 779
759 779
758 779
757 779
756 779
755 779
754 779
753 779
752 779
751 779
750 779
749 779
748 779
747 779
746 779
745 779
744 779
743 779
742 7...

result:

ok all 1 test passed

Test #135:

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

input:

1
200000 100000
96138 96138 96139 96139 96140 96140 96141 96141 96142 96142 96143 96143 96144 96144 96145 96145 96146 96146 96147 96147 96148 96148 96149 96149 96150 96150 96151 96151 96152 96152 96153 96153 96154 96154 96155 96155 96156 96156 96157 96157 96158 96158 96159 96159 96160 96160 96161 96...

output:

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

result:

ok all 1 test passed