QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303015#7807. LoopsPhantomThreshold#AC ✓45ms20332kbC++202.0kb2024-01-11 16:52:392024-01-11 16:52:40

Judging History

This is the latest submission verdict.

  • [2024-01-11 16:52:40]
  • Judged
  • Verdict: AC
  • Time: 45ms
  • Memory: 20332kb
  • [2024-01-11 16:52:39]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<string> a(n+5);
	for(int i=1;i<n;i++)
	{
		string s;
		cin>>s;
		a[i]=' '+s;
	}
	auto hs=[&](int x,int y)
	{
		return (x-1)*m+y;
	};
	vector<vector<int>> G(n*m+5);
	vector<int> deg(n*m+5);
	auto addedge=[&](int u,int v)
	{
//		cerr<<"addedge "<<u<<' '<<v<<endl;
		G[u].push_back(v);
		deg[v]++;
	};
	//0:down, 1:up
	vector<vector<int>> ty(n+5,vector<int>(m+5));
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(a[i][j]=='1')
			{
				if(ty[i][j])
				{
					ty[i][j+1]=1;
					addedge(hs(i+1,j),hs(i+1,j+1));
					addedge(hs(i+1,j+1),hs(i,j));
					addedge(hs(i,j),hs(i,j+1));
				}
				else
				{
					ty[i][j+1]=0;
					addedge(hs(i,j),hs(i,j+1));
					addedge(hs(i,j+1),hs(i+1,j));
					addedge(hs(i+1,j),hs(i+1,j+1));
				}
			}
			else if(a[i][j]=='2')
			{
				if(ty[i][j])
				{
					ty[i][j+1]=0;
					addedge(hs(i+1,j),hs(i,j));
					addedge(hs(i,j),hs(i,j+1));
					addedge(hs(i,j+1),hs(i+1,j+1));
				}
				else
				{
					ty[i][j+1]=1;
					addedge(hs(i,j),hs(i+1,j));
					addedge(hs(i+1,j),hs(i+1,j+1));
					addedge(hs(i+1,j+1),hs(i,j+1));
				}
			}
			else
			{
				if(ty[i][j])
				{
					ty[i][j+1]=1;
					addedge(hs(i+1,j),hs(i,j));
					addedge(hs(i,j),hs(i+1,j+1));
					addedge(hs(i+1,j+1),hs(i,j+1));
				}
				else
				{
					ty[i][j+1]=0;
					addedge(hs(i,j),hs(i+1,j));
					addedge(hs(i+1,j),hs(i,j+1));
					addedge(hs(i,j+1),hs(i+1,j+1));
				}
			}
		}
	}
	vector<int> ans(n*m+5);
	queue<int> q;
	for(int i=1;i<=n*m;i++)
	{
		if(deg[i]==0)q.push(i);
	}
	int idx=0;
	while(not q.empty())
	{
		int u=q.front();q.pop();
		ans[u]=++idx;
		for(auto v:G[u])
		{
			deg[v]--;
			if(deg[v]==0)
			{
				q.push(v);
			}
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cout<<ans[hs(i,j)]<<" \n"[j==m];
		}
	return 0;
}

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

详细

Test #1:

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

input:

3 4
113
231

output:

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

result:

ok 

Test #2:

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

input:

2 2
1

output:

1 2
3 4

result:

ok 

Test #3:

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

input:

2 2
2

output:

1 4
2 3

result:

ok 

Test #4:

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

input:

2 2
3

output:

1 3
2 4

result:

ok 

Test #5:

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

input:

10 10
332133211
312132213
221223223
213231333
212221111
311132221
312232123
123132221
112112133

output:

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

result:

ok 

Test #6:

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

input:

20 20
2211223333122331122
3331311131211112312
2223231233212131113
1333132112122133111
3213311331223233331
1221321331233112122
1121231321232232222
2232213321133123222
1132113323222231313
1312131323132213333
3311112222223332131
2223312233231113113
2132333222332312223
1112323111213123112
13333212331311...

output:

1 6 8 11 14 47 50 57 65 73 228 230 287 293 303 315 318 322 336 340
2 4 13 18 21 44 53 61 70 225 232 245 281 297 309 321 325 330 333 353
3 9 16 35 42 58 66 74 222 235 239 241 243 277 282 304 328 337 341 348
5 7 19 33 39 62 140 167 219 226 237 246 265 270 274 288 298 305 311 344
10 15 31 36 67 134 144...

result:

ok 

Test #7:

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

input:

50 50
1332131133132323222112321123131221312233322122223
2221231213232322112331221312322112322311122221123
1123133112313113133322131132321333112332213213331
2211311121212313132213233111332323333231213213211
3213111221231131223123231131232311332333311131222
33211133322223112231133211113231232213123112...

output:

1 2 8 12 72 75 85 535 545 561 590 599 614 621 657 676 754 760 799 806 815 826 879 1326 1335 1345 1358 1414 1503 1509 1645 1653 1662 1780 1789 1832 1838 1846 2020 2034 2051 2071 2082 2241 2250 2260 2285 2294 2476 2480
3 6 10 65 68 70 78 82 528 553 571 581 607 648 666 671 747 783 791 825 844 862 871 1...

result:

ok 

Test #8:

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

input:

100 100
313212312322233331312323312332132331313321221212212131211311112113112312322211333333322323131311231
312312132132131211223133231112313131131133222132323231232333112213131232133331131132133222232221333
21311321231223313122231331333213122212113312122322333111113232313312212231121333332321322113...

output:

1 3 5 11 90 94 98 104 109 205 215 222 237 243 255 637 654 779 788 816 826 956 980 991 1007 1815 1829 1895 1921 1949 1962 1976 2474 2544 2571 2838 2851 2984 2995 3018 3045 3059 3071 4445 4456 4465 4656 4673 4690 4871 4891 4908 4925 5010 5025 5348 5387 5405 5481 5758 5776 5793 5807 5824 5838 5853 5992...

result:

ok 

Test #9:

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

input:

200 200
1233323221211232311113332333232111313131133121323322113313331121312123331121131233131131212221212121322231231333231213122232133122122231313133221233211322111123232232323232221132223323332312332211322
21332332123232121213222231221121113212231313332313112133223111232211133133131211112113112321...

