QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694052#9327. Permutation and Querieslytqwq#AC ✓1346ms124008kbC++142.5kb2024-10-31 17:10:112024-10-31 17:10:27

Judging History

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

  • [2024-10-31 17:10:27]
  • 评测
  • 测评结果:AC
  • 用时:1346ms
  • 内存:124008kb
  • [2024-10-31 17:10:11]
  • 提交

answer

#include<bits/stdc++.h>
#define re return
using namespace std;
const int N=1e5+10;
int n,q,p[N],wz[N];
int L;
long long ans[N]; 

struct DS{
int id,lim;
priority_queue<int> q1,q2;
DS(){while(!q1.empty()) q1.pop();while(!q2.empty()) q2.pop();}
DS(int i){id=i,lim=n/id;}
void insert(int x){
    if(x>lim) re;
    q1.push(-x);
}
void erase(int x){
    if(x>lim) re;
    q2.push(-x);
}
int ask(){
    while(!q1.empty()&&!q2.empty()&&q1.top()==q2.top()) q1.pop(),q2.pop();
    if(q1.empty()) re n;
    re -q1.top();
}
}dk[N];

long long ask(){
	long long ans=1e9;
	for(int i=1;i<=L;i++){
		int x=dk[i].ask();
		ans=min(ans,i*1ll*x);
	}
	return ans;
}

int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		wz[p[i]]=i;
	}
	L=sqrt(n);
    for(int i=1;i<=L;i++) dk[i]=DS(i);
	for(int i=1;i<=L;i++){
		for(int v=1;v+i<=n;v++){
			dk[i].insert(abs(p[v+i]-p[v]));
			dk[i].insert(abs(wz[v+i]-wz[v]));
		}
	}
	printf("%lld\n",ask());
