QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393357#6545. Connect the DotsNahidameowAC ✓58ms10464kbC++201.9kb2024-04-18 15:35:572024-04-18 15:35:58

Judging History

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

  • [2024-04-18 15:35:58]
  • 评测
  • 测评结果:AC
  • 用时:58ms
  • 内存:10464kb
  • [2024-04-18 15:35:57]
  • 提交

answer

#include<bits/stdc++.h>
#define pd push_back
#define all(A) A.begin(),A.end()
#define lower_bound lb
#define ve std::vector
typedef long long ll;
typedef long long ll;
typedef __int128 Int;
typedef unsigned long long ul;
typedef long double LD;
bool FileIfstream(std::string name){
	std::ifstream f(name.c_str());
	return f.good();
}
namespace Math{
	ll QP(ll x,ll y,ll mod){ll ans=1;for(;y;y>>=1,x=x*x%mod)if(y&1)ans=ans*x%mod;return ans;}
	ll inv(ll x,ll mod){return QP(x,mod-2,mod);}
}
const int N=2e5+10;
const int mod=998244353;
void solve(){
	//don't forget to open long long
	int n,m;std::cin>>n>>m;
	ve<int>v(n+1);
	ve<std::array<int,2>>ans;
	for(int i=1;i<=n;i++)std::cin>>v[i];
	for(int i=1;i<n;i++)
		if(v[i]!=v[i+1])ans.pd({i,i+1});
	ve<bool>del(n+1);
	auto special=[&](int x)->void{
		int L=x,R=x;
		for(int i=x-1;i>=1;i--)
			if(!del[i]){if(L^x)ans.pd({i,x});L=i;}
		for(int i=x+1;i<=n;i++)
			if(!del[i]){if(R^x)ans.pd({x,i});R=i;}
		if(v[L]!=v[R]&&L!=x&&R!=x)ans.pd({L,R});
	};
	ve<int>st;
	ve<int>cnt(m+1);
	for(int i=1;i<=n;i++)
		cnt[v[i]]++;
	for(int i=1;i<=n;i++){
		while(st.size()>=2&&v[st[st.size()-2]]!=v[i]){
			if(cnt[v[st.back()]]==1){
				special(st.back());
				st.clear();
				goto flg;
			}
			ans.pd({st[st.size()-2],i});
			del[st.back()]=true;
			--cnt[v[st.back()]];
			st.pop_back();
		}
		st.pd(i);
	}
	for(int i=4;i<=st.size();i+=2)
		ans.pd({st[0],st[i-1]});
	flg:;
	sort(all(ans));ans.erase(unique(all(ans)),ans.end());
	std::cout<<ans.size()<<'\n';
	for(auto &p:ans)
		std::cout<<p[0]<<' '<<p[1]<<'\n';
}
int main(){
#ifndef ONLINE_JUDGE
	if(!FileIfstream("IO.in")){
		freopen("IO.in","w",stdout);
		return 0;
	}
	freopen("IO.in","r",stdin);
	freopen("IO.out","w",stdout);
#endif
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	int T=1;
	std::cin>>T;
	while(T--)solve();

	return 0;
}




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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #2:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #3:

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

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

result:

ok all 10 test passed

Test #4:

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

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

result:

ok all 10 test passed

Test #5:

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

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

result:

ok all 10 test passed

Test #6:

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

input:

1
5 2
1 1 2 2 1

output:

4
1 3
1 4
2 3
4 5

result:

ok all 1 test passed

Test #7:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #8:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #9:

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

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
1 5
1 8
1 13
1 18
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
23
1 2
1 7
1 11
1 16
1 19
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
23
1 3
1 4
1 11
1 14
1 17
1 20
2 3
4 5
4 6
6 7
6 8
6 9
6 10
6 11
1...

result:

ok all 4 test passed

Test #10:

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

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
1 4
1 9
1 12
1 16
1 23
1 27
1 30
1 32
1 37
1 39
1 42
1 44
1 46
1 48
1 53
1 57
1 61
1 67
1 69
1 71
1 74
1 78
1 83
1 86
1 89
1 92
1 95
1 97
2 4
3 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
...

result:

ok all 4 test passed

Test #11:

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

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
1 3
1 4
1 9
1 13
1 16
1 21
1 25
1 29
1 32
1 35
1 38
1 41
1 43
1 46
1 51
1 53
1 56
1 62
1 67
1 69
1 75
1 80
1 84
1 87
1 89
1 91
1 95
1 100
2 3
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 ...

result:

ok all 1 test passed

Test #12:

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

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
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
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 ...

result:

ok all 1 test passed

Test #13:

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

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
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 33
1 53
1 73
1 93
1 113
1 133
1 153
1 173
1 193
2 4
3 4
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...

result:

ok all 1 test passed

Test #14:

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

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

result:

ok all 4 test passed

Test #15:

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

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