output:

1 2 18 24 34 42 47 60 121 124 126 159 187 194 200 216 275 305 318 377 396 402 413 435 449 458 1080 1105 1159 1195 1221 1237 1252 1267 1286 3712 3741 3823 3845 6070 6093 6116 6205 6310 6333 6565 6584 7914 7945 8114 8169 8815 8846 8878 8912 9009 9111 9140 9368 9425 9485 9520 9554 10937 10958 11131 111...

result:

ok 

Test #10:

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

input:

300 300
3311223122331113313232133212111231323122311111231321321213311311223122233323333132332232323332312322221323323333232321123321332123331132313333121313313331312211322211311113222113233311321131311211122122313222233123221311212231212221311323332223213123221113233123111131112321222323313333321121...

output:

1 3 5 7 9 33 37 60 66 165 171 241 252 261 269 279 363 382 392 416 1008 1032 1046 1059 1100 1373 1502 1518 1534 1544 1558 1570 2838 2910 2927 2963 2986 3038 3062 3681 3707 3758 3779 3802 3824 3846 3869 5959 6063 6091 6169 6192 6215 6290 6540 6566 6593 6620 6690 10384 10422 10458 10556 10587 10621 121...

result:

ok 

Test #11:

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

input:

400 400
1111113223123311131222231121323322132111222131332233123133331313321122332211312131233113332212112333322333232212133332323123223121323232113111122122321213132333132312232321123223112332221221321321132133231121331233221223332113133133223333313311331311131331131322133321121331232321232332232331...

output:

1 2 4 6 8 11 14 94 113 121 132 137 178 189 600 625 687 702 755 767 780 1115 1123 1155 1234 1249 1265 1280 1294 1660 1746 1824 1862 1882 2000 2019 2055 2073 2092 2109 2127 3839 3863 4048 4072 4363 4382 4433 6562 6590 6699 6752 6871 6897 6923 7549 7578 7702 8527 8644 8708 8742 8859 8899 9318 9399 9599...

result:

ok 

Test #12:

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

input:

2 500
133313131212111213113123132322133111323331323213121233222213321221323231313331312223211231111112211313132133321112312333232313123223211131121131223122213231213122221133131113211331311111133222221111221111232332122332221121331213233333122232123122221121331232223313223111233221222121323132222311...

output:

1 2 5 7 9 10 13 14 17 18 23 24 25 26 28 30 35 36 39 41 42 45 46 47 49 50 53 56 58 59 63 64 66 69 71 73 74 76 77 79 81 83 84 87 90 92 93 94 97 98 103 104 105 107 109 112 113 116 117 118 121 123 127 128 129 133 134 136 137 139 142 145 146 149 150 152 154 157 158 161 162 163 166 167 169 173 175 176 177...

result:

ok 

Test #13:

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

input:

500 2
1
3
3
1
1
2
1
2
1
3
2
1
2
1
3
3
3
3
3
3
1
2
3
2
3
3
1
3
1
2
3
2
1
2
3
3
2
2
2
3
1
2
2
2
2
2
1
1
3
3
3
3
1
3
1
2
2
3
1
3
1
3
2
2
3
2
2
3
2
3
2
2
2
2
3
3
3
2
3
3
3
2
2
1
2
1
3
1
1
2
2
1
3
2
3
1
1
1
3
1
2
2
1
2
1
2
1
2
1
1
3
3
2
2
1
1
1
3
3
3
2
1
1
1
3
1
2
2
2
1
1
3
3
3
3
1
1
2
2
1
2
2
2
3
1
2
2
...

output:

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

result:

ok 

Test #14:

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

input:

500 500
3222313321212112132211312331222113112212133113211232222333321313232232233113321313131221133123212131231113321222331133221312322133212132213311132232133222323122322113223233122211331321213313333321113132221322312233233132121322121312131311322232232233311111333333212213232221111133111231133221...

output:

1 3 28 32 102 127 134 173 182 186 191 276 280 286 293 300 836 852 879 894 947 1014 1027 1149 1162 1175 1200 1226 1240 1328 1341 2618 2639 2657 2724 2847 2863 2876 3143 3162 3182 3203 3295 3382 3406 3432 3535 3691 4532 4560 4595 4642 4707 4732 10175 10210 10277 10346 10475 10543 11987 12032 12151 121...

result:

ok 

Test #15:

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

input:

500 500
1111111111111111111111111111111111111111111311111111111111111111111131111111111112111111111111311111111311111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111211111111111111111111111111111111111111111111121111231111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 181 194 206 218 231 245 259 273 287 302 317 333 349 365 380 396 412 428 446 505 526 548 570 591 614 635 658 682 707 731 755 779 806 832 859 885 911 937 964 991 1020 1051 1083 1114 1358 1387 1416 1450 1484 1522 1561 1599 163...

result:

ok 

Test #16:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222221222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222212222222222222222222222222222222222222222222222223222222222222222222222222222222222222222222222222222222...

output:

1 421 424 1511 1521 2703 2718 2865 2882 3044 3062 4706 4733 4920 4949 6475 6512 9025 9077 9954 10007 10930 10979 12117 12166 12743 12800 13252 13306 13735 13784 14759 14809 17174 17225 18727 18780 21664 21725 21898 21957 22543 22601 23224 23271 23917 23973 24476 24532 25015 25074 25565 25613 26044 2...

result:

ok 

Test #17:

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

input:

500 500
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333233333333333333233333333333333333331333333333333333331333133333333333333333333333333333333333333333333333333333333333333333333333333333333333333333313333333333333333333333333333333333333333333333333...

output:

1 3 7 11 22 30 49 61 73 100 116 147 168 190 214 240 299 333 369 407 444 480 516 556 597 684 730 776 825 874 924 1032 1094 1158 1341 1406 1531 1596 1665 1734 2029 2240 2313 2387 2464 2544 2704 3070 3170 3573 3671 3765 3868 4291 4407 4521 5277 5509 5627 5749 5866 5982 6097 6215 6334 6451 6571 6690 681...

result:

ok 

Test #18:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 ...

result:

ok 

Test #19:

score: 0
Accepted
time: 43ms
memory: 20192kb

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 1000 1001 2000 2001 3000 3001 4000 4001 5000 5001 6000 6001 7000 7001 8000 8001 9000 9001 10000 10001 11000 11001 12000 12001 13000 13001 14000 14001 15000 15001 16000 16001 17000 17001 18000 18001 19000 19001 20000 20001 21000 21001 22000 22001 23000 23001 24000 24001 25000 25001 26000 26001 2700...

result:

ok 

Test #20:

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

input:

500 500
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

output:

1 3 7 13 21 31 43 57 73 91 111 133 157 183 211 241 273 307 343 381 421 463 507 553 601 651 703 757 813 871 931 993 1057 1123 1191 1261 1333 1407 1483 1561 1641 1723 1807 1893 1981 2071 2163 2257 2353 2451 2551 2653 2757 2863 2971 3081 3193 3307 3423 3541 3661 3783 3907 4033 4161 4291 4423 4557 4693 ...

result:

ok 

Test #21:

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

input:

5 6
31323
21231
12312
23331

output:

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

result:

ok 

Test #22:

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

input:

13 8
2331112
3321121
2123131
1132132
1322123
1121123
1113323
2221132
2223233
1231311
1312132
2132321

output:

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

result:

ok 

Test #23:

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

input:

23 42
33333331332231231323231212313222133321121
31233133331232213332132321323133121233231
33133113212333331313311213313212332123311
33223113233332121231221232122122223232232
11213221333231211333312321211313313211123
31311121113113133311221123233131122213321
21213121311132111312333132122323322323131
...

output:

1 3 7 10 20 50 63 71 75 96 268 290 295 303 309 338 364 370 381 387 420 465 479 486 492 498 639 670 673 680 683 703 709 716 732 793 799 866 890 893 897 901
2 5 9 17 47 58 68 81 91 262 280 285 299 315 330 335 341 359 375 417 457 461 470 474 503 626 632 659 665 677 686 698 722 728 790 796 802 810 861 8...

result:

ok 

Test #24:

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

input:

111 78
23121233313321232121333332113113322223322232121133221311132322123321123111132
33112122333333132223313123123123312132212211231222133323123232232211113221332
31233211311332323113323122311233132332223123112321221131323122333123311323213
31233112331313231111332332332333111213233221231131313113321...

output:

1 6 12 14 16 18 163 176 192 217 224 236 249 255 261 704 735 751 770 1010 1027 1206 1239 1336 1360 1418 1435 1452 1467 1800 1815 1830 1934 2845 2939 2954 3003 3021 3389 3441 3490 3505 3581 3620 3639 3655 4391 4403 4413 4524 4545 4556 6901 6918 7054 7112 7130 7149 7182 7202 7242 7361 7371 7380 7450 74...

result:

ok 

Test #25:

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

input:

239 432
1211133322222211233323123332311321322321231321333222133131213312213133113331121231223112212122131222231332223111113111321232212311121132133133231332232123332323333211131131331123332313333113211131311331213231321122333332311113112231312111223322232313213112211113231113121132331232211221332221...

output:

1 2 140 146 151 157 169 182 203 209 239 249 503 516 700 708 715 722 733 746 782 1069 1114 1128 1144 1371 1428 1456 1526 3258 3275 3295 3338 3361 3385 4379 4440 4464 4504 5997 6013 6032 6069 6084 6405 6499 6520 6562 7450 7497 7521 7662 7690 7712 7931 7974 8001 8078 8106 8299 8322 8365 8424 8443 8462 ...

result:

ok 

Test #26:

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

input:

488 466
3323323332313211122332111313223213332133112332322232113231232223331223233233323111213132333321311321113231223223313233212133233332231113233332223231133112222133312112133212331311122321333332122122223323232311232222111212222233123112322332223312211233213321113111211321322112132112221333213231...

output:

1 3 25 37 44 59 63 69 83 372 610 691 700 718 729 739 751 764 988 999 1028 1047 1156 1185 1211 1224 4307 4330 4381 4409 4495 4548 4575 4602 4822 4864 4911 5369 5396 5446 5606 5633 5664 5695 5751 6004 6080 6477 6505 6594 6617 6662 6862 8458 8491 8654 8686 8755 8794 9257 9318 9354 9702 9740 9991 10065 ...

result:

ok 

Test #27:

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

input:

498 499
3123233112131322112121113331221121123223333321122111132312112232113331311321123212131312221123211222312212131111133333313311331331312121322221111222213333333212221131113233122123232332211121111123133211113332221333213111211332322131223231321212131131322232311331113333311132122332232332132331...

output:

1 3 5 12 18 22 132 226 232 238 304 311 331 339 354 362 465 482 495 509 523 1192 1220 1233 1244 1275 1305 1900 1919 1937 2864 2912 2938 2963 2989 3013 3450 3499 3520 3584 4308 4402 4447 4502 4567 4594 4615 4637 6027 6056 6087 6120 6151 6181 8729 9056 9160 9191 9219 9246 9274 10900 10930 10992 11352 1...

result:

ok 

Test #28:

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

input:

500 499
3123313312332121332313133312313232131113323131112123321322122331123121222123321222222122231223213121212232312213111113113121212313223131212212231112323111333311311223222223123113131323212233111312211222112233333113113113211232121321121131211231331331223112313333113323212112321223212323322332...

output:

1 3 5 111 120 136 142 185 206 216 225 400 414 559 569 577 586 663 723 771 921 935 984 995 1019 1084 1220 1234 1246 1265 1277 2029 2099 2135 2152 2172 3859 3888 3918 3952 6364 6737 6884 7005 7039 7457 7516 7550 7588 7627 7663 7793 7862 7929 7962 7996 8099 9262 9299 9336 9877 9905 9971 10036 10072 101...

result:

ok 

Test #29:

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

input:

499 500
2233333331322123232123323323133112221222132221213313122313133111112311222113131122122111112113313322212311133232332213322323321221112323232232112122111133213123312121321213132231331211131313133331331331312322312232232311333223213113313333111313121112313311213123131132221332231223323111332112...

output:

1 4 6 19 23 31 39 199 213 222 227 488 520 532 543 643 677 688 727 1084 1102 1120 1148 1171 1268 1301 1332 1351 2999 3019 3079 3120 3143 3169 3345 3360 3825 3848 3872 3928 3946 3964 4147 4561 4582 4699 4718 4740 4762 4837 5483 5513 5742 5760 5945 5971 6020 6039 6133 6161 10172 10278 10314 10351 10384...