//	ans[0]=ask();
	for(int i=1;i<=q;i++){
		
		int l,r;
		scanf("%d%d",&l,&r);
		if(l>r)swap(l,r);
		for(int v=1;v<=L;v++){
			if(l+v<=n)
			dk[v].erase(abs(p[l+v]-p[l]));
			if(r+v<=n)
			dk[v].erase(abs(p[r+v]-p[r]));
			if(l+v!=r)
			if(r-v>=1)
			dk[v].erase(abs(p[r-v]-p[r]));
			if(l-v>=1)
			dk[v].erase(abs(p[l-v]-p[l]));
			
			
			
			if(p[l]+v<=n)
			dk[v].erase(abs(l-wz[p[l]+v]));
			if(p[l]-v>=1)
			dk[v].erase(abs(l-wz[p[l]-v]));
			if(p[r]+v!=p[l])
			if(p[r]+v<=n)
			dk[v].erase(abs(r-wz[p[r]+v]));
			if(p[r]-v!=p[l])
			if(p[r]-v>=1)
			dk[v].erase(abs(r-wz[p[r]-v]));
			
			
//			if(r+v<=n)
//			dk[v].erase(dk[v].find(abs(p[r+v]-p[r])));
//			if(l+v!=r)
//			if(r-v>=1)
//			dk[v].erase(dk[v].find(abs(p[r-v]-p[r])));
//			if(l-v>=1)
//			dk[v].erase(dk[v].find(abs(p[l-v]-p[l])));
			
		}
		swap(p[l],p[r]);
		swap(wz[p[l]],wz[p[r]]);
		for(int v=1;v<=L;v++){
			if(l+v<=n)
			dk[v].insert(abs(p[l+v]-p[l]));
			if(r+v<=n)
			dk[v].insert(abs(p[r+v]-p[r]));
			if(l+v!=r)
			if(r-v>=1)
			dk[v].insert(abs(p[r-v]-p[r]));
			if(l-v>=1)
			dk[v].insert(abs(p[l-v]-p[l]));
			
			
			
			if(p[l]+v<=n)
			dk[v].insert(abs(l-wz[p[l]+v]));
			if(p[l]-v>=1)
			dk[v].insert(abs(l-wz[p[l]-v]));
			if(p[r]+v!=p[l])
			if(p[r]+v<=n)
			dk[v].insert(abs(r-wz[p[r]+v]));
			if(p[r]-v!=p[l])
			if(p[r]-v>=1)
			dk[v].insert(abs(r-wz[p[r]-v]));
		}
		printf("%lld\n",ask());
//		ans[i]=ask();
		
	}
}
/*
6 5
2 4 1 6 3 5
1 2
3 5
1 2
5 3
5 6
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 12172kb

input:

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

output:

2
1
1
1
2
1

result:

ok 6 numbers

Test #2:

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

input:

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

output:

3
3
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1

result:

ok 21 numbers

Test #3:

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

input:

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

output:

2
1
1
1
1
1
2

result:

ok 7 numbers

Test #4:

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

input:

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

output:

1
1
1
1
1

result:

ok 5 number(s): "1 1 1 1 1"

Test #5:

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

input:

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

output:

1
1
1
1
1
1

result:

ok 6 numbers

Test #6:

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

input:

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

output:

10
10
10
3
3
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
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
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
2
2
2
2
2
2
2
2
2...

result:

ok 1001 numbers

Test #7:

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

input:

1000 1000
1 32 63 94 125 156 187 218 249 280 311 342 373 404 435 466 497 528 559 590 621 652 683 714 745 776 807 838 869 900 931 962 993 2 33 64 95 126 157 188 219 250 281 312 343 374 405 436 467 498 529 560 591 622 653 684 715 746 777 808 839 870 901 932 963 994 3 34 65 96 127 158 189 220 251 282 3...

output:

31
21
21
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
9
9
9
9
9
9
9
8
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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
...

result:

ok 1001 numbers

Test #8:

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

input:

292 1828
1 18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 290 2 19 36 53 70 87 104 121 138 155 172 189 206 223 240 257 274 291 3 20 37 54 71 88 105 122 139 156 173 190 207 224 241 258 275 292 4 21 38 55 72 89 106 123 140 157 174 191 208 225 242 259 276 5 22 39 56 73 90 107 124 141 158 17...

output:

17
9
9
6
6
6
6
6
6
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 1829 numbers

Test #9:

score: 0
Accepted
time: 12ms
memory: 12160kb

input:

1919 2393
1 44 87 130 173 216 259 302 345 388 431 474 517 560 603 646 689 732 775 818 861 904 947 990 1033 1076 1119 1162 1205 1248 1291 1334 1377 1420 1463 1506 1549 1592 1635 1678 1721 1764 1807 1850 1893 2 45 88 131 174 217 260 303 346 389 432 475 518 561 604 647 690 733 776 819 862 905 948 991 1...

output:

43
43
43
42
42
42
42
42
42
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 2394 numbers

Test #10:

score: 0
Accepted
time: 9ms
memory: 11732kb

input:

1000 2000
1 32 63 94 125 156 187 218 249 280 311 342 373 404 435 466 497 528 559 590 621 652 683 714 745 776 807 838 869 900 931 962 993 2 33 64 95 126 157 188 219 250 281 312 343 374 405 436 467 498 529 560 591 622 653 684 715 746 777 808 839 870 901 932 963 994 3 34 65 96 127 158 189 220 251 282 3...

output:

31
16
16
12
12
12
12
12
12
12
12
3
3
3
3
3
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...

result:

ok 2001 numbers

Test #11:

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

input:

500 999
1 23 45 67 89 111 133 155 177 199 221 243 265 287 309 331 353 375 397 419 441 463 485 2 24 46 68 90 112 134 156 178 200 222 244 266 288 310 332 354 376 398 420 442 464 486 3 25 47 69 91 113 135 157 179 201 223 245 267 289 311 333 355 377 399 421 443 465 487 4 26 48 70 92 114 136 158 180 202 ...

output:

22
22
22
19
19
16
16
12
12
12
8
8
8
8
8
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 1000 numbers

Test #12:

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

input:

1600 2000
1 41 81 121 161 201 241 281 321 361 401 441 481 521 561 601 641 681 721 761 801 841 881 921 961 1001 1041 1081 1121 1161 1201 1241 1281 1321 1361 1401 1441 1481 1521 1561 2 42 82 122 162 202 242 282 322 362 402 442 482 522 562 602 642 682 722 762 802 842 882 922 962 1002 1042 1082 1122 116...

output:

40
40
40
40
40
40
40
36
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 2001 numbers

Test #13:

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

input:

1600 2000
1 41 81 121 161 201 241 281 321 361 401 441 481 521 561 601 641 681 721 761 801 841 881 921 961 1001 1041 1081 1121 1161 1201 1241 1281 1321 1361 1401 1441 1481 1521 1561 2 42 82 122 162 202 242 282 322 362 402 442 482 522 562 602 642 682 722 762 802 842 882 922 962 1002 1042 1082 1122 116...

output:

40
40
40
40
40
40
40
18
15
15
15
15
15
15
15
15
15
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

result:

ok 2001 numbers

Test #14:

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

input:

900 900
1 31 61 91 121 151 181 211 241 271 301 331 361 391 421 451 481 511 541 571 601 631 661 691 721 751 781 811 841 871 2 32 62 92 122 152 182 212 242 272 302 332 362 392 422 452 482 512 542 572 602 632 662 692 722 752 782 812 842 872 3 33 63 93 123 153 183 213 243 273 303 333 363 393 423 453 483...

output:

30
30
30
18
18
18
18
18
18
18
8
8
8
8
7
7
7
7
7
7
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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
...

result:

ok 901 numbers

Test #15:

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

input:

400 500
1 21 41 61 81 101 121 141 161 181 201 221 241 261 281 301 321 341 361 381 2 22 42 62 82 102 122 142 162 182 202 222 242 262 282 302 322 342 362 382 3 23 43 63 83 103 123 143 163 183 203 223 243 263 283 303 323 343 363 383 4 24 44 64 84 104 124 144 164 184 204 224 244 264 284 304 324 344 364 ...

output:

20
20
16
13
13
13
13
13
13
6
4
4
4
4
4
4
4
4
4
4
4
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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...

result:

ok 501 numbers

Test #16:

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

input:

400 500
1 21 41 61 81 101 121 141 161 181 201 221 241 261 281 301 321 341 361 381 2 22 42 62 82 102 122 142 162 182 202 222 242 262 282 302 322 342 362 382 3 23 43 63 83 103 123 143 163 183 203 223 243 263 283 303 323 343 363 383 4 24 44 64 84 104 124 144 164 184 204 224 244 264 284 304 324 344 364 ...

output:

20
19
4
4
4
4
4
4
4
4
4
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 501 numbers

Test #17:

score: 0
Accepted
time: 1098ms
memory: 116588kb

input:

100000 100000
1 317 633 949 1265 1581 1897 2213 2529 2845 3161 3477 3793 4109 4425 4741 5057 5373 5689 6005 6321 6637 6953 7269 7585 7901 8217 8533 8849 9165 9481 9797 10113 10429 10745 11061 11377 11693 12009 12325 12641 12957 13273 13589 13905 14221 14537 14853 15169 15485 15801 16117 16433 16749 ...

output:

316
316
316
316
316
298
298
298
298
298
298
298
298
298
298
298
298
298
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
150
20
20
20
20
...

result:

ok 100001 numbers

Test #18:

score: 0
Accepted
time: 1115ms
memory: 124008kb

input:

100000 100000
1 317 633 949 1265 1581 1897 2213 2529 2845 3161 3477 3793 4109 4425 4741 5057 5373 5689 6005 6321 6637 6953 7269 7585 7901 8217 8533 8849 9165 9481 9797 10113 10429 10745 11061 11377 11693 12009 12325 12641 12957 13273 13589 13905 14221 14537 14853 15169 15485 15801 16117 16433 16749 ...

output:

316
316
316
316
316
316
316
316
316
316
316
316
316
316
316
316
316
316
316
316
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
5...

result:

ok 100001 numbers

Test #19:

score: 0
Accepted
time: 1074ms
memory: 117940kb

input:

100000 100000
1 317 633 949 1265 1581 1897 2213 2529 2845 3161 3477 3793 4109 4425 4741 5057 5373 5689 6005 6321 6637 6953 7269 7585 7901 8217 8533 8849 9165 9481 9797 10113 10429 10745 11061 11377 11693 12009 12325 12641 12957 13273 13589 13905 14221 14537 14853 15169 15485 15801 16117 16433 16749 ...

output:

316
316
316
316
316
316
316
316
316
316
316
126
126
126
126
126
126
126
126
126
126
126
126
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
99
9...

result:

ok 100001 numbers

Test #20:

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

input:

200 200
1 15 29 43 57 71 85 99 113 127 141 155 169 183 197 2 16 30 44 58 72 86 100 114 128 142 156 170 184 198 3 17 31 45 59 73 87 101 115 129 143 157 171 185 199 4 18 32 46 60 74 88 102 116 130 144 158 172 186 200 5 19 33 47 61 75 89 103 117 131 145 159 173 187 6 20 34 48 62 76 90 104 118 132 146 1...

output:

14
14
8
8
8
8
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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
...

result:

ok 201 numbers

Test #21:

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

input:

200 200
1 15 29 43 57 71 85 99 113 127 141 155 169 183 197 2 16 30 44 58 72 86 100 114 128 142 156 170 184 198 3 17 31 45 59 73 87 101 115 129 143 157 171 185 199 4 18 32 46 60 74 88 102 116 130 144 158 172 186 200 5 19 33 47 61 75 89 103 117 131 145 159 173 187 6 20 34 48 62 76 90 104 118 132 146 1...

output:

14
4
4
4
3
3
3
3
3
3
3
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
1
1
1
1
1
1
1...

result:

ok 201 numbers

Test #22:

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

input:

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

output:

3
2
2
2
2
2
2
2
1
1
1

result:

ok 11 numbers

Test #23:

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

input:

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

output:

3
2
1
1
2
1
1
1
1
1
1

result:

ok 11 numbers

Test #24:

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

input:

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

output:

3
2
2
2
1
1
1
1
2
1
2

result:

ok 11 numbers

Test #25:

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

input:

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

output:

3
2
1
1
1
1
1
1
1
1
1

result:

ok 11 numbers

Test #26:

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

input:

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

output:

3
2
1
1
1
1
1
1
1
1
1

result:

ok 11 numbers

Test #27:

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

input:

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

output:

3
1
1
1
1
2
2
1
1
1
1

result:

ok 11 numbers

Test #28:

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

input:

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

output:

3
1
2
2
1
1
1
1
1
1
1

result:

ok 11 numbers

Test #29:

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

input:

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

output:

3
2
1
2
1
1
1
1
1
1
1

result:

ok 11 numbers

Test #30:

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

input:

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

output:

3
2
3
2
2
1
1
2
2
1
1

result:

ok 11 numbers

Test #31:

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

input:

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

output:

3
2
2
1
1
1
2
2
2
1
1

result:

ok 11 numbers

Test #32:

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

input:

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

output:

3
1
1
1
1
1
1
1
1
1
1

result:

ok 11 numbers

Test #33:

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

input:

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

output:

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

result:

ok 31 numbers

Test #34:

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

input:

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

output:

3
2
2
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1

result:

ok 31 numbers

Test #35:

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

input:

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

output:

3
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 31 numbers

Test #36:

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

input:

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

output:

3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 31 numbers

Test #37:

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

input:

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

output:

3
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1

result:

ok 31 numbers

Test #38:

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

input:

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

output:

3
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1

result:

ok 31 numbers

Test #39:

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

input:

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

output:

3
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 31 numbers

Test #40:

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

input:

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

output:

3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
2
1
1
1
1
1
1
1

result:

ok 31 numbers

Test #41:

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

input:

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

output:

3
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
2

result:

ok 31 numbers

Test #42:

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

input:

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

output:

3
1
1
1
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 31 numbers

Test #43:

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

input:

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

output:

3
2
2
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1

result:

ok 31 numbers

Test #44:

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

input:

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

output:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
2
2
1
1
1
1
2
1
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
2

result:

ok 101 numbers

Test #45:

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

input:

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

output:

2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
2
1
1
2
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1

result:

ok 101 numbers

Test #46:

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

input:

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

output:

2
2
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1

result:

ok 101 numbers

Test #47:

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

input:

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

result:

ok 101 numbers

Test #51:

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

input:

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

output:

2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2

result:

ok 101 numbers

Test #52:

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

input:

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

output:

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

output:

2
1
2
2
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
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
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
2
1
1
1

result:

ok 101 numbers

Test #55:

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

input:

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

output:

2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
2
1
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
2
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 101 numbers

Test #56:

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

input:

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

output:

2
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
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
2
2
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1

result:

ok 101 numbers

Test #57:

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

input:

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

output:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
1
1

result:

ok 101 numbers

Test #58:

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

input:

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

output:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
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
2
1
1
2
1
1
2
2
2
2
1
1
1
1

result:

ok 101 numbers

Test #59:

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

input:

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

output:

2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
2
1
1
1
1
1
1
2
1

result:

ok 101 numbers

Test #60:

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

input:

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

ok 101 numbers

Test #62:

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

input:

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

output:

2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
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
2
1
2
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1

result:

ok 101 numbers

Test #63:

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

input:

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

output:

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
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 101 numbers

Test #64:

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

input:

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

output:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
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
2
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 101 numbers

Test #65:

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

input:

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

output:

2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
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
2
1
1
2
1
2
1
1
1
1
1

result:

ok 101 numbers

Test #66:

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

input:

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

output:

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

result:

ok 10001 numbers

Test #67:

score: 0
Accepted
time: 157ms
memory: 23552kb

input:

97336 10000
46 2162 4278 6394 8510 10626 12742 14858 16974 19090 21206 23322 25438 27554 29670 31786 33902 36018 38134 40250 42366 44482 46598 48714 50830 52946 55062 57178 59294 61410 63526 65642 67758 69874 71990 74106 76222 78338 80454 82570 84686 86802 88918 91034 93150 95266 92 2208 4324 6440 8...

output:

2115
2115
2115
2115
2115
1056
2115
448
2115
270
2115
2115
2115
1053
2115
2115
2115
2115
2115
2115
2115
2115
2115
18
2115
2115
2115
2115
2115
1704
2115
1330
2115
2115
2115
2115
2115
2115
2115
2115
2115
361
2115
348
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
1710
2115
1...

result:

ok 10001 numbers

Test #68:

score: 0
Accepted
time: 157ms
memory: 24148kb

input:

97336 10000
46 2162 4278 6394 8510 10626 12742 14858 16974 19090 21206 23322 25438 27554 29670 31786 33902 36018 38134 40250 42366 44482 46598 48714 50830 52946 55062 57178 59294 61410 63526 65642 67758 69874 71990 74106 76222 78338 80454 82570 84686 86802 88918 91034 93150 95266 92 2208 4324 6440 8...

output:

2115
80
2115
2115
2115
711
2115
988
2115
422
2115
1050
2115
2115
2115
2115
2115
410
2115
552
2115
2115
2115
2115
2115
2115
2115
1079
2115
70
2115
2115
2115
2115
2115
2115
2115
784
2115
2115
2115
2115
2115
226
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
1136
2115
2115
2115
2115
2...

result:

ok 10001 numbers

Test #69:

score: 0
Accepted
time: 157ms
memory: 23772kb

input:

97336 10000
46 2162 4278 6394 8510 10626 12742 14858 16974 19090 21206 23322 25438 27554 29670 31786 33902 36018 38134 40250 42366 44482 46598 48714 50830 52946 55062 57178 59294 61410 63526 65642 67758 69874 71990 74106 76222 78338 80454 82570 84686 86802 88918 91034 93150 95266 92 2208 4324 6440 8...

output:

2115
2115
2115
2115
2115
2115
2115
1020
2115
2115
2115
472
2115
2115
2115
2115
2115
276
2115
2115
2115
2115
2115
274
2115
2115
2115
223
2115
1839
2115
956
2115
1923
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
540
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
1...

result:

ok 10001 numbers

Test #70:

score: 0
Accepted
time: 157ms
memory: 24024kb

input:

97336 10000
46 2162 4278 6394 8510 10626 12742 14858 16974 19090 21206 23322 25438 27554 29670 31786 33902 36018 38134 40250 42366 44482 46598 48714 50830 52946 55062 57178 59294 61410 63526 65642 67758 69874 71990 74106 76222 78338 80454 82570 84686 86802 88918 91034 93150 95266 92 2208 4324 6440 8...

output:

2115
1624
2115
2115
2115
2115
2115
1356
2115
70
2115
114
2115
2115
2115
2115
2115
2115
2115
2000
2115
404
2115
2115
2115
1708
2115
2115
2115
1515
2115
2070
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
2115
1740
2115
588
2115
2115
2115
286
2115
2115
2115
2115
2115
1952
2115
2115
2115
1905
2115
2...

result:

ok 10001 numbers

Test #71:

score: 0
Accepted
time: 161ms
memory: 24052kb

input:

97336 10000
46 2162 4278 6394 8510 10626 12742 14858 16974 19090 21206 23322 25438 27554 29670 31786 33902 36018 38134 40250 42366 44482 46598 48714 50830 52946 55062 57178 59294 61410 63526 65642 67758 69874 71990 74106 76222 78338 80454 82570 84686 86802 88918 91034 93150 95266 92 2208 4324 6440 8...

output:

2115
1497
2115
240
2115
2115
2115
2115
2115
1035
2115
2115
2115
2115
2115
574
2115
910
2115
2115
2115
953
2115
2115
2115
1764
2115
2115
2115
1527
2115
2115
2115
1150
2115
1004
2115
592
2115
2115
2115
2115
2115
1400
2115
2115
2115
2115
2115
2115
2115
1860
2115
2115
2115
808
2115
795
2115
2115
2115
69...

result:

ok 10001 numbers

Test #72:

score: 0
Accepted
time: 130ms
memory: 20136kb

input:

64000 10000
40 1640 3240 4840 6440 8040 9640 11240 12840 14440 16040 17640 19240 20840 22440 24040 25640 27240 28840 30440 32040 33640 35240 36840 38440 40040 41640 43240 44840 46440 48040 49640 51240 52840 54440 56040 57640 59240 60840 62440 80 1680 3280 4880 6480 8080 9680 11280 12880 14480 16080 ...

output:

1599
1599
1599
1599
1599
560
1599
788
1599
916
1599
518
1599
1599
1599
205
1599
1584
1599
1459
1599
1599
1599
1599
1599
1562
1599
1599
1599
1599
1599
501
1599
665
1599
1599
1599
488
1599
1244
1599
1599
1599
1599
1599
1599
1599
12
1599
955
1599
1599
1599
866
1599
975
1599
1176
1599
1057
1599
1232
159...

result:

ok 10001 numbers

Test #73:

score: 0
Accepted
time: 92ms
memory: 15956kb

input:

27000 10000
30 930 1830 2730 3630 4530 5430 6330 7230 8130 9030 9930 10830 11730 12630 13530 14430 15330 16230 17130 18030 18930 19830 20730 21630 22530 23430 24330 25230 26130 60 960 1860 2760 3660 4560 5460 6360 7260 8160 9060 9960 10860 11760 12660 13560 14460 15360 16260 17160 18060 18960 19860 ...

output:

899
899
899
899
899
251
899
899
899
899
899
891
899
899
899
899
899
27
899
216
899
25
899
899
899
899
899
516
899
899
899
555
899
282
899
899
899
208
899
508
899
300
899
380
899
30
899
899
899
636
899
899
899
212
899
220
899
899
899
270
899
382
899
899
899
414
899
777
899
899
899
899
899
448
899
899...

result:

ok 10001 numbers

Test #74:

score: 0
Accepted
time: 108ms
memory: 16832kb

input:

42875 10000
35 1260 2485 3710 4935 6160 7385 8610 9835 11060 12285 13510 14735 15960 17185 18410 19635 20860 22085 23310 24535 25760 26985 28210 29435 30660 31885 33110 34335 35560 36785 38010 39235 40460 41685 70 1295 2520 3745 4970 6195 7420 8645 9870 11095 12320 13545 14770 15995 17220 18445 1967...

output:

1224
1212
1224
1224
1224
768
1224
1224
1224
1224
1224
336
1224
1224
1224
1224
1224
1224
1224
124
1224
1224
1224
1224
1224
1224
1224
1224
1224
890
1224
807
1224
282
1224
1224
1224
1224
1224
1224
1224
756
1224
49
1224
1224
1224
124
1224
99
1224
1224
1224
344
1224
1224
1224
1224
1224
204
1224
534
1224
...

result:

ok 10001 numbers

Test #75:

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

input:

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

output:

2
2
1
2
2
1
1
1
1

result:

ok 9 numbers

Test #76:

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

input:

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

output:

8
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

result:

ok 28 numbers

Test #77:

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

input:

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

output:

9
3
3
3
3
3
3
3
3
8
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 28 numbers

Test #78:

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

input:

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

output:

6
3
3
3
3
3
3
3
3
4
4
4
6
6
6
6
6
6
8
2
2
1
1
1
1
1
1
1

result:

ok 28 numbers

Test #79:

score: 0
Accepted
time: 442ms
memory: 32296kb

input:

42875 42875
4 1229 2454 3679 4904 6129 7354 8579 9804 11029 12254 13479 14704 15929 17154 18379 19604 20829 22054 23279 24504 25729 26954 28179 29404 30629 31854 33079 34304 35529 36754 37979 39204 40429 41654 39 1264 2489 3714 4939 6164 7389 8614 9839 11064 12289 13514 14739 15964 17189 18414 19639...

output:

144
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
140
...

result:

ok 42876 numbers

Test #80:

score: 0
Accepted
time: 765ms
memory: 45584kb

input:

64000 64000
40 1640 3240 4840 6440 8040 9640 11240 12840 14440 16040 17640 19240 20840 22440 24040 25640 27240 28840 30440 32040 33640 35240 36840 38440 40040 41640 43240 44840 46440 48040 49640 51240 52840 54440 56040 57640 59240 60840 62440 80 1680 3280 4880 6480 8080 9680 11280 12880 14480 16080 ...

output:

410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
410
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
440
...

result:

ok 64001 numbers

Test #81:

score: 0
Accepted
time: 1307ms
memory: 70444kb

input:

97336 97336
27 2143 4259 6375 8491 10607 12723 14839 16955 19071 21187 23303 25419 27535 29651 31767 33883 35999 38115 40231 42347 44463 46579 48695 50811 52927 55043 57159 59275 61391 63507 65623 67739 69855 71971 74087 76203 78319 80435 82551 84667 86783 88899 91015 93131 95247 73 2189 4305 6421 8...

output:

423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
423
...

result:

ok 97337 numbers

Test #82:

score: 0
Accepted
time: 1326ms
memory: 70736kb

input:

97336 97336
11 2127 4243 6359 8475 10591 12707 14823 16939 19055 21171 23287 25403 27519 29635 31751 33867 35983 38099 40215 42331 44447 46563 48679 50795 52911 55027 57143 59259 61375 63491 65607 67723 69839 71955 74071 76187 78303 80419 82535 84651 86767 88883 90999 93115 95231 57 2173 4289 6405 8...

output:

141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
141
...

result:

ok 97337 numbers

Test #83:

score: 0
Accepted
time: 1299ms
memory: 74924kb

input:

97336 97336
25 2141 4257 6373 8489 10605 12721 14837 16953 19069 21185 23301 25417 27533 29649 31765 33881 35997 38113 40229 42345 44461 46577 48693 50809 52925 55041 57157 59273 61389 63505 65621 67737 69853 71969 74085 76201 78317 80433 82549 84665 86781 88897 91013 93129 95245 71 2187 4303 6419 8...

output:

658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
658
...

result:

ok 97337 numbers

Test #84:

score: 0
Accepted
time: 426ms
memory: 32416kb

input:

42875 42875
13 1238 2463 3688 4913 6138 7363 8588 9813 11038 12263 13488 14713 15938 17163 18388 19613 20838 22063 23288 24513 25738 26963 28188 29413 30638 31863 33088 34313 35538 36763 37988 39213 40438 41663 48 1273 2498 3723 4948 6173 7398 8623 9848 11073 12298 13523 14748 15973 17198 18423 1964...

output:

324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
324
...

result:

ok 42876 numbers

Test #85:

score: 0
Accepted
time: 759ms
memory: 47888kb

input:

64000 64000
9 1609 3209 4809 6409 8009 9609 11209 12809 14409 16009 17609 19209 20809 22409 24009 25609 27209 28809 30409 32009 33609 35209 36809 38409 40009 41609 43209 44809 46409 48009 49609 51209 52809 54409 56009 57609 59209 60809 62409 49 1649 3249 4849 6449 8049 9649 11249 12849 14449 16049 1...

output:

287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
287
...

result:

ok 64001 numbers

Test #86:

score: 0
Accepted
time: 1291ms
memory: 67752kb

input:

97336 97336
42 2158 4274 6390 8506 10622 12738 14854 16970 19086 21202 23318 25434 27550 29666 31782 33898 36014 38130 40246 42362 44478 46594 48710 50826 52942 55058 57174 59290 61406 63522 65638 67754 69870 71986 74102 76218 78334 80450 82566 84682 86798 88914 91030 93146 95262 88 2204 4320 6436 8...

output:

376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
376
...

result:

ok 97337 numbers

Test #87:

score: 0
Accepted
time: 1310ms
memory: 69760kb

input:

97336 97336
41 2157 4273 6389 8505 10621 12737 14853 16969 19085 21201 23317 25433 27549 29665 31781 33897 36013 38129 40245 42361 44477 46593 48709 50825 52941 55057 57173 59289 61405 63521 65637 67753 69869 71985 74101 76217 78333 80449 82565 84681 86797 88913 91029 93145 95261 87 2203 4319 6435 8...

output:

94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
94
...

result:

ok 97337 numbers

Test #88:

score: 0
Accepted
time: 1346ms
memory: 73656kb

input:

97336 97336
23 2139 4255 6371 8487 10603 12719 14835 16951 19067 21183 23299 25415 27531 29647 31763 33879 35995 38111 40227 42343 44459 46575 48691 50807 52923 55039 57155 59271 61387 63503 65619 67735 69851 71967 74083 76199 78315 80431 82547 84663 86779 88895 91011 93127 95243 69 2185 4301 6417 8...

output:

282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
282
...

result:

ok 97337 numbers

Test #89:

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

input:

3375 3375
6 231 456 681 906 1131 1356 1581 1806 2031 2256 2481 2706 2931 3156 21 246 471 696 921 1146 1371 1596 1821 2046 2271 2496 2721 2946 3171 36 261 486 711 936 1161 1386 1611 1836 2061 2286 2511 2736 2961 3186 51 276 501 726 951 1176 1401 1626 1851 2076 2301 2526 2751 2976 3201 66 291 516 741 ...

output:

48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
48
...

result:

ok 3376 numbers

Test #90:

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

input:

1000 1000
5 105 205 305 405 505 605 705 805 905 15 115 215 315 415 515 615 715 815 915 25 125 225 325 425 525 625 725 825 925 35 135 235 335 435 535 635 735 835 935 45 145 245 345 445 545 645 745 845 945 55 155 255 355 455 555 655 755 855 955 65 165 265 365 465 565 665 765 865 965 75 175 275 375 475...

output:

55
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
44
44
44
44
44
44
44
44
44
...

result:

ok 1001 numbers

Test #91:

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

input:

512 512
8 72 136 200 264 328 392 456 16 80 144 208 272 336 400 464 24 88 152 216 280 344 408 472 32 96 160 224 288 352 416 480 40 104 168 232 296 360 424 488 48 112 176 240 304 368 432 496 56 120 184 248 312 376 440 504 64 128 192 256 320 384 448 512 5 69 133 197 261 325 389 453 13 77 141 205 269 33...

output:

18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
...

result:

ok 513 numbers

Test #92:

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

input:

512 512
7 71 135 199 263 327 391 455 15 79 143 207 271 335 399 463 23 87 151 215 279 343 407 471 31 95 159 223 287 351 415 479 39 103 167 231 295 359 423 487 47 111 175 239 303 367 431 495 55 119 183 247 311 375 439 503 63 127 191 255 319 383 447 511 2 66 130 194 258 322 386 450 10 74 138 202 266 33...

output:

27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
27
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
...

result:

ok 513 numbers

Test #93:

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

input:

343 343
3 52 101 150 199 248 297 10 59 108 157 206 255 304 17 66 115 164 213 262 311 24 73 122 171 220 269 318 31 80 129 178 227 276 325 38 87 136 185 234 283 332 45 94 143 192 241 290 339 1 50 99 148 197 246 295 8 57 106 155 204 253 302 15 64 113 162 211 260 309 22 71 120 169 218 267 316 29 78 127 ...

output:

32
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
21
8
8
8
8
8
8
8
8
8
8
8
8
8
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
16
16
16
16
16
16
1...

result:

ok 344 numbers

Test #94:

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

input:

512 512
5 69 133 197 261 325 389 453 13 77 141 205 269 333 397 461 21 85 149 213 277 341 405 469 29 93 157 221 285 349 413 477 37 101 165 229 293 357 421 485 45 109 173 237 301 365 429 493 53 117 181 245 309 373 437 501 61 125 189 253 317 381 445 509 8 72 136 200 264 328 392 456 16 80 144 208 272 33...

output:

9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
36
...

result:

ok 513 numbers

Test #95:

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

input:

512 512
4 68 132 196 260 324 388 452 12 76 140 204 268 332 396 460 20 84 148 212 276 340 404 468 28 92 156 220 284 348 412 476 36 100 164 228 292 356 420 484 44 108 172 236 300 364 428 492 52 116 180 244 308 372 436 500 60 124 188 252 316 380 444 508 6 70 134 198 262 326 390 454 14 78 142 206 270 33...

output:

18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
...

result:

ok 513 numbers

Test #96:

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

input:

343 343
1 50 99 148 197 246 295 8 57 106 155 204 253 302 15 64 113 162 211 260 309 22 71 120 169 218 267 316 29 78 127 176 225 274 323 36 85 134 183 232 281 330 43 92 141 190 239 288 337 6 55 104 153 202 251 300 13 62 111 160 209 258 307 20 69 118 167 216 265 314 27 76 125 174 223 272 321 34 83 132 ...

output:

40
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
42
48
18
18
6
6
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 344 numbers

Test #97:

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

input:

512 512
3 67 131 195 259 323 387 451 11 75 139 203 267 331 395 459 19 83 147 211 275 339 403 467 27 91 155 219 283 347 411 475 35 99 163 227 291 355 419 483 43 107 171 235 299 363 427 491 51 115 179 243 307 371 435 499 59 123 187 251 315 379 443 507 1 65 129 193 257 321 385 449 9 73 137 201 265 329 ...

output:

45
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
...

result:

ok 513 numbers

Test #98:

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

input:

512 512
8 72 136 200 264 328 392 456 16 80 144 208 272 336 400 464 24 88 152 216 280 344 408 472 32 96 160 224 288 352 416 480 40 104 168 232 296 360 424 488 48 112 176 240 304 368 432 496 56 120 184 248 312 376 440 504 64 128 192 256 320 384 448 512 4 68 132 196 260 324 388 452 12 76 140 204 268 33...

output:

36
36
36
36
36
36
36
36
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
40
18
18
18
18
18
18
18
18
18
18
18
18
18
18
18
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
...

result:

ok 513 numbers

Test #99:

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

input:

343 343
7 56 105 154 203 252 301 14 63 112 161 210 259 308 21 70 119 168 217 266 315 28 77 126 175 224 273 322 35 84 133 182 231 280 329 42 91 140 189 238 287 336 49 98 147 196 245 294 343 5 54 103 152 201 250 299 12 61 110 159 208 257 306 19 68 117 166 215 264 313 26 75 124 173 222 271 320 33 82 13...

output:

24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
24
32
32
32
32
32
32
32
32
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
35
32
32
32
32
32
32
32
32
...

result:

ok 344 numbers

Test #100:

score: 0
Accepted
time: 563ms
memory: 45548kb

input:

97338 97336
46 2162 4278 6394 8510 10626 12742 14858 16974 19090 21206 23322 25438 27554 29670 31786 33902 36018 38134 40250 42366 44482 46598 48714 50830 52946 55062 57178 59294 61410 63526 65642 67758 69874 71990 74106 76222 78338 80454 82570 84686 86802 88918 91034 93150 95266 92 2208 4324 6440 8...

output:

1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
1
24
...

result:

ok 97337 numbers