result:

ok all 4 test passed

Test #16:

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

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
1 4
1 9
1 12
1 13
1 14
1 15
1 16
1 17
1 24
1 25
1 26
1 27
1 29
1 30
1 31
1 34
1 35
1 37
1 40
1 41
1 46
1 47
1 48
1 49
1 50
1 51
1 54
1 55
1 61
1 64
1 65
1 67
1 68
1 69
1 70
1 71
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 83
1 86
1 87
1 96
1 97
3 4
4 5
4 6
4 7
4 8
4 9
8 9
9 10
9 11
9 12
11 12
1...

result:

ok all 4 test passed

Test #17:

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

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
1 5
1 6
1 7
1 8
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 29
1 38
1 39
1 43
1 44
1 45
1 46
1 47
1 49
1 53
1 54
1 55
1 58
1 59
1 62
1 63
1 64
1 65
1 67
1 68
1 73
1 79
1 80
1 81
1 83
1 85
1 86
1 87
1 88
1 92
1 93
1 94
1 95
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 ...

result:

ok all 1 test passed

Test #18:

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

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
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7
11
1 2
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7
11
1 2
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7
11
1 2
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7

result:

ok all 4 test passed

Test #19:

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

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

result:

ok all 4 test passed

Test #20:

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

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

result:

ok all 4 test passed

Test #21:

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

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

result:

ok all 1 test passed

Test #22:

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

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

result:

ok all 4 test passed

Test #23:

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

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
1 4
1 6
1 7
1 9
1 12
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 31
1 32
1 33
1 34
1 35
1 36
1 37
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 55
1 56
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 ...

result:

ok all 4 test passed

Test #24:

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

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
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
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1...

result:

ok all 1 test passed

Test #25:

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

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
1 4
1 5
1 7
1 8
1 9
1 10
1 11
1 14
1 15
1 16
1 17
1 20
1 21
1 22
1 23
1 26
1 27
1 28
1 29
1 32
1 33
1 34
1 35
1 39
1 40
1 41
1 44
1 45
1 50
1 51
1 54
1 55
1 56
1 57
1 60
1 61
1 62
1 63
1 66
1 67
1 68
1 69
1 72
1 73
1 74
1 75
1 78
1 79
1 80
1 81
1 84
1 85
1 86
1 87
1 90
1 91
1 92
1 93
1 9...

result:

ok all 1 test passed

Test #26:

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

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
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
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
2 31
3 31
4 31
5 31
6 31
7 31
8 31
9 31
10 31
11 31
12 31
13 31
14 31
15 31
16 31
17 31
18 31
19 31
20 31
21 31
22 31
23 31
24...

result:

ok all 1 test passed

Test #27:

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

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

result:

ok all 1 test passed

Test #28:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
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
1 57
1 58
1 59
1 60
1 63
1 64
1 65
1 66
1 67
1 68
1 6...

result:

ok all 1 test passed

Test #29:

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

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
1 9
1 17
1 20
1 25
1 29
1 31
1 37
1 40
1 42
1 44
1 49
1 51
1 53
1 56
1 58
1 60
1 63
1 69
1 72
1 76
1 84
1 91
1 95
1 97
1 100
1 103
1 109
1 112
1 115
1 124
1 127
1 131
1 136
1 139
1 144
1 147
1 151
1 155
1 161
1 169
1 171
1 177
1 179
1 184
1 190
1 192
1 197
1 199
1 203
1 205
1 209
1 211
...

result:

ok all 1 test passed

Test #30:

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

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
1 12
1 15
1 18
1 24
1 30
1 32
1 40
1 42
1 46
1 49
1 51
1 53
1 56
1 61
1 64
1 70
1 75
1 84
1 87
1 90
1 93
1 96
1 98
1 101
1 103
1 107
1 109
1 117
1 119
1 121
1 125
1 127
1 133
1 137
1 139
1 142
1 148
1 150
1 154
1 163
1 165
1 167
1 171
1 176
1 180
1 183
1 188
1 194
1 201
1 205
1 ...

result:

ok all 1 test passed

Test #31:

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

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
1 3
1 4
1 8
1 12
1 16
1 20
1 24
1 28
1 32
1 36
1 40
1 44
1 48
1 52
1 56
1 60
1 64
1 68
1 72
1 76
1 80
1 84
1 88
1 92
1 96
1 100
1 104
1 108
1 112
1 116
1 120
1 124
1 128
1 132
1 136
1 140
1 144
1 148
1 152
1 156
1 160
1 164
1 168
1 172
1 176
1 180
1 184
1 188
1 192
1 196
1 200
1 204
1 208
1 212...

result:

ok all 1 test passed