result:

ok 

Test #30:

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

input:

499 499
3331311322112121132231112131211232313223221112211231221332131112333233233123232331133312332213113312123123131221212321211132223131121332231133211332313321223323112323321133231311331111132232211322312112233333313111111222122233311121333223331323133311322131221123322312212221223231321131221222...

output:

1 3 7 9 11 78 82 87 322 380 387 394 403 573 585 594 604 618 1263 1353 1369 1402 1416 1432 1446 1533 1542 1735 1751 1763 1774 1789 1998 2717 2738 2779 2802 3164 3230 3246 3278 3327 3345 3361 3379 3397 4986 5002 5019 5042 5223 8245 8279 8313 8529 8566 8643 8725 8765 8806 10068 10115 10163 10210 10926 ...

result:

ok 

Test #31:

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

input:

3 500
132123121213333113221113211321121223122233232311333232223212312313311233212212221223132231323212123121211213322123111313121132323221332222322312223211212322221211233331232121332112231332211132211312111221233131332112132232123332232311121133133232212321321233132131121321112222312313231311311211...

output:

1 2 7 13 15 17 19 21 28 30 31 32 36 39 41 45 47 49 55 58 60 61 63 65 74 79 82 84 87 88 89 91 103 105 106 109 113 115 116 120 122 124 126 131 134 136 140 141 143 147 149 154 159 162 163 167 168 170 178 179 180 182 184 190 195 197 200 204 207 209 211 215 217 223 224 225 233 235 236 239 240 241 249 251...

result:

ok 

Test #32:

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

input:

500 3
12
23
11
33
32
32
21
21
12
23
31
33
21
33
12
12
13
21
22
23
32
13
13
31
23
13
22
13
23
21
11
11
12
32
21
21
31
32
31
11
33
11
12
12
12
32
32
12
13
31
22
32
33
11
33
21
13
31
33
23
31
33
31
33
21
21
32
13
31
31
21
13
12
23
31
22
32
21
22
33
33
32
12
22
21
22
23
33
13
31
11
11
23
11
31
22
31
12
...

output:

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

result:

ok 

Test #33:

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

input:

5 500
323321131213321113313131221133323123222231222231233122121112131321232112111111311332123221111321311123122311131132122111211213333221111123111313311211132333212223232131332311332213213113313332133231122213211113313113133131113221121332122333321312122333211132322331223133133313123113322122311121...

output:

1 3 18 21 25 28 30 33 38 40 62 64 68 70 71 72 74 76 92 98 99 104 105 108 110 125 128 131 133 145 150 157 172 178 180 182 184 196 199 205 207 211 213 221 223 231 233 237 240 249 262 268 269 270 280 282 284 287 289 292 306 308 320 322 324 326 328 345 350 352 354 357 373 376 379 387 390 397 398 401 404...

result:

ok 

Test #34:

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

input:

500 5
2312
3122
2223
3222
1211
2211
3212
2132
1211
3232
3133
3132
2233
1231
2121
2213
2112
1233
1122
1113
2222
1221
2312
2311
2211
1311
1123
1123
2331
1313
2233
1113
2211
3223
1232
2122
1111
2211
2123
3213
3122
2122
2133
2231
2121
3231
1221
3212
3123
3132
1323
1131
3331
1223
3312
3113
2121
1312
2313...

output:

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

result:

ok 

Test #35:

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

input:

14 500
13222332332231221131213212121133132321123223111233223312222121211112111311313332333111112232111223211223222331113313212111313332331312333232311231322331221223232333233213231232132113332331132122132131221122131112212313113112131112332212311213131232231123113311123211131122222333112212333221322...

output:

1 2 5 16 19 46 54 91 95 153 163 177 180 200 204 212 215 219 223 238 241 288 293 299 302 306 370 373 377 380 385 424 447 451 461 480 496 500 505 510 575 579 582 598 612 666 670 674 678 691 697 717 721 738 748 753 801 805 835 838 841 863 867 871 873 876 879 883 930 936 1000 1003 1011 1038 1041 1051 10...

result:

ok 

Test #36:

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

input:

500 14
3222223233323
3321211322233
3212323311313
2121333133121
1132223313222
3213132123121
1311132231313
1223111333213
3223131333131
2323331311321
1212213213121
3321213132113
2213112232332
3323312212221
2331233131212
3132332323231
3233312212322
2232231321233
3221121322311
3312213311221
3123221232132...

output:

1 3 11 14 38 42 52 61 66 220 332 347 494 518
2 5 9 30 35 45 49 57 210 324 339 456 481 508
4 7 22 24 27 53 72 203 302 316 348 444 469 495
6 16 18 20 31 58 67 194 211 295 310 358 432 482
8 10 13 36 54 62 186 221 284 303 366 375 408 421
12 17 32 39 50 68 179 195 229 275 325 386 398 433
15 19 25 28 43 4...

result:

ok 

Test #37:

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

input:

42 500
22321333321323312111231223231112313233322223312223231123333132233232332323233311321322333221131311111221222233221112332333221132311321111331121321231112213133122221231322331112312323321311213113123312322113332213223321323133111122131231313122132211331123311223323311222311121123211213321321222...

output:

1 24 27 36 197 206 224 242 258 272 281 288 316 368 394 413 421 427 432 437 442 954 966 971 975 1010 1020 1026 1032 1036 1042 1049 1403 1423 1432 1447 1455 1495 1508 1519 1687 1692 1708 1714 1729 1767 1775 1804 1811 2108 2120 2130 2150 2159 2167 2483 2489 2498 2510 2585 2595 2611 2617 2649 2662 2679 ...

result:

ok 

Test #38:

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

input:

500 42
11333233331131113122312231331211223323231
13131111223111221132213132223221213332121
33221122332122112222131322332122331123211
11122332312132232321211231131111113212133
12331222132321231332113212212322111211221
31231122131113133231312211232222122213112
21131211232311113331211211123113133233332...

output:

1 2 4 11 14 25 34 39 44 127 568 580 590 629 752 763 771 806 818 828 957 992 1006 1018 1054 1670 1686 1723 2249 2266 2284 2303 2324 2552 2577 2628 2721 2806 3139 3156 3191 3210
3 5 9 13 22 28 32 37 42 125 130 558 569 602 615 741 753 782 794 855 947 968 980 1038 1047 1079 1656 1703 2185 2229 2323 2481...

result:

ok 

Test #39:

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

input:

132 500
1132323323231313311333232113321322332132222131331322222313323213212211313222311121333132112222311221331231221111333131232232232231112312212233132321233312211331321323322321111123213131232111121322332223332231212131312112112123121222231122231313132223213132113311121121333133121312313333323211...

output:

1 2 4 122 146 159 165 177 228 251 264 270 283 290 996 1012 1223 1246 1257 1270 1308 1370 1471 1521 1553 1567 1583 1599 1638 2074 2192 2209 2246 2263 2487 2550 2586 2601 2619 2677 3340 3357 3405 3421 3435 5255 5275 5426 5468 5487 5727 5919 5940 6000 6019 6408 6475 6493 6568 6606 6624 6665 7808 7828 7...

result:

ok 

Test #40:

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

input:

500 132
12232111232311313223132222113231223331332112121131122121311322322212111231331212321312113131332231123333233333311122213231131132313
13321311123332321112233322221332113221213112112121332311223223213123113122123213221231321223312312132322311223121132231233333113213
1331323322332322111231123132...

output:

1 2 9 11 16 55 69 73 77 82 89 345 418 500 512 545 554 572 580 601 744 755 780 793 1822 1846 2083 2105 2124 2170 2192 2991 3011 3221 3245 3292 3342 3397 3422 4151 4199 4351 4374 4395 4417 4437 5950 5981 6016 6545 6623 6657 6693 7354 7393 7430 7465 7575 7609 7645 7826 9022 9063 9459 9987 10021 10164 1...

result:

ok 

Test #41:

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

input:

250 500
3331231211133131113221212112311331322312131211323111323211121112121223221123132121333221132312321213212212123331333221322212112231231312132213223323133233133122233232131131133123323131132133222331313131222221112232212311113131121333323213111122211222222233311212233311133322211231222333222131...

output:

1 3 5 10 13 307 335 345 354 363 370 376 644 669 682 952 965 977 987 1078 1481 1494 1508 1668 1681 1696 1711 1729 1988 4133 4163 4191 4250 4437 4462 4670 4692 5237 5397 5428 5459 5488 5567 5593 5983 6044 6071 6636 6651 6688 6709 6732 6752 6930 7020 7066 7088 7109 7131 7152 8557 8890 8954 8987 9019 90...

result:

ok 

Test #42:

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

input:

500 250
133113133113113111233121332223232121322213133333212131312233133331111223123323132233233123313221332321122231231321323223233223131221221232123123322213133123132112322323233232332321123311233233333112223223111211122213211132312132311221232323133231211
323132231131131123231323113123213333211213...

output:

1 2 6 16 18 21 83 88 115 139 144 150 176 182 188 625 637 647 656 876 2487 2616 2637 2659 2682 2765 2806 3125 3147 3307 3352 3374 3417 4202 4228 4253 4279 4622 4752 4778 4879 4908 5511 5534 5579 5628 5674 6393 6444 6470 6496 6672 6700 7011 7043 7346 7382 7419 7623 7685 10801 10846 10936 11031 11209 1...

result:

ok 

Test #43:

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

input:

400 500
3311311321233123231112321333233131232212212332122331132111122231332132313232123123122121312211221333112232121121222231333113232132123311333123321233121311122323111221113222332133312332312232311332321123321232321212112321313313131212131311231121233113213112211121122121212333322111223213222312...

output:

1 3 5 7 9 148 155 161 182 468 478 484 497 569 581 709 732 743 762 774 786 800 1148 1217 1234 1253 1322 1348 2716 2807 2849 3072 3097 3195 3216 3236 3277 3337 3361 3380 6137 6168 6195 6301 7547 7612 7646 7680 7851 7888 7954 8230 8265 8304 9385 9756 9790 10250 10282 10314 10346 10447 10484 10558 10591...

result:

ok 

Test #44:

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

input:

500 400
1333112223111311312321322331211131212113113331221131323233223113223221322233133231223211313122313232111213132313212333212332111131112313233322233231331122333332231232112332333332231121122332323211221211231211222222212131113322122231323233111311333111223322222213213112132232211122213322111211...

output:

1 2 5 24 31 34 37 129 139 167 212 258 264 269 286 294 302 608 615 621 634 1028 1043 1062 1071 1106 1173 2057 2079 2098 2117 2136 2154 2239 2254 3094 3117 3135 3154 3171 3575 3595 3616 4141 4218 4266 4289 4382 4402 4423 4446 5021 5045 6523 6652 6901 6937 7005 7134 7239 7273 7346 7381 7417 10330 10598...

result:

ok 

Test #45:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 ...

result:

ok 

Test #46:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 1000 1001 2000 2001 3000 3001 4000 4001 5000 5001 6000 6001 7029 7031 8313 8314 9313 9314 10313 10314 11313 11314 12313 12314 13313 13314 14313 14314 15313 15314 16313 16314 17313 17314 18313 18314 19313 19314 20313 20314 21313 21314 22313 22314 23313 23314 24313 24314 25313 25314 26313 26314 2731...

result:

ok 

Test #47:

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

input:

500 500
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

output:

1 3 7 13 21 31 43 57 73 91 111 133 157 183 211 241 273 307 343 381 421 463 507 553 601 651 703 757 813 871 931 993 1057 1123 1191 1261 1333 1407 1483 1561 1641 1723 1807 1893 1981 2071 2163 2257 2353 2451 2551 2653 2757 2863 2971 3081 3193 3307 3423 3541 3661 3783 3907 4033 4161 4291 4423 4557 4693 ...

result:

ok 

Test #48:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 ...

result:

ok 

Test #49:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 1000 1001 2000 2001 3000 3001 4000 4001 4642 4644 5643 5645 6968 6972 7193 7196 8009 8012 8955 8958 9876 9880 10768 10772 11660 11664 12951 12956 14206 14210 15575 15579 17073 17077 18644 18648 19759 19763 20441 20445 21315 21322 22418 22426 23530 23537 24644 24650 25804 25811 26875 26880 27943 27...