Test #32:

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

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
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 40
1 52
1 60
1 80
1 100
1 120
1 140
1 160
1 180
1 200
1 220
1 240
1 260
1 280
1 300
1 320
1 340
1 360
1 380
1 400
1 420
1 440
1 460
1 480
1 500
1 520
1 540
1 560
1 580
1 600
1 620
1 640
1 660
1 680
1 700
1 720
1 740
1 760
1 765
1 780
1 800
1 8...

result:

ok all 1 test passed

Test #33:

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

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
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146...

result:

ok all 1 test passed

Test #34:

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

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
1 3
1 4
1 8
1 12
1 16
1 20
1 24
1 28
1 32
1 36
1 40
1 44
1 48
1 52
1 56
1 60
1 64
1 68
1 72
1 76
1 80
1 84
1 88
1 92
1 96
1 100
1 104
1 108
1 112
1 116
1 120
1 124
1 128
1 132
1 136
1 140
1 144
1 148
1 152
1 156
1 160
1 164
1 168
1 172
1 176
1 180
1 184
1 188
1 192
1 196
1 200
1 204
1 208
1 21...

result:

ok all 1 test passed

Test #35:

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

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
1 6
1 9
1 13
1 15
1 18
1 22
1 27
1 29
1 34
1 41
1 51
1 54
1 57
1 59
1 65
1 67
1 70
1 73
1 75
1 79
1 82
1 89
1 92
1 94
1 98
1 102
1 105
1 110
1 119
1 126
1 128
1 130
1 134
1 136
1 139
1 141
1 147
1 154
1 157
1 162
1 164
1 169
1 172
1 174
1 177
1 181
1 184
1 191
1 195
1 201
1 204
1 207
1...

result:

ok all 1 test passed

Test #36:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 300
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
12 14
12 15
12 16
12 17
12 18
12 19
12 20
12 21
12 22
12 23
12 24
12 25
12 26
12 27
12 28
12 29
12 30
12 31
12 32
12 33
12 34
12 35
12 36
12 37
12 38
12 39
12 40
12 41
12 42
12 43
12 44
12 45
...

result:

ok all 1 test passed

Test #37:

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

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
1 6
1 7
1 8
1 9
1 10
1 11
1 13
1 14
1 15
1 17
1 20
1 21
1 28
1 29
1 30
1 31
1 32
1 34
1 35
1 36
1 37
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 58
1 59
1 60
1 63
1 66
1 67
1 68
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 81
1 82
1 83
1 89
1 90
1 91
1 92
1 93
1 94
1 95
1 96
1 97
1 98
...

result:

ok all 1 test passed

Test #38:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 25
1 27
1 28
1 29
1 30
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 54
1 55
1 56
1 57
1 58
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 6...

result:

ok all 1 test passed

Test #39:

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

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
1 3
1 4
1 6
1 7
1 8
1 18
1 19
1 20
1 21
1 22
1 29
1 30
1 32
1 33
1 39
1 40
1 41
1 45
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 58
1 59
1 60
1 61
1 62
1 65
1 66
1 67
1 68
1 69
1 70
1 75
1 81
1 82
1 84
1 86
1 94
1 95
1 97
1 98
1 99
1 100
1 102
1 111
1 113
1 115
1 119
1 122
1 123
1 124
1 126
1 12...

result:

ok all 1 test passed

Test #40:

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

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
1 4
1 5
1 8
1 9
1 10
1 11
1 14
1 15
1 16
1 17
1 20
1 21
1 22
1 23
1 26
1 27
1 28
1 29
1 32
1 33
1 34
1 35
1 38
1 39
1 40
1 41
1 44
1 45
1 46
1 47
1 50
1 51
1 52
1 53
1 56
1 57
1 58
1 59
1 62
1 63
1 64
1 65
1 68
1 69
1 70
1 71
1 74
1 75
1 76
1 77
1 80
1 81
1 82
1 83
1 86
1 87
1 88
1 89
...

result:

ok all 1 test passed

Test #41:

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

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
1 1264
1 1265
1 1266
1 1267
1 1268
1 1269
1 1270
1 1271
1 1272
1 1273
1 1274
1 1275
1 1276
1 1277
1 1278
1 1279
1 1280
1 1281
1 1282
1 1283
1 1284
1 1285
1 1286
1 1287
1 1288
1 1289
1 1290
1 1291
1 1292
1 1293
1 1294
1 1295
1 1296
1 1297
1 1298
1 1299
1 1300
1 1301
1 1302
1 1303
1 1304
1 1305
...

result:

ok all 1 test passed

Test #42:

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

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

result:

ok all 1 test passed

Test #43:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #44:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #45:

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

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

result:

ok all 10 test passed

Test #46:

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

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

result:

ok all 10 test passed

Test #47:

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

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

result:

ok all 10 test passed

Test #48:

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

input:

1
5 2
1 1 2 2 1

output:

4
1 3
1 4
2 3
4 5

result:

ok all 1 test passed

Test #49:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #50:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #51:

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

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
1 5
1 8
1 13
1 18
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
23
1 2
1 7
1 11
1 16
1 19
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
23
1 3
1 4
1 11
1 14
1 17
1 20
2 3
4 5
4 6
6 7
6 8
6 9
6 10
6 11
1...

result:

ok all 4 test passed

Test #52:

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

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
1 4
1 9
1 12
1 16
1 23
1 27
1 30
1 32
1 37
1 39
1 42
1 44
1 46
1 48
1 53
1 57
1 61
1 67
1 69
1 71
1 74
1 78
1 83
1 86
1 89
1 92
1 95
1 97
2 4
3 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
...

result:

ok all 4 test passed

Test #53:

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

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
1 3
1 4
1 5
1 14
1 23
1 28
1 30
1 36
1 40
1 45
1 49
1 59
1 63
1 66
1 69
1 72
1 74
1 78
1 85
1 88
1 91
1 96
1 99
1 104
1 111
1 113
1 116
1 118
1 123
1 125
1 130
1 135
1 138
1 140
1 143
1 146
1 151
1 153
1 155
1 161
1 164
1 167
1 177
1 179
1 183
1 186
1 188
1 192
1 197
1 211
1 214
1 216
1 219
1 22...

result:

ok all 1 test passed

Test #54:

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

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
1 3
1 4
1 8
1 12
1 16
1 20
1 24
1 28
1 32
1 36
1 40
1 44
1 48
1 52
1 56
1 60
1 64
1 68
1 72
1 76
1 80
1 84
1 88
1 92
1 96
1 100
1 104
1 108
1 112
1 116
1 120
1 124
1 128
1 132
1 136
1 140
1 144
1 148
1 152
1 156
1 160
1 164
1 168
1 172
1 176
1 180
1 184
1 188
1 192
1 196
1 200
1 204
1 208
1 212
...

result:

ok all 1 test passed

Test #55:

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

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
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 34
1 54
1 74
1 94
1 114
1 134
1 154
1 174
1 194
1 214
1 234
1 254
1 274
1 294
2 5
3 5
4 5
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 ...

result:

ok all 1 test passed

Test #56:

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

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

result:

ok all 4 test passed

Test #57:

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

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

result:

ok all 4 test passed

Test #58:

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

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
1 4
1 9
1 12
1 13
1 14
1 15
1 16
1 17
1 24
1 25
1 26
1 27
1 29
1 30
1 31
1 34
1 35
1 37
1 40
1 41
1 46
1 47
1 48
1 49
1 50
1 51
1 54
1 55
1 61
1 64
1 65
1 67
1 68
1 69
1 70
1 71
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 83
1 86
1 87
1 96
1 97
3 4
4 5
4 6
4 7
4 8
4 9
8 9
9 10
9 11
9 12
11 12
1...

result:

ok all 4 test passed

Test #59:

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

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
1 9
1 10
1 11
1 13
1 14
1 15
1 18
1 19
1 24
1 25
1 26
1 28
1 29
1 34
1 37
1 38
1 43
1 44
1 46
1 47
1 48
1 49
1 50
1 51
1 56
1 58
1 59
1 60
1 61
1 68
1 70
1 72
1 73
1 78
1 79
1 80
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 94
1 95
1 96
1 97
1 101
1 106
1 108
1 109
1 110
1 111
1 114
1 117
...

result:

ok all 1 test passed

Test #60:

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

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
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7
11
1 2
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7
11
1 2
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7
11
1 2
1 7
2 3
2 4
2 5
2 6
2 7
3 4
4 5
5 6
6 7

result:

ok all 4 test passed

Test #61:

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

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

result:

ok all 4 test passed

Test #62:

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

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

result:

ok all 4 test passed

Test #63:

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

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

result:

ok all 1 test passed

Test #64:

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

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

result:

ok all 4 test passed

Test #65:

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

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
1 4
1 6
1 7
1 9
1 12
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 31
1 32
1 33
1 34
1 35
1 36
1 37
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 55
1 56
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 ...

result:

ok all 4 test passed

Test #66:

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

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
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
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1...

result:

ok all 1 test passed

Test #67:

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

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
1 3
1 4
1 5
1 6
1 9
1 10
1 11
1 12
1 15
1 16
1 17
1 18
1 21
1 22
1 23
1 24
1 27
1 28
1 29
1 30
1 33
1 34
1 35
1 36
1 39
1 40
1 41
1 42
1 45
1 46
1 47
1 48
1 51
1 52
1 53
1 54
1 57
1 58
1 59
1 60
1 63
1 64
1 65
1 66
1 69
1 70
1 71
1 72
1 75
1 76
1 77
1 78
1 81
1 82
1 83
1 84
1 87
1 88
1 89
1 90
1...

result:

ok all 1 test passed

Test #68:

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

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
1 60
1 92
1 93
1 94
1 95
1 96
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141...

result:

ok all 1 test passed