result:

ok 

Test #50:

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

input:

500 500
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

output:

1 3 7 13 21 31 43 57 73 91 111 133 157 183 211 241 273 307 343 381 421 463 507 551 596 642 690 740 792 846 902 960 1020 1082 1146 1212 1280 1423 1499 1577 1657 1739 1823 1909 1997 2087 2179 2273 2369 2467 2567 2669 2773 2879 2987 3097 3209 3323 3439 3557 3677 3799 3923 4048 4174 4300 4428 4558 4690 ...

result:

ok 

Test #51:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 255 270 286 301 317 333 350 367 385 403 422 441 461 482 504 525 547 569 592 615 639 662 686 709 732 755 778 802 828 854 881 908 936 965 995 1025 1056 1087 1119 1151 1183 1215 1248 1282 1316 1351 1386 142...

result:

ok 

Test #52:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 397 399 600 603 1029 1034 1252 1256 1402 1407 1558 1563 1703 1707 1787 1790 1816 1818 3675 3683 3832 3841 4058 4071 4515 4527 4613 4624 4693 4702 4771 4781 5363 5374 5751 5766 6141 6151 6872 6886 7897 7914 8887 8905 10088 10110 10377 10393 13027 13057 13859 13889 15255 15287 15833 15861 15947 1597...

result:

ok 

Test #53:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 ...

result:

ok 

Test #54:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 10 14 31 37 62 70 103 113 154 166 215 229 286 302 367 385 458 478 559 581 670 694 791 817 922 950 1063 1093 1214 1246 1375 1409 1546 1582 1727 1765 1918 1958 2119 2161 2330 2374 2551 2597 2782 2830 3023 3073 3274 3326 3535 3589 3806 3862 4087 4145 4378 4438 4679 4741 4990 5054 5311 5377 5642 5710 ...

result:

ok 

Test #55:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 ...

result:

ok 

Test #56:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 12 16 20 25 30 36 42 49 56 64 72 81 90 100 110 121 132 144 156 169 182 196 210 225 240 256 272 289 306 324 342 361 380 400 420 441 462 484 506 529 552 576 600 625 650 676 702 729 756 784 812 841 870 900 930 961 992 1024 1056 1089 1122 1156 1190 1225 1260 1296 1332 1369 1406 1444 1482 1521 ...

result:

ok 

Test #57:

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

input:

500 500
3133333333331313333313313331131333311113131133333131131113333111133311111313131133331331111131333331133113313131333331313311313313133311113113333331331133313313113133133311131331133113333333331333311333131133131333133333333311133111333333111313333333333333133133333131333133113311333113333113...

output:

1 3 5 11 19 26 32 46 52 72 87 97 111 117 140 143 158 167 188 231 246 257 335 351 358 408 423 502 511 521 566 576 674 699 718 743 755 768 782 794 925 938 1039 1055 1068 1138 1167 1287 1306 1346 1359 1463 1478 1494 1644 1662 1680 1695 2012 2046 2100 2132 2148 2165 2181 2195 2446 2575 2619 2640 2663 26...

result:

ok 

Test #58:

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

input:

500 500
3331113313111333311331333331133131331333311131311311133333113331133331131131131331131133333133313311131311313333331313113133311313111131333331113111311311111311113331113111113331113113131331313131311331113333133131333111313111133111111313131311131111111113113333133333131133331131333333131111...

output:

1 3 5 8 10 13 16 45 49 52 71 74 78 82 133 144 178 187 194 202 241 249 255 292 305 320 352 371 381 394 483 496 507 540 550 616 665 673 699 716 736 760 771 783 793 1013 1027 1257 1273 1291 1329 1342 1358 1374 1440 1535 1553 1583 1719 1734 1752 1806 1842 2024 2041 2060 2204 2239 2402 2439 2459 2477 256...

result:

ok 

Test #59:

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

input:

500 500
3333323333333333333233333233332333323333333333233333333333323233333333333333333333333333333333233332333333333333333223322233333233333333322333333333333333333323333233333323332323333333223333233333333333333333323233233323233332333333333333333233333333332333233333233333333333333232333333333323...

output:

1 3 7 13 28 37 95 111 238 267 284 302 379 405 456 482 726 765 838 883 908 1051 1096 1148 1220 1474 1731 1857 1915 2120 2292 2322 2381 2443 2544 2613 2799 4514 4618 5145 5241 5333 5431 5531 5627 5833 5934 5982 6081 6277 6365 6544 6639 6923 7137 7248 7352 7723 7827 7929 8137 8474 8530 8642 8748 8854 9...

result:

ok 

Test #60:

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

input:

500 500
2221112221121221111121112111121111111111222122112211111111122212121111222122121121111111121111211122111112111122111111211221122212112211221121122112222111222112111111111111211121211121221111211121111122211121211121111211112112121222221111111122121122112211111111111222112112122111111121111121...

output:

1 4 6 15 19 23 26 29 149 153 156 162 223 230 239 266 274 279 284 304 309 315 320 325 331 1717 1733 1749 1766 1784 1803 1821 1842 1863 1885 1910 1933 1954 1978 2000 2025 2106 2127 2209 2229 2247 2327 2349 2369 2390 3425 3447 3472 3496 3599 3621 3644 7059 8188 8240 8288 8414 8455 8489 8935 8980 9024 9...

result:

ok 

Test #61:

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

input:

500 500
3331111331111113131111131113213111131313113111313111133311111113111131111111333331331131131311331131133111131333111311111111131111111113113313311113111111111131111311111113111111313111113111111311111313313131113113113111113313113131311311111131133331331311333113131331331111111313111311311333...

output:

1 3 5 9 11 13 15 18 43 50 54 59 63 68 72 77 101 107 124 129 133 139 144 149 176 182 191 197 323 354 361 399 406 434 449 455 672 683 722 732 800 816 831 895 910 924 937 976 989 1029 1139 1150 1165 1182 1233 1261 1307 1351 1382 1410 1426 1466 1480 1497 1547 1563 1879 1896 1912 2015 2059 2107 2127 2226...

result:

ok 