Test #69:

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

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

result:

ok all 1 test passed

Test #70:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
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
1 57
1 58
1 59
1 60
1 63
1 64
1 65
1 66
1 67
1 68
1 6...

result:

ok all 1 test passed

Test #71:

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

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
1 9
1 17
1 20
1 25
1 29
1 31
1 37
1 40
1 42
1 44
1 49
1 51
1 53
1 56
1 58
1 60
1 63
1 69
1 72
1 76
1 84
1 91
1 95
1 97
1 100
1 103
1 109
1 112
1 115
1 124
1 127
1 131
1 136
1 139
1 144
1 147
1 151
1 155
1 161
1 169
1 171
1 177
1 179
1 184
1 190
1 192
1 197
1 199
1 203
1 205
1 209
1 211
...

result:

ok all 1 test passed

Test #72:

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

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
1 12
1 15
1 18
1 24
1 30
1 32
1 40
1 42
1 46
1 49
1 51
1 53
1 56
1 61
1 64
1 70
1 75
1 84
1 87
1 90
1 93
1 96
1 98
1 101
1 103
1 107
1 109
1 117
1 119
1 121
1 125
1 127
1 133
1 137
1 139
1 142
1 148
1 150
1 154
1 163
1 165
1 167
1 171
1 176
1 180
1 183
1 188
1 194
1 201
1 205
1 ...

result:

ok all 1 test passed

Test #73:

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

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
1 3
1 4
1 8
1 12
1 16
1 20
1 24
1 28
1 32
1 36
1 40
1 44
1 48
1 52
1 56
1 60
1 64
1 68
1 72
1 76
1 80
1 84
1 88
1 92
1 96
1 100
1 104
1 108
1 112
1 116
1 120
1 124
1 128
1 132
1 136
1 140
1 144
1 148
1 152
1 156
1 160
1 164
1 168
1 172
1 176
1 180
1 184
1 188
1 192
1 196
1 200
1 204
1 208
1 212...

result:

ok all 1 test passed

Test #74:

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

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
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 40
1 52
1 60
1 80
1 100
1 120
1 140
1 160
1 180
1 200
1 220
1 240
1 260
1 280
1 300
1 320
1 340
1 360
1 380
1 400
1 420
1 440
1 460
1 480
1 500
1 520
1 540
1 560
1 580
1 600
1 620
1 640
1 660
1 680
1 700
1 720
1 740
1 760
1 765
1 780
1 800
1 8...

result:

ok all 1 test passed

Test #75:

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

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
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146...

result:

ok all 1 test passed

Test #76:

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

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
1 3
1 4
1 8
1 12
1 16
1 20
1 24
1 28
1 32
1 36
1 40
1 44
1 48
1 52
1 56
1 60
1 64
1 68
1 72
1 76
1 80
1 84
1 88
1 92
1 96
1 100
1 104
1 108
1 112
1 116
1 120
1 124
1 128
1 132
1 136
1 140
1 144
1 148
1 152
1 156
1 160
1 164
1 168
1 172
1 176
1 180
1 184
1 188
1 192
1 196
1 200
1 204
1 208
1 21...

result:

ok all 1 test passed

Test #77:

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

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
1 6
1 9
1 13
1 15
1 18
1 22
1 27
1 29
1 34
1 41
1 51
1 54
1 57
1 59
1 65
1 67
1 70
1 73
1 75
1 79
1 82
1 89
1 92
1 94
1 98
1 102
1 105
1 110
1 119
1 126
1 128
1 130
1 134
1 136
1 139
1 141
1 147
1 154
1 157
1 162
1 164
1 169
1 172
1 174
1 177
1 181
1 184
1 191
1 195
1 201
1 204
1 207
1...

result:

ok all 1 test passed

Test #78:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 300
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
12 14
12 15
12 16
12 17
12 18
12 19
12 20
12 21
12 22
12 23
12 24
12 25
12 26
12 27
12 28
12 29
12 30
12 31
12 32
12 33
12 34
12 35
12 36
12 37
12 38
12 39
12 40
12 41
12 42
12 43
12 44
12 45
...

result:

ok all 1 test passed

Test #79:

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

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
1 6
1 7
1 8
1 9
1 10
1 11
1 13
1 14
1 15
1 17
1 20
1 21
1 28
1 29
1 30
1 31
1 32
1 34
1 35
1 36
1 37
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 58
1 59
1 60
1 63
1 66
1 67
1 68
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 81
1 82
1 83
1 89
1 90
1 91
1 92
1 93
1 94
1 95
1 96
1 97
1 98
...

result:

ok all 1 test passed

Test #80:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 25
1 27
1 28
1 29
1 30
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 54
1 55
1 56
1 57
1 58
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 6...

result:

ok all 1 test passed

Test #81:

score: 0
Accepted
time: 7ms
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
1 3
1 4
1 6
1 7
1 8
1 18
1 19
1 20
1 21
1 22
1 29
1 30
1 32
1 33
1 39
1 40
1 41
1 45
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 58
1 59
1 60
1 61
1 62
1 65
1 66
1 67
1 68
1 69
1 70
1 75
1 81
1 82
1 84
1 86
1 94
1 95
1 97
1 98
1 99
1 100
1 102
1 111
1 113
1 115
1 119
1 122
1 123
1 124
1 126
1 12...

result:

ok all 1 test passed

Test #82:

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

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
1 4
1 5
1 8
1 9
1 10
1 11
1 14
1 15
1 16
1 17
1 20
1 21
1 22
1 23
1 26
1 27
1 28
1 29
1 32
1 33
1 34
1 35
1 38
1 39
1 40
1 41
1 44
1 45
1 46
1 47
1 50
1 51
1 52
1 53
1 56
1 57
1 58
1 59
1 62
1 63
1 64
1 65
1 68
1 69
1 70
1 71
1 74
1 75
1 76
1 77
1 80
1 81
1 82
1 83
1 86
1 87
1 88
1 89
...

result:

ok all 1 test passed

Test #83:

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

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
1 1264
1 1265
1 1266
1 1267
1 1268
1 1269
1 1270
1 1271
1 1272
1 1273
1 1274
1 1275
1 1276
1 1277
1 1278
1 1279
1 1280
1 1281
1 1282
1 1283
1 1284
1 1285
1 1286
1 1287
1 1288
1 1289
1 1290
1 1291
1 1292
1 1293
1 1294
1 1295
1 1296
1 1297
1 1298
1 1299
1 1300
1 1301
1 1302
1 1303
1 1304
1 1305
...

result:

ok all 1 test passed

Test #84:

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

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

result:

ok all 1 test passed

Test #85:

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

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

result:

ok all 101 test passed

Test #86:

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

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

result:

ok all 87 test passed

Test #87:

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

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

result:

ok all 101 test passed

Test #88:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #89:

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

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
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 33
1 53
1 73
1 93
1 113
1 133
1 153
1 173
1 193
1 213
1 233
1 253
1 273
1 293
1 313
1 333
1 353
1 373
1 393
1 413
1 433
1 453
1 473
1 493
1 513
1 533
1 553
1 573
1 593
1 613
1 633
1 653
1 673
1 693
1 713
1 733
1 753
1 773
1 793
1 813
1 833
1 853
1...

result:

ok all 1 test passed

Test #90:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #91:

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

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

result:

ok all 10 test passed

Test #92:

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

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

result:

ok all 10 test passed

Test #93:

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

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

result:

ok all 10 test passed

Test #94:

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

input:

1
5 2
1 1 2 2 1

output:

4
1 3
1 4
2 3
4 5

result:

ok all 1 test passed

Test #95:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #96:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #97:

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

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
1 8
1 10
1 12
1 15
1 17
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
23
1 2
1 3
1 4
1 9
1 11
1 14
1 19
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
24
1 2
1 3
1 5
1 8
1 10
1 15
1 17
3 4
4 5
5 6
6 7
6 8
8 9...

result:

ok all 10 test passed

Test #98:

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

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
1 7
1 10
1 13
1 16
1 18
1 22
1 26
1 29
1 38
1 41
1 43
1 45
1 48
1 52
1 54
1 58
1 67
1 69
1 75
1 79
1 81
1 84
1 87
1 89
1 94
1 100
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 ...

result:

ok all 10 test passed

Test #99:

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

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
1 3
1 4
1 5
1 14
1 23
1 28
1 30
1 36
1 40
1 45
1 49
1 59
1 63
1 66
1 69
1 72
1 74
1 78
1 85
1 88
1 91
1 96
1 99
1 104
1 111
1 113
1 116
1 118
1 123
1 125
1 130
1 135
1 138
1 140
1 143
1 146
1 151
1 153
1 155
1 161
1 164
1 167
1 177
1 179
1 183
1 186
1 188
1 192
1 197
1 211
1 214
1 216
1 219
1 22...

result:

ok all 1 test passed

Test #100:

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

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

result:

ok all 10 test passed

Test #101:

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

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

result:

ok all 10 test passed

Test #102:

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

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
1 5
1 7
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 24
1 25
1 26
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 41
1 42
1 43
1 44
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 58
1 59
1 63
1 69
1 71
1 72
1 73
1 76
1 79
1 85
1 86
1 87
1 93
1 94
1 97
1 98
1 100
2 3
2 4
2 5
4 5
5 6
5 7
6 7
7 8
7 9
7 ...

result:

ok all 10 test passed