Test #62:

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

input:

500 500
2222222222222222222222222232232222222222222222222222222222222222222322222222222222222222222222222223222222222222222222222222222222222222222222223222223222322222222222222222222232222222222222222222222222222222222232222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 106 108 254 259 541 550 686 697 846 854 1017 1028 1082 1095 1387 1400 1589 1601 1926 1940 2274 2288 2736 2761 3292 3318 3369 3885 3913 4343 4831 4858 5385 5413 5895 5928 6422 6459 7031 7073 7405 7446 7815 7865 8206 8258 8670 8718 9090 9141 9497 9551 9909 9955 10160 10210 10834 10881 11357 11404 11...

result:

ok 

Test #63:

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

input:

500 500
1231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231...

output:

1 2 1997 2499 2500 2501 2503 2505 4997 5499 5500 5501 5503 5505 7997 8499 8500 8501 8503 8505 10997 11499 11500 11501 11503 11505 13997 14499 14500 14501 14503 14505 16997 17499 17500 17501 17503 17505 19997 20499 20500 20501 20503 20505 22997 23499 23500 23501 23503 23505 25997 26499 26500 26501 26...

result:

ok 

Test #64:

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

input:

500 500
1321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321...

output:

1 2 5 2996 2998 3000 3001 3002 3005 5996 5998 6000 6001 6002 6005 8996 8998 9000 9001 9002 9005 11996 11998 12000 12001 12002 12005 14996 14998 15000 15001 15002 15005 17996 17998 18000 18001 18002 18005 20996 20998 21000 21001 21002 21005 23996 23998 24000 24001 24002 24005 26996 26998 27000 27001 ...

result:

ok 

Test #65:

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

input:

500 500
1231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231...

output:

1 2 2825 2830 2832 2833 2835 2836 5825 5830 5832 5833 5835 5836 8825 8830 8832 8833 8835 8836 11825 11830 11832 11833 11835 11836 14825 14830 14832 14833 14835 14836 17825 17830 17832 17833 17835 17836 20825 20830 20832 20833 20835 20836 23825 23830 23832 23833 23835 23836 26825 26830 26832 26833 26...

result:

ok 

Test #66:

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

input:

500 500
1321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321...

output:

1 2 2820 2827 2829 2832 2834 2836 5820 5827 5829 5832 5834 5836 8820 8827 8829 8832 8834 8836 11820 11827 11829 11832 11834 11836 14820 14827 14829 14832 14834 14836 17820 17827 17829 17832 17834 17836 20820 20827 20829 20832 20834 20836 23820 23827 23829 23832 23834 23836 26820 26827 26829 26832 26...

result:

ok 

Test #67:

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

input:

500 500
1231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231231...

output:

1 2 9 2665 2666 2667 2669 2670 2677 5665 5666 5667 5669 5670 5677 8665 8666 8667 8669 8670 8677 11665 11666 11667 11669 11670 11677 14665 14666 14667 14669 14670 14677 17665 17666 17667 17669 17670 17677 20665 20666 20667 20669 20670 20677 23665 23666 23667 23669 23670 23677 26665 26666 26667 26669 ...

result:

ok 

Test #68:

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

input:

500 500
1321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321321...

output:

1 2 7 2333 2334 2336 2337 2338 2347 5333 5334 5336 5337 5338 5347 8333 8334 8336 8337 8338 8347 11333 11334 11336 11337 11338 11347 14333 14334 14336 14337 14338 14347 17333 17334 17336 17337 17338 17347 20333 20334 20336 20337 20338 20347 23333 23334 23336 23337 23338 23347 26333 26334 26336 26337 ...

result:

ok 

Test #69:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 8 10 13 16 19 22 25 30 34 38 42 46 53 58 63 68 73 82 88 94 100 106 117 124 131 138 145 158 166 174 182 190 205 214 223 232 241 258 268 278 288 298 317 328 339 350 361 382 394 406 418 430 453 466 479 492 505 530 544 558 572 586 613 628 643 658 673 702 718 734 750 766 797 814 831 848 865 898 9...

result:

ok 

Test #70:

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

input:

500 500
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2 4 6 9 11 14 17 20 24 28 32 36 40 45 51 56 61 66 72 80 86 92 98 105 115 122 129 136 144 156 164 172 180 189 203 212 221 230 240 256 266 276 286 297 315 326 337 348 360 380 392 404 416 429 451 464 477 490 504 528 542 556 570 585 611 626 641 656 672 700 716 732 748 765 795 812 829 846 864 896 914 9...

result:

ok 

Test #71:

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

input:

500 500
2312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312...

output:

1 1497 1999 2000 2001 2003 2005 4497 4999 5000 5001 5003 5005 7497 7999 8000 8001 8003 8005 10497 10999 11000 11001 11003 11005 13497 13999 14000 14001 14003 14005 16497 16999 17000 17001 17003 17005 19497 19999 20000 20001 20003 20005 22497 22999 23000 23001 23003 23005 25497 25999 26000 26001 2600...

result:

ok 

Test #72:

score: 0
Accepted
time: 45ms
memory: 20032kb

input:

500 500
2132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132...

output:

1 1996 1998 2000 2001 2002 2005 4996 4998 5000 5001 5002 5005 7996 7998 8000 8001 8002 8005 10996 10998 11000 11001 11002 11005 13996 13998 14000 14001 14002 14005 16996 16998 17000 17001 17002 17005 19996 19998 20000 20001 20002 20005 22996 22998 23000 23001 23002 23005 25996 25998 26000 26001 2600...

result:

ok 

Test #73:

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

input:

500 500
2312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312...

output:

1 5 2826 2828 2830 2833 2834 2839 5826 5828 5830 5833 5834 5839 8826 8828 8830 8833 8834 8839 11826 11828 11830 11833 11834 11839 14826 14828 14830 14833 14834 14839 17826 17828 17830 17833 17834 17839 20826 20828 20830 20833 20834 20839 23826 23828 23830 23833 23834 23839 26826 26828 26830 26833 26...

result:

ok 

Test #74:

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

input:

500 500
2132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132...

output:

1 2823 2824 2826 2828 2830 2835 5823 5824 5826 5828 5830 5835 8823 8824 8826 8828 8830 8835 11823 11824 11826 11828 11830 11835 14823 14824 14826 14828 14830 14835 17823 17824 17826 17828 17830 17835 20823 20824 20826 20828 20830 20835 23823 23824 23826 23828 23830 23835 26823 26824 26826 26828 2683...

result:

ok 

Test #75:

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

input:

500 500
2312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312312...

output:

1 4 2663 2664 2665 2667 2668 2673 5663 5664 5665 5667 5668 5673 8663 8664 8665 8667 8668 8673 11663 11664 11665 11667 11668 11673 14663 14664 14665 14667 14668 14673 17663 17664 17665 17667 17668 17673 20663 20664 20665 20667 20668 20673 23663 23664 23665 23667 23668 23673 26663 26664 26665 26667 26...

result:

ok 

Test #76:

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

input:

500 500
2132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132132...

output:

1 10 12 2332 2333 2334 2338 2351 2353 5332 5333 5334 5338 5351 5353 8332 8333 8334 8338 8351 8353 11332 11333 11334 11338 11351 11353 14332 14333 14334 14338 14351 14353 17332 17333 17334 17338 17351 17353 20332 20333 20334 20338 20351 20353 23332 23333 23334 23338 23351 23353 26332 26333 26334 2633...

result:

ok 

Test #77:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 5 7 15 19 31 37 53 61 81 91 115 127 155 169 201 217 253 271 311 331 375 397 445 469 521 547 603 631 691 721 785 817 885 919 991 1027 1103 1141 1221 1261 1345 1387 1475 1519 1611 1657 1753 1801 1901 1951 2055 2107 2215 2269 2381 2437 2553 2611 2731 2791 2915 2977 3105 3169 3301 3367 3503 3571 3711 ...

result:

ok 

Test #78:

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

input:

500 500
2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...

output:

1 4 6 13 16 26 30 42 47 63 68 88 94 117 124 146 158 182 191 223 232 268 278 317 328 362 382 418 431 479 492 544 558 613 628 674 702 750 767 831 848 916 934 1005 1024 1082 1118 1178 1199 1279 1300 1384 1406 1493 1516 1586 1630 1702 1727 1823 1848 1948 1974 2077 2104 2186 2238 2322 2351 2463 2492 2608...

result:

ok 

Test #79:

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

input:

500 500
3123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123...

output:

1 3 5 2497 2999 3000 3001 3003 3005 5497 5999 6000 6001 6003 6005 8497 8999 9000 9001 9003 9005 11497 11999 12000 12001 12003 12005 14497 14999 15000 15001 15003 15005 17497 17999 18000 18001 18003 18005 20497 20999 21000 21001 21003 21005 23497 23999 24000 24001 24003 24005 26497 26999 27000 27001 ...

result:

ok 

Test #80:

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

input:

500 500
3213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213...

output:

1 3 2496 2498 2500 2501 2502 2505 5496 5498 5500 5501 5502 5505 8496 8498 8500 8501 8502 8505 11496 11498 11500 11501 11502 11505 14496 14498 14500 14501 14502 14505 17496 17498 17500 17501 17502 17505 20496 20498 20500 20501 20502 20505 23496 23498 23500 23501 23502 23505 26496 26498 26500 26501 26...

result:

ok 

Test #81:

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

input:

500 500
3123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123...

output:

1 3 4 2829 2832 2834 2835 2837 2838 5829 5832 5834 5835 5837 5838 8829 8832 8834 8835 8837 8838 11829 11832 11834 11835 11837 11838 14829 14832 14834 14835 14837 14838 17829 17832 17834 17835 17837 17838 20829 20832 20834 20835 20837 20838 23829 23832 23834 23835 23837 23838 26829 26832 26834 26835 ...

result:

ok 

Test #82:

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

input:

500 500
3213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213...

output:

1 3 2825 2827 2829 2831 2833 2837 5825 5827 5829 5831 5833 5837 8825 8827 8829 8831 8833 8837 11825 11827 11829 11831 11833 11837 14825 14827 14829 14831 14833 14837 17825 17827 17829 17831 17833 17837 20825 20827 20829 20831 20833 20837 23825 23827 23829 23831 23833 23837 26825 26827 26829 26831 26...

result:

ok 

Test #83:

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

input:

500 500
3123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123...

output:

1 3 5 2663 2667 2668 2669 2671 2673 5663 5667 5668 5669 5671 5673 8663 8667 8668 8669 8671 8673 11663 11667 11668 11669 11671 11673 14663 14667 14668 14669 14671 14673 17663 17667 17668 17669 17671 17673 20663 20667 20668 20669 20671 20673 23663 23667 23668 23669 23671 23673 26663 26667 26668 26669 ...

result:

ok 

Test #84:

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

input:

500 500
3213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213213...

output:

1 3 2331 2332 2334 2335 2336 2342 5331 5332 5334 5335 5336 5342 8331 8332 8334 8335 8336 8342 11331 11332 11334 11335 11336 11342 14331 14332 14334 14335 14336 14342 17331 17332 17334 17335 17336 17342 20331 20332 20334 20335 20336 20342 23331 23332 23334 23335 23336 23342 26331 26332 26334 26335 26...

result:

ok 

Test #85:

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

input:

500 500
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

output:

1 3 5 9 13 19 25 33 41 49 61 71 85 97 109 127 141 161 177 193 217 235 261 281 301 331 353 385 409 433 469 495 533 561 589 631 661 705 737 769 817 851 901 937 973 1027 1065 1121 1161 1201 1261 1303 1365 1409 1453 1519 1565 1633 1681 1729 1801 1851 1925 1977 2029 2107 2161 2241 2297 2353 2437 2495 258...

result:

ok 

Test #86:

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

input:

500 500
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

output:

1 3 8 12 22 28 42 50 68 78 100 112 138 152 182 198 232 250 288 308 350 372 418 442 492 518 572 600 658 688 750 782 848 882 952 988 1062 1100 1178 1218 1300 1342 1428 1472 1562 1608 1702 1750 1848 1898 2000 2052 2158 2212 2322 2378 2492 2550 2668 2728 2850 2912 3038 3102 3232 3298 3432 3500 3638 3708...

result:

ok 

Extra Test:

score: 0
Extra Test Passed