Test #103:

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

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
1 9
1 10
1 11
1 13
1 14
1 15
1 18
1 19
1 24
1 25
1 26
1 28
1 29
1 34
1 37
1 38
1 43
1 44
1 46
1 47
1 48
1 49
1 50
1 51
1 56
1 58
1 59
1 60
1 61
1 68
1 70
1 72
1 73
1 78
1 79
1 80
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 94
1 95
1 96
1 97
1 101
1 106
1 108
1 109
1 110
1 111
1 114
1 117
...

result:

ok all 1 test passed

Test #104:

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

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

result:

ok all 10 test passed

Test #105:

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

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

result:

ok all 10 test passed

Test #106:

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

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

result:

ok all 10 test passed

Test #107:

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

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

result:

ok all 1 test passed

Test #108:

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

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

result:

ok all 10 test passed

Test #109:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 13
1 14
1 15
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
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 52
1 53
1 54
1 55
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67...

result:

ok all 10 test passed

Test #110:

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

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
1 3
1 4
1 8
1 12
1 16
1 20
1 24
1 28
1 32
1 36
1 40
1 44
1 48
1 52
1 56
1 60
1 64
1 68
1 72
1 76
1 80
1 84
1 88
1 92
1 96
1 100
1 104
1 108
1 112
1 116
1 120
1 124
1 128
1 132
1 136
1 140
1 144
1 148
1 152
1 156
1 160
1 164
1 168
1 172
1 176
1 180
1 184
1 188
1 192
1 196
1 200
1 204
1 208
1 212
...

result:

ok all 1 test passed

Test #111:

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

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
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 34
1 54
1 74
1 94
1 114
1 134
1 154
1 174
1 194
1 214
1 234
1 254
1 274
1 294
2 5
3 5
4 5
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 ...

result:

ok all 1 test passed

Test #112:

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

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
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
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1...

result:

ok all 1 test passed

Test #113:

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

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
1 3
1 4
1 5
1 6
1 9
1 10
1 11
1 12
1 15
1 16
1 17
1 18
1 21
1 22
1 23
1 24
1 27
1 28
1 29
1 30
1 33
1 34
1 35
1 36
1 39
1 40
1 41
1 42
1 45
1 46
1 47
1 48
1 51
1 52
1 53
1 54
1 57
1 58
1 59
1 60
1 63
1 64
1 65
1 66
1 69
1 70
1 71
1 72
1 75
1 76
1 77
1 78
1 81
1 82
1 83
1 84
1 87
1 88
1 89
1 90
1...

result:

ok all 1 test passed

Test #114:

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

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
1 60
1 92
1 93
1 94
1 95
1 96
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141...

result:

ok all 1 test passed

Test #115:

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

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

result:

ok all 1 test passed

Test #116:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
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
1 57
1 58
1 59
1 60
1 63
1 64
1 65
1 66
1 67
1 68
1 6...

result:

ok all 1 test passed

Test #117:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 300
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
12 14
12 15
12 16
12 17
12 18
12 19
12 20
12 21
12 22
12 23
12 24
12 25
12 26
12 27
12 28
12 29
12 30
12 31
12 32
12 33
12 34
12 35
12 36
12 37
12 38
12 39
12 40
12 41
12 42
12 43
12 44
12 45
...

result:

ok all 1 test passed

Test #118:

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

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
1 6
1 7
1 8
1 9
1 10
1 11
1 13
1 14
1 15
1 17
1 20
1 21
1 28
1 29
1 30
1 31
1 32
1 34
1 35
1 36
1 37
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 58
1 59
1 60
1 63
1 66
1 67
1 68
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 81
1 82
1 83
1 89
1 90
1 91
1 92
1 93
1 94
1 95
1 96
1 97
1 98
...

result:

ok all 1 test passed

Test #119:

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

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
1 4
1 5
1 10
1 11
1 13
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 27
1 28
1 31
1 32
1 35
1 36
1 37
1 38
1 39
1 42
1 43
1 44
1 45
1 46
1 47
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 58
1 61
1 63
1 64
1 65
1 66
1 68
1 69
1 70
1 71
1 72
1 78
1 79
1 84
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1...

result:

ok all 1 test passed

Test #120:

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

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
1 3
1 13
1 15
1 16
1 17
1 21
1 22
1 23
1 24
1 25
1 26
1 30
1 31
1 33
1 35
1 37
1 38
1 44
1 45
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 75
1 77
1 78
1 79
1 83
1 84
1 86
1 87
1 89
1 91
1 94
1 103
1 104
1 108
1 109
1 111...

result:

ok all 1 test passed

Test #121:

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

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

result:

ok all 1 test passed

Test #122:

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

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
1 9
1 17
1 20
1 25
1 29
1 31
1 37
1 40
1 42
1 44
1 49
1 51
1 53
1 56
1 58
1 60
1 63
1 69
1 72
1 76
1 84
1 91
1 95
1 97
1 100
1 103
1 109
1 112
1 115
1 124
1 127
1 131
1 136
1 139
1 144
1 147
1 151
1 155
1 161
1 169
1 171
1 177
1 179
1 184
1 190
1 192
1 197
1 199
1 203
1 205
1 209
1 211
...

result:

ok all 1 test passed

Test #123:

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

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
1 5
1 6
1 7
1 13
1 16
1 23
1 28
1 31
1 34
1 39
1 42
1 45
1 49
1 55
1 59
1 63
1 66
1 68
1 77
1 81
1 85
1 88
1 94
1 99
1 101
1 105
1 107
1 114
1 118
1 122
1 125
1 128
1 135
1 140
1 145
1 147
1 150
1 156
1 163
1 169
1 177
1 179
1 182
1 185
1 187
1 189
1 194
1 199
1 202
1 205
1 211
1 216
1 224
1 2...

result:

ok all 1 test passed

Test #124:

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

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
1 5
1 6
1 9
1 12
1 15
1 18
1 22
1 33
1 37
1 39
1 42
1 45
1 49
1 55
1 59
1 63
1 65
1 67
1 70
1 77
1 85
1 92
1 94
1 97
1 100
1 103
1 105
1 108
1 116
1 119
1 122
1 126
1 129
1 132
1 135
1 137
1 142
1 146
1 150
1 154
1 157
1 159
1 163
1 166
1 171
1 174
1 178
1 185
1 187
1 193
1 195
1 197
1 199
1 ...

result:

ok all 1 test passed

Test #125:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 25
1 27
1 28
1 29
1 30
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 54
1 55
1 56
1 57
1 58
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 6...

result:

ok all 1 test passed

Test #126:

score: 0
Accepted
time: 15ms
memory: 4528kb

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
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
1 57
1 58
1 59
1 60
1 61
1 ...

result:

ok all 1 test passed

Test #127:

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

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
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
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
1 57
1 58
1 59
1 60
1 61
1...

result:

ok all 1 test passed

Test #128:

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

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
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 21...

result:

ok all 1 test passed

Test #129:

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

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
1 309
1 310
1 311
1 312
1 313
1 314
1 315
1 316
1 317
1 318
1 319
1 320
1 321
1 322
1 323
1 324
1 325
1 326
1 327
1 328
1 329
1 330
1 331
1 332
1 333
1 334
1 335
1 336
1 337
1 338
1 339
1 340
1 341
1 342
1 343
1 344
1 345
1 346
1 347
1 348
1 349
1 350
1 351
1 352
1 353
1 354
1 355
1 356
1 357...

result:

ok all 1 test passed

Test #130:

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

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
1 50101
1 66073
1 76162
1 115984
1 174862
2 50101
3 50101
4 50101
5 50101
6 50101
7 50101
8 50101
9 50101
10 50101
11 50101
12 50101
13 50101
14 50101
15 50101
16 50101
17 50101
18 50101
19 50101
20 50101
21 50101
22 50101
23 50101
24 50101
25 50101
26 50101
27 50101
28 50101
29 50101
30 5010...

result:

ok all 1 test passed

Test #131:

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

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
1 3
1 4
1 5
1 6
1 9
1 10
1 11
1 12
1 15
1 16
1 17
1 18
1 21
1 22
1 23
1 24
1 27
1 28
1 29
1 30
1 33
1 34
1 35
1 36
1 39
1 40
1 41
1 42
1 45
1 46
1 47
1 48
1 51
1 52
1 53
1 54
1 57
1 58
1 59
1 60
1 63
1 64
1 65
1 66
1 69
1 70
1 71
1 72
1 75
1 76
1 77
1 78
1 81
1 82
1 83
1 84
1 87
1 88
1 89
1 9...

result:

ok all 1 test passed

Test #132:

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

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
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
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
1 57
1 58
1 59
1 60
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 8...

result:

ok all 1 test passed

Test #133:

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

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
1 11590
1 11591
1 11592
1 11593
1 11594
1 11595
1 11596
1 11597
1 11598
1 11599
1 11600
1 11601
1 11602
1 11603
1 11604
1 11605
1 11606
1 11607
1 11608
1 11609
1 11610
1 11611
1 11612
1 11613
1 11614
1 11615
1 11616
1 11617
1 11618
1 11619
1 11620
1 11621
1 11622
1 11623
1 11624
1 11625
1 116...

result:

ok all 1 test passed

Test #134:

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

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
1 779
1 780
1 781
1 782
1 783
1 784
1 785
1 786
1 787
1 788
1 789
1 790
1 791
1 792
1 793
1 794
1 795
1 796
1 797
1 798
1 799
1 800
1 801
1 802
1 803
1 804
1 805
1 806
1 807
1 808
1 809
1 810
1 811
1 812
1 813
1 814
1 815
1 816
1 817
1 818
1 819
1 820
1 821
1 822
1 823
1 824
1 825
1 826
1 827...

result:

ok all 1 test passed

Test #135:

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

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

result:

ok all 1 test passed