QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#690202#1088. Border Similarity Undertaking0xyzAC ✓2482ms133384kbC++144.3kb2024-10-30 20:58:112024-10-30 20:58:12

Judging History

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

  • [2024-10-30 20:58:12]
  • 评测
  • 测评结果:AC
  • 用时:2482ms
  • 内存:133384kb
  • [2024-10-30 20:58:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int _=2005;
int L[_][_],R[_][_],U[_][_],D[_][_],cl[_][_],cr[_][_],cu[_][_],cd[_][_],n,m;
char a[_][_];
long long s;
void sol(int xl,int xr,int yl,int yr){
	if(xl>=xr||yl>=yr)return;
	//cout<<xl<<' '<<xr<<' '<<yl<<' '<<yr<<'\n';
	if(xr-xl+1>=yr-yl+1){
		int xm=xl+xr>>1;
		for(int l=yl;l<=yr;l++)
			for(int r=l+1;r<=yr;r++)cu[l][r]=cd[l][r]=0;
		for(int l=yl;l<=yr;l++){
			vector<int>e;
			for(int i=xm+1;i<=min(D[xm+1][l],xr);i++)e.push_back(R[i][l]);
			sort(e.begin(),e.end(),greater<int>());
			for(int r=l+1;r<=yr;r++)
				if(min(D[xm+1][r],xr)>=min(D[xm+1][l],xr)){
					while(e.size()&&e.back()<r)e.pop_back();
					cd[l][r]+=e.size();
				}
		}
		for(int r=yl;r<=yr;r++){
			vector<int>e;
			for(int i=xm+1;i<=min(D[xm+1][r],xr);i++)e.push_back(L[i][r]);
			sort(e.begin(),e.end());
			for(int l=r-1;l>=yl;l--)
				if(min(D[xm+1][r],xr)<min(D[xm+1][l],xr)){
					while(e.size()&&e.back()>l)e.pop_back();
					cd[l][r]+=e.size();
				}
		}
		for(int l=yl;l<=yr;l++){
			vector<int>e;
			for(int i=xm;i>=max(U[xm][l],xl);i--)e.push_back(R[i][l]);
			sort(e.begin(),e.end(),greater<int>());
			for(int r=l+1;r<=yr;r++)
				if(max(U[xm][r],xl)<=max(U[xm][l],xl)){
					while(e.size()&&e.back()<r)e.pop_back();
					/*if(l==1&&r==2){
						cout<<"1______________________\n";
						for(auto i:e)cout<<i<<' ';
						cout<<"\n______________________\n";
					}*/
					cu[l][r]+=e.size();
				}
		}
		for(int r=yl;r<=yr;r++){
			vector<int>e;
			for(int i=xm;i>=max(U[xm][r],xl);i--)e.push_back(L[i][r]);
			sort(e.begin(),e.end());
			for(int l=r-1;l>=yl;l--)
				if(max(U[xm][r],xl)>max(U[xm][l],xl)){
					while(e.size()&&e.back()>l)e.pop_back();
					/*if(l==1&&r==2){
						cout<<"2______________________\n";
						for(auto i:e)cout<<i<<' ';
						cout<<"\n______________________\n";
					}*/
					cu[l][r]+=e.size();
				}
		}
		for(int l=yl;l<=yr;l++)
			for(int r=l+1;r<=yr;r++){
				//cout<<l<<' '<<r<<' '<<cu[l][r]<<' '<<cd[l][r]<<'\n';
				if(a[xm][l]==a[xm+1][l]&&a[xm][r]==a[xm+1][r])s+=cu[l][r]*cd[l][r];
			}
		//cout<<1<<' '<<s<<'\n';
		sol(xl,xm,yl,yr);sol(xm+1,xr,yl,yr);
	}else{
		int ym=yl+yr>>1;
		for(int u=xl;u<=xr;u++)
			for(int d=u+1;d<=xr;d++)cl[u][d]=cr[u][d]=0;
		for(int u=xl;u<=xr;u++){
			vector<int>e;
			for(int i=ym+1;i<=min(R[u][ym+1],yr);i++)e.push_back(D[u][i]);
			sort(e.begin(),e.end(),greater<int>());
			for(int d=u+1;d<=xr;d++)
				if(min(R[d][ym+1],yr)>=min(R[u][ym+1],yr)){
					while(e.size()&&e.back()<d)e.pop_back();
					cr[u][d]+=e.size();
				}
		}
		for(int d=xl;d<=xr;d++){
			vector<int>e;
			for(int i=ym+1;i<=min(R[d][ym+1],yr);i++)e.push_back(U[d][i]);
			sort(e.begin(),e.end());
			for(int u=d-1;u>=xl;u--)
				if(min(R[d][ym+1],yr)<min(R[u][ym+1],yr)){
					while(e.size()&&e.back()>u)e.pop_back();
					cr[u][d]+=e.size();
				}
		}
		for(int u=xl;u<=xr;u++){
			vector<int>e;
			for(int i=ym;i>=max(L[u][ym],yl);i--)e.push_back(D[u][i]);
			sort(e.begin(),e.end(),greater<int>());
			for(int d=u+1;d<=xr;d++)
				if(max(L[d][ym],yl)<=max(L[u][ym],yl)){
					while(e.size()&&e.back()<d)e.pop_back();
					cl[u][d]+=e.size();
				}
		}
		for(int d=xl;d<=xr;d++){
			vector<int>e;
			for(int i=ym;i>=max(L[d][ym],yl);i--)e.push_back(U[d][i]);
			sort(e.begin(),e.end());
			for(int u=d-1;u>=xl;u--)
				if(max(L[d][ym],yl)>max(L[u][ym],yl)){
					while(e.size()&&e.back()>u)e.pop_back();
					cl[u][d]+=e.size();
				}
		}
		for(int u=xl;u<=xr;u++)
			for(int d=u+1;d<=xr;d++){
				//cout<<u<<' '<<d<<' '<<cl[u][d]<<' '<<cr[u][d]<<'\n';
				if(a[u][ym]==a[u][ym+1]&&a[d][ym]==a[d][ym+1])s+=cl[u][d]*cr[u][d];
			}
		//cout<<2<<' '<<s<<'\n';
		sol(xl,xr,yl,ym);sol(xl,xr,ym+1,yr);
	}
}
int main(){
	//freopen("qwq.in","r",stdin);
	//freopen("qwq.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>(a[i]+1);
	for(int i=n;i;i--)
		for(int j=m;j;j--){
			R[i][j]=a[i][j+1]==a[i][j]?R[i][j+1]:j;
			D[i][j]=a[i+1][j]==a[i][j]?D[i+1][j]:i;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			L[i][j]=a[i][j-1]==a[i][j]?L[i][j-1]:j;
			U[i][j]=a[i-1][j]==a[i][j]?U[i-1][j]:i;
		}
	sol(1,n,1,m);
	cout<<s<<'\n';
	return 0;
}/*
5 5
aaaaa
baaaa
aaaab
aaaaa
abaaa

30
*/

詳細信息

Test #1:

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

input:

3 5
zzzzz
zxzxz
zzzzz

output:

3

result:

ok answer is '3'

Test #2:

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

input:

4 4
abbc
bcca
babc
acbb

output:

0

result:

ok answer is '0'

Test #3:

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

input:

12 12
abbabaaaaabb
ababaaaaaabb
aaabbbbbabbb
aabababaaaba
abbbaaabaaba
baaababbbaba
aaaaababbaaa
bbabbbbbabaa
bbbabbaabaaa
aabbbaaaabba
babaabababaa
bababaabaaba

output:

25

result:

ok answer is '25'

Test #4:

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

input:

200 200
aabababbaabbaabaaaabbabaaaaabababbbaaabbbbbbaabbbbbababaabbbabaaaabaaababababababbbbbbabababbbbbababbaababbabaabababbbaabbaaaabbababbaabbaaaaaababbbbbbbbabababbbbababbaaaabbabaaaabaaaababaababaabaabaa
bbabababaabbaaabaaaaabbabbbbbbaabaababaaaabaaaaabbbbbababbaaabbaaabbbaaaabaabbbabbabbaababa...

output:

9063

result:

ok answer is '9063'

Test #5:

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

input:

200 200
bbcacaacbcabaacacbacabcccbbacbbbabaccbcabacbacaccbabcbcbaaacbacbaccbbacabbabbbbaccabcacbccaaaaaabacbcabcacbcacbbcbcbbababcccabccaaacabcbccbcbacccbbbcacacbcbbaccaabcbcababbccbcbacbcaaaacabaccaabacabbca
abbbbaacabcbabacaabcccbbcabaabcaacacacacbabbccbabbcbbcbacbbaababbcbbcacbbbabcbbcbbbbabaaaab...

output:

1993

result:

ok answer is '1993'

Test #6:

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

input:

200 200
daadbcdabdabbcbabacdbdaaabbbdbcbbcdaacababcbbdcdbadbadbbccdcbdbbabbddadaccaaaddacdaddaadaaacbdacbcacbdbcaaddddadcdacaaaaccdaadadaaabadbbdcbcbadccbcabccddaddbcdadbdcddcdbaabaacccdaddcdddcaccbddcdaddcbc
adadabcbbacacdadbbaadbbacaccccaabcadbccdddcdbaabacdcaaccbddaadcbcaadcccdbcdccdacbbbbcbabdcb...

output:

725

result:

ok answer is '725'

Test #7:

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

input:

200 200
txxwjvdrstzdlvxbapbangqherrnvedtncukdffoafsxdpbjhowrytghnpxjdylejgnxmvagxqkgrmektefspdsfzyshkavoputrpszynegndfaxqwuexqhsoqqixyakpshebggckjonwsjaiffhgpimqblmjymlltdanrmkgfpvmuzdntucrrtverpfdeellblawwyk
jieyodnvjkcmuomidegwcrinowmvivwnqvwwffmmhxjktznptunvuxcxanknhevtgchvotjifeutehgbsemomcvtahx...

output:

4

result:

ok answer is '4'

Test #8:

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

input:

200 20
bbabbbaabbababbbbbbb
bbbabbbbbababbbabaab
bbabbbabbbbbbbbbbbab
abaaabbbbbabbbaaabba
ababbbbbbbbabbbabbbb
baababbbababbbbbbbab
baabbabbbaaaabbababb
bbbbbabaabbbbabbbbaa
bababbbbbbbbbbbbbbab
bbbaabbbbaabbabbabba
bbabbbbbbbbbaabaabbb
bbbbbbbabbabaabbbabb
bbbbbaabbbaabbbbbaba
aabbaabbababbabbbbab...

output:

5669

result:

ok answer is '5669'

Test #9:

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

input:

200 20
bbbbbbabbbbabbbbbbba
bbbbabbbbabbbbbabbbb
bababbbbbbbbbbabbbbb
bbbbbbbbabbbbbabbbba
babbbbbabbbbbbbbbbbb
bbbbbbabababbbbbbbbb
bbbbbbbbabbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbbaabbbb
bbbababbbbbbbbbbbbbb
bbbbbbbbbbbabbbbbaba
abbbbbbbbbbbbbbbbbba
bbbbbbabbabbbbbbbbbb
bbbbabbbbbbbbabbbbbb...

output:

30317

result:

ok answer is '30317'

Test #10:

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

input:

200 20
bbbbabbbbbbbbbbbbbab
bbbbbbbbbbbbbbbbbbba
bbbabbbbbbbbbbabbbbb
bbbbbabbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbabaabbbbbb
abbbbbbbbbbbbbbbaabb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbabbbbbbbb
abbbbbbbbbbabbbbbbab
babbbbbbbbbbabbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbaaabbbbbb
abbbabbbbbbbbabbbbbb...

output:

138080

result:

ok answer is '138080'

Test #11:

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

input:

200 20
babbbbbbbbbbbbbbbabb
babbbbbbbbbbbbbbbbbb
bbbbbbabbbbbbabbbbbb
bbbbbbbbbabbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbabbbbbbbbbbbbb
bbbbaabbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbabb
bbbababbbbbbbbbbbbbb
bbbbbbbbbbbbabbbbbba
bbbbbbbbbbbbbbbbabbb...

output:

371054

result:

ok answer is '371054'

Test #12:

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

input:

200 20
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
babbbbbbbbbbbbbbbabb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbabbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbabbbbbb
bbbbbbbbbbbbbbbbbbbb...

output:

636400

result:

ok answer is '636400'

Test #13:

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

input:

200 20
bbaabaaaababaaaaaaaa
baabaabaaababbaaaaba
ababaaaaababaaaaabaa
baaababaaaabaaaababa
aaaaabaaaaabbaabaaab
aabaaaabaababbabaabb
aaaaaaaaaaaaaaaaaaaa
aabaaaaabaabbbabaaaa
aaaaaaabbaaabaaabbaa
aaabaaaaaaaaaaaaaaaa
aaaabaaabaaaaabbaaba
bbabbabbbaaaabaaaaab
aaaaaaabaaaababaaaba
aaaaabbbabaaaaaaaaab...

output:

5557

result:

ok answer is '5557'

Test #14:

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

input:

200 20
abaaaaabaaaaaaaaabaa
aabaaaabbaabaaaaaabb
aabaabaaabaaaabaaaaa
aaaaabaaaaaaaaaaaaaa
aabaabababbbaaabaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaabaaaaaaaaaa
aaabaaaaaaaaaaaaaaaa
bbababaaababaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aabaaaabbaaaaaaaaaaa
abaaaaaabbaaaaaaaaaa
aaaaabaaaaaaaaaaaaaa
baaaabaabaaaaaaaaaaa...

output:

26980

result:

ok answer is '26980'

Test #15:

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

input:

200 20
aaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaabbaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaabbaaaabaaaaaa
aaaaaaaaaaaaaaaaaaab
aaaaaaaaaaaaaaaaaaaa
aaaaaaaabaabbaaaaaaa
aaaaaaaaaaaaaaaabaaa
aaaaaaaabaaaaaaaaaaa
aaaaaaabaaabaaaaaaaa
aaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaabaaaa
aaaababaaaaaaaaaaaaa
baaaabaaaaaabaaaaaab...

output:

128439

result:

ok answer is '128439'

Test #16:

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

input:

200 20
aaaaaaaaaaaaaaaaaaaa
aaaaaabaaaaaaaaaaaaa
aaaaaabaabaaabaaaaaa
aaaaaaaaabaaaaaaaaaa
aaaaaaaaaaaaaaaaabaa
aaaaabaaaaaaaaaaabba
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaabaaaaaaaaaaaaba
aaaaaaaaabaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaabaaaaaaaaaaaaa
aaaaaababaaaaaaaaaaa...

output:

431605

result:

ok answer is '431605'

Test #17:

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

input:

200 20
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaba
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaabaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa...

output:

721991

result:

ok answer is '721991'

Test #18:

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

input:

200 200
bbbbbbbbaabbaabbbbabbbbbbbbbabbbababbbbbbbbbbbbbbbbabbbabbbbbbabbbbabaaabbbbbbbbbbbbaabbaababbabbbabbbbbbababaabbbbbabbbaabaabbbbbabbabbababbbbbbbaabaababbbababbbbbababbababbbbbbbaababababbbbbabbabbbb
bbbbbbbbbbbbbabbbbbbabaabbaabababbaaaaaabbbbbabbbbabbbbabbbbbabbbbbbababbbbbbbbaabbbbabaaba...

output:

65918

result:

ok answer is '65918'

Test #19:

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

input:

200 200
bbabbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbbbbabbbbbbbbbabbbbbbabbbbbbbabbbbbbbbbbbbbabbbabbbbbbbbbabbbbbbbabbbabbbbbbbbbbabbbabbbbbbbbbbbbbbaababbbbbbbbbbabbbbaabbbbabbbbbbbbbbbabbbbbbbbbbabbbabbbbabbbbbb
bbbbabbbbbbbbbbbbbbabbbbababbbabbbbbabbbbbbbbbababbabbbbbbbbbbbbababbbbbbbbabbbaaababbbbbbb...

output:

436980

result:

ok answer is '436980'

Test #20:

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

input:

200 200
bbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbbbbbbabbbbbbbabbbbab
bbbbbbbbbbabbbbbabbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbabbbabbab...

output:

2006888

result:

ok answer is '2006888'

Test #21:

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

input:

200 200
bbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbabbbbbbbbbbbbbbbbbbbbba
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbababbbbbbbbabbbbbbbbb...

output:

8811371

result:

ok answer is '8811371'

Test #22:

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

input:

200 200
bbbbbbbbbbbbbaabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbabbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbb...

output:

29949725

result:

ok answer is '29949725'

Test #23:

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

input:

200 200
aabaaaaaaaabaaaaaabaaaaabaaabaaaababaabaabbaabaaaaaaaaaabaaaaaaabaaaaaababaaabbabaaababaababaaaaaaaaaaaabaaaaabaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaabaaaababbaaaaaaaaaaaaaaabaaabaabbbbabaaaaaaaaaaaaabaaa
aaaaaaaabbaaaaaaaabbaaaaaabaabbaaaabaaaabbabaaaabaaaaaabaaaaabbbaaaabaaabaaabbababbabbaabaa...

output:

62746

result:

ok answer is '62746'

Test #24:

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

input:

200 200
aabaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaaaaaaaababaabaabaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaabaaabaaaaaaaabaaaaaabaaaaaaaaaaaaaaabaabaaaabaaaaaaaaabaaabaaaaaaaaaaaabaaaaaabbaaaabaaaa
aabaaaaabaabaaaaaaababaaabaaaaaaabaaaaaaaaaaaaaaaaabbabaaaaaaaaaaaaaaaaaaaaaaababaabbaabaab...

output:

393455

result:

ok answer is '393455'

Test #25:

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

input:

200 200
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaababaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaa...

output:

1744602

result:

ok answer is '1744602'

Test #26:

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

input:

200 200
aaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaa...

output:

7733272

result:

ok answer is '7733272'

Test #27:

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

input:

200 200
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaa...

output:

26388726

result:

ok answer is '26388726'

Test #28:

score: 0
Accepted
time: 777ms
memory: 133080kb

input:

2000 2000
hxbcuprmlgnupldnbzhcpesdlawilpqilczdvavjoetwdjtjkcdccftawgagfjhfcnkejypkgwswgiibgfxzzcgjdqjmamdkttedmffqievedyicgurwmungupmvuwralxutfnrykylbqrbqquvrchuuoebfapvgsjgasdfnkxrjnflizeqychfhuetijdnuoenucqkktzkurqcpusbncvilxziylxxyprsqwcdrgcviobiapvuxvhignilpavhjuebiwhatxtqvemtmxwlufvdkmqstjpqvos...

output:

238

result:

ok answer is '238'

Test #29:

score: 0
Accepted
time: 1503ms
memory: 133076kb

input:

2000 2000
aabbbabababbbbbbbaabbaabbbbabbaabbbbbbbbabbaabbabaababababbbbbbabaaabbbbbabbaabbaabbaaaabaaabaaaaaabbbbaaaaabbbbabbaaaababbaaaabbaabaababaaaabaaaaaabbbaabaabbbbbabaaaaaaabaaabbaabaababaaabbbaababababaabbbbbaabbbaabaaabbbbaababaaabaaabbaabaaaaaababbabbaaabbbababaabaabaabbbaabaabbbbbaaababbb...

output:

888377

result:

ok answer is '888377'

Test #30:

score: 0
Accepted
time: 71ms
memory: 54864kb

input:

100 2000
baaabbabbaaababaaababbbabbabaaaabbbbbbbbabababbaabaabaaaaaaaabbbbbaaaaaaaaaabaabbbaabaabaaabaaaababbbbbaaaaabbbaaabbbaababbaaaaabbabaaaaaaaabaabaabbbbbbbbbaaabaababbaaabbbaabbaaaaaaabbbabaaabbabbbaaaabbabbababbaaaabbabbaaaaaababbbbababaabbabbabbbbbabbaababbabbbaabbbaabbababbbabbabbaaabbbbbb...

output:

44364

result:

ok answer is '44364'

Test #31:

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

input:

3 2000
abaabbbbaaabbbaaaababaaaabbbbaaaaabaabbaaaabbaaaaabababaababababbbabbbabbbabbbbbabaaabaabaabbaaabaaabbabbaabbabbbbabaabbabbbaabbbbbabbabbbababaaaabaabaabaaaabaabaabaaaaabbababbbbbaabbabbaababbbaaababaaaaaaababbbabbaabbabbbababaababababbabbbababbbaabbabaaaabbaabaaaabbaabbabaabaababbababbbabaab...

output:

771

result:

ok answer is '771'

Test #32:

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

input:

2 2000
aabaabaaabbbbaababbaaabbabaaaaabaaabbbabababaaaaabaabbaababaaabbaaaabaabaababbabbbbaaabbbbbaabaaaabbaababbaabaaabbbbbbaaaaabababbaaaababbbabbbbaabbbbaabaaaaaaaaaaabbbabaaaaaabababaaaaabbaaababaabababababaabbbabaababbbabbaaaaabbabbaaaaaabbbbaabaaabbaabaaabbbbbaabaaabaaaaaabbaababbaaaaabbabbbba...

output:

309

result:

ok answer is '309'

Test #33:

score: 0
Accepted
time: 1725ms
memory: 133120kb

input:

2000 2000
bbbbbbbbbababbbbbbbbbbabbabbbbbbbabbbbbbbbbababaaabbaabbbbaabbaababbbaabaabbabbbbbaaababbbabbabbbbbbabbbbbababbabbabababaabbbbabbbbabbabbbabbbabbbbabbbbabbabaaabbbbaabaababbbbbbaabaabbbbabbbbaaabbbbbaabbabbaabababaabbbbbbbbbbababaababbbbbbbbbbababaabbbaabbbbbbbbbbbbbabbbaaabaabbbbbabbbabbb...

output:

6611891

result:

ok answer is '6611891'

Test #34:

score: 0
Accepted
time: 1961ms
memory: 133076kb

input:

2000 2000
bbabbbbbabbbbbbbababbabbbbbbbbabbbbbbabbabbbababbbbbbbbbbbbbabbbbbbbbbbbbabbbababbbbbbbbbbbbbbbbbbbabbbbabbbbabbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbabbbbbbabbbbbbbbbbabaababaabbbbbbbbbbbbbbbbbbabbbbabbbabbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

42485356

result:

ok answer is '42485356'

Test #35:

score: 0
Accepted
time: 2150ms
memory: 133076kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbabbbbbabbbbbbaabbabbbbbabbbbbbbbbbbbbbbbbbbaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbb...

output:

208474291

result:

ok answer is '208474291'

Test #36:

score: 0
Accepted
time: 2337ms
memory: 133028kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

920144952

result:

ok answer is '920144952'

Test #37:

score: 0
Accepted
time: 2479ms
memory: 133204kb

input:

2000 2000
bbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

3800182739

result:

ok answer is '3800182739'

Test #38:

score: 0
Accepted
time: 1722ms
memory: 133140kb

input:

2000 2000
aaaabbabbabaaaaabaaaaabbaaaabaabaabaaaaaaaaaaaabaababaaabbaabaababaaaaaaabaabaaabbbabaaaaabaaaabaaaaaaaaaaaaabaaaaaaaabbaaaabaaaaaaaaaabbbaabaabaaaaaabaaaaabbaaaaababaaaaaabbaaaaaaabaaaaaabaaaaabbbaaaaaaaaabbbababaaaaaaaaaabaaaaaaaaaaaaaababababaaaaaaaabbaaabaaabbaabbaaaaababaaaaaabaaaabaa...

output:

6633997

result:

ok answer is '6633997'

Test #39:

score: 0
Accepted
time: 1951ms
memory: 133144kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaabaaaabaaaaababbaaaabaaaababaaaaaaabaaaaaaaaaaaaaabaaabaaaaaabaaaaaaaaaaaabbaaabaaaaababaababaaaaabababaaaaabaaaaaaaaaaabaabbaaaabaaaaaaaabaaaaaaaaaaaaaaaabbaaaaaaaabaaaaaaaaaaabaaaaaaaaaabaaaaaaaabaaaaabaaaaaaabaaaaaaaaaabaaaaaaaaabbabaaaaababaabaabaaaaaaaa...

output:

42677036

result:

ok answer is '42677036'

Test #40:

score: 0
Accepted
time: 2152ms
memory: 133140kb

input:

2000 2000
aaaaaaaaaaaaaaabaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaabaaabaaaaabaaaaaaaaaaaaaabaaaaabaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaabaaabaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaa...

output:

209624629

result:

ok answer is '209624629'

Test #41:

score: 0
Accepted
time: 2382ms
memory: 133080kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaba...

output:

908496629

result:

ok answer is '908496629'

Test #42:

score: 0
Accepted
time: 2482ms
memory: 133036kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3819264516

result:

ok answer is '3819264516'

Test #43:

score: 0
Accepted
time: 2017ms
memory: 133120kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

2193746696652

result:

ok answer is '2193746696652'

Test #44:

score: 0
Accepted
time: 1942ms
memory: 133148kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

2886592675758

result:

ok answer is '2886592675758'

Test #45:

score: 0
Accepted
time: 1919ms
memory: 133312kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

3460768674956

result:

ok answer is '3460768674956'

Test #46:

score: 0
Accepted
time: 1885ms
memory: 133184kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

3680478183757

result:

ok answer is '3680478183757'

Test #47:

score: 0
Accepted
time: 1869ms
memory: 133344kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

3834982314152

result:

ok answer is '3834982314152'

Test #48:

score: 0
Accepted
time: 2039ms
memory: 133148kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

2113716926482

result:

ok answer is '2113716926482'

Test #49:

score: 0
Accepted
time: 1926ms
memory: 133088kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

2884992951736

result:

ok answer is '2884992951736'

Test #50:

score: 0
Accepted
time: 1896ms
memory: 133384kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3434267490537

result:

ok answer is '3434267490537'

Test #51:

score: 0
Accepted
time: 1879ms
memory: 133348kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3693371002932

result:

ok answer is '3693371002932'

Test #52:

score: 0
Accepted
time: 1872ms
memory: 133372kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3833465918348

result:

ok answer is '3833465918348'

Test #53:

score: 0
Accepted
time: 1830ms
memory: 133384kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

3996001000000

result:

ok answer is '3996001000000'

Test #54:

score: 0
Accepted
time: 1842ms
memory: 133152kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3996001000000

result:

ok answer is '3996001000000'

Test #55:

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

input:

20 2000
bbbbbabbbabbbbbabbbbbbbbaaaabaabbaabbbbaabbbabbabbabbaabbbabbabbabbbbbbaabbbbbababbabbbbbbabbbbbbbbbbbaabbabbbbbaababbbbbbbbabbbabbbbbbbabbbbbbbbbabbbabbabbbbaababbbbbbbbaabbbabbbbbbbbbabbbaabbbaabbbbbababbbbbbbbabbbbbbbabbbbbbbbabbbbbababbbbbbbbbbbbbbbbababbbbbbbbbbbaaabbabbbbabbbbbaabbbbab...

output:

56816

result:

ok answer is '56816'

Test #56:

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

input:

20 2000
bbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbababbabbabbabbbbabbbbbbabbbabbbbbabbbbabbbbbabbbbbbabbbbbbbbbbbbaabbabbbbababbbabbbbbbbbbbabbbabbbbbbbbbbbbbbbaabbabbbbbbbbbbbbbbabbbbabbabbbbbbbabbabbbbbbbbbbbabbbbabbbaabbaaabbbbbbbabbbbbbbbbbbbbabbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbabbbb...

output:

355419

result:

ok answer is '355419'

Test #57:

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

input:

20 2000
abbbbbabbbabbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbababbbbbbbbabbabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbaabbbbbb...

output:

1290507

result:

ok answer is '1290507'

Test #58:

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

input:

20 2000
abbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbb...

output:

3673870

result:

ok answer is '3673870'

Test #59:

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

input:

20 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

9771068

result:

ok answer is '9771068'

Test #60:

score: 0
Accepted
time: 18ms
memory: 46892kb

input:

20 2000
babaabaaaababaaabaaaaaaaaaaaabaaaabaaaaaabbaababaababaaaaaaaaaaaaaabaaaaaaaabaaaaaabbaaaaaaababaaaaaaabaaabaaaababaaaabaaaabbbababaaaaaababaaababaaaaaaaabaaaaaaabaaababaaabaaaaaaababaabaaaaaabaaaaaaaaaaaabaaaaaaaaabaabbaaaababaaaaaabaaaababaaaaabaabbabaaabbaaaabaaaaababababaabaabaaaaabaabaaa...

output:

57804

result:

ok answer is '57804'

Test #61:

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

input:

20 2000
aaaaaaaaaaabaaabaaabaaaaabbbaaaaaaaabaaaaaaaabaabaaaaaabaaaaabababbaaaaaabaaaaaaabbabaaaaaaaaaaaaaabaaaaaaababaaaaaabaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaababaaaaaaaaaaaaaaaabaaaabaaaaaaaaaaaabaaaaaaabaaabaaabaaabaabaaabaaaaaaabbaaaaabaabaaaabaabaaabaaaaaaaaaaabaaaaaaaaaaaaaaabaaaaaaaaaaaa...

output:

361169

result:

ok answer is '361169'

Test #62:

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

input:

20 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaabaaaaaaaaaabaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaababaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaabaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaa...

output:

1287432

result:

ok answer is '1287432'

Test #63:

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

input:

20 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaabaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaba...

output:

3785925

result:

ok answer is '3785925'

Test #64:

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

input:

20 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

9744215

result:

ok answer is '9744215'

Test #65:

score: 0
Accepted
time: 18ms
memory: 105904kb

input:

2000 20
bbbbabbbaababbbbbbbb
bbbbaabbabbbabbbbaba
babbabbbbbbbabbbbabb
ababbbbbbababbbbabbb
baaaabababbbbbbbbbba
bbbabbabbabbbbbbbbba
bbbabbbabbabbbbababb
bbbbbbabababbbbabbbb
babbbbbabbbbbbbaabbb
abbbbbbbbbbabbbbabbb
bbbbbbbbbabbbbbbabbb
abbbbbbbaabbbbbbbbbb
abbabbbabbbbbabbbbaa
bbbbbabbbbabaabbbba...

output:

56385

result:

ok answer is '56385'

Test #66:

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

input:

2000 20
bbbbbbbabbbbbbbbbbbb
bbbbbbbbbbbbbabbbbab
bbbbbbabbbbbbbbbbbab
bbbbabbabbbaabbabbab
abbbbbbbbbababbbbaab
bbbbbbabaababbabbbbb
bbbbabbbaabbbbbbbabb
bbbabbbbbabbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbabb
bbbbbbbbabbbbbbbbbbb
bbbbbbbbabbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbabbbbbb...

output:

348282

result:

ok answer is '348282'

Test #67:

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

input:

2000 20
bbbbbbbbbbbbbbbbbbbb
bbabbbbbabbbbbbbbbbb
babbbabbbabbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbaabbbbbbbbab
abbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbabbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbabbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbbbbbbab
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbab...

output:

1198544

result:

ok answer is '1198544'

Test #68:

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

input:

2000 20
bbbbbbbbbbbbbbbbbbbb
bbabbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbabbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbabbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbabbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbabbbb...

output:

3642961

result:

ok answer is '3642961'

Test #69:

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

input:

2000 20
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbabbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbabbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
abbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbb...

output:

9234628

result:

ok answer is '9234628'

Test #70:

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

input:

2000 20
aabaaabbbaaaaaababaa
aaabaaaaaaaaaabaaaab
babbaaaabaaabaabaaaa
baaababbabaaaababaaa
abbaaaabaaaaabaaaaaa
aaaaaaaaabaaaaabbaaa
aaaabaaababaabaaabaa
aaaaaababbabaaaaaaab
baaaaaaaaaaaaaabaaab
aaabbaaaaaaaaababaaa
aabaaaaaaaabababaaba
bbaaaaaaabaaababbbba
aaaabaaaaabaabaaabab
babaabaabaaaaaaaaaa...

output:

57704

result:

ok answer is '57704'

Test #71:

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

input:

2000 20
babaaaaaabaaaaaaaaaa
aaaaaaaaaaaaabaaaaaa
aaaaaabaaaaaaaaaabaa
aabaaabaaaaaaaaaabaa
aaaaaaaaaaabaaaaaaaa
abaabaaaaabaaaaaaaaa
bbbaaaaaaaabaaaaaaaa
aabbaaaaaaaabaaaaaab
baaaaabaaaaaaaaaaaaa
aaaaaaabaaaabaaaaaaa
baaaaaaabaaaaaaaaaaa
abaaaaaaaaaaaaaaabaa
aaaaaaaaaaaaabaaaaaa
aaaaaaaaabaaaaaaaba...

output:

346719

result:

ok answer is '346719'

Test #72:

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

input:

2000 20
aaaaabaaaaaaaaabaaaa
aaaaaaaaaaabaaaaaaaa
aaaaaaaaaaaaaaaaabaa
aaaabaaaaaaaaaaaaaaa
aaaaaabaaaaabaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaabaaaaaaa
aabaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
ababaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaabaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaab
aaaaaaaaaaaaaaaaaaa...

output:

1248199

result:

ok answer is '1248199'

Test #73:

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

input:

2000 20
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaababaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaabaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaabaaaaaaaaaaaaaaa
aaaaaaaaaaababaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaabaaaaa
aaaaaaabaaaaaaaaaaa...

output:

3835772

result:

ok answer is '3835772'

Test #74:

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

input:

2000 20
aaaaaaaaaaabaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaabaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaabaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa...

output:

9533317

result:

ok answer is '9533317'

Test #75:

score: 0
Accepted
time: 1529ms
memory: 133308kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaa...

output:

2191400000

result:

ok answer is '2191400000'

Test #76:

score: 0
Accepted
time: 1419ms
memory: 133088kb

input:

2000 2000
ccccccccccccccccccccaaaaaaaaaaaaaaaaaaaavvvvvvvvvvvvvvvvvvvvppppppppppppppppppppvvvvvvvvvvvvvvvvvvvvttttttttttttttttttttvvvvvvvvvvvvvvvvvvvvoooooooooooooooooooorrrrrrrrrrrrrrrrrrrrnnnnnnnnnnnnnnnnnnnnaaaaaaaaaaaaaaaaaaaajjjjjjjjjjjjjjjjjjjjrrrrrrrrrrrrrrrrrrrrwwwwwwwwwwwwwwwwwwwwiiiiiiiiii...

output:

416024000

result:

ok answer is '416024000'

Test #77:

score: 0
Accepted
time: 1704ms
memory: 133084kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

151925000000

result:

ok answer is '151925000000'

Test #78:

score: 0
Accepted
time: 1644ms
memory: 133340kb

input:

2000 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn...

output:

45969000000

result:

ok answer is '45969000000'

Test #79:

score: 0
Accepted
time: 1504ms
memory: 133072kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaabbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

536440500

result:

ok answer is '536440500'

Test #80:

score: 0
Accepted
time: 1373ms
memory: 133148kb

input:

2000 2000
ddddddddddkkkkkkkkkkrrrrrrrrrrwwwwwwwwwwvvvvvvvvvvaaaaaaaaaaoooooooooottttttttttttttttttttzzzzzzzzzzqqqqqqqqqqssssssssssuuuuuuuuuuuuuuuuuuuuxxxxxxxxxxnnnnnnnnnnuuuuuuuuuuzzzzzzzzzzeeeeeeeeeeuuuuuuuuuubbbbbbbbbbnnnnnnnnnnmmmmmmmmmmccccccccccppppppppppnnnnnnnnnnhhhhhhhhhhllllllllllgggggggggg...

output:

95748500

result:

ok answer is '95748500'

Test #81:

score: 0
Accepted
time: 1670ms
memory: 133080kb

input:

2000 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

49867000000

result:

ok answer is '49867000000'

Test #82:

score: 0
Accepted
time: 1578ms
memory: 133176kb

input:

2000 2000
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr...

output:

10989000000

result:

ok answer is '10989000000'

Test #83:

score: 0
Accepted
time: 1856ms
memory: 133148kb

input:

2000 2000
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu...

output:

998001000000

result:

ok answer is '998001000000'

Test #84:

score: 0
Accepted
time: 1782ms
memory: 133144kb

input:

2000 2000
gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg...

output:

249001000000

result:

ok answer is '249001000000'

Test #85:

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

input:

1 1
b

output:

0

result:

ok answer is '0'

Test #86:

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

input:

2000 1
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b...

output:

0

result:

ok answer is '0'

Test #87:

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

input:

2000 1
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a...

output:

0

result:

ok answer is '0'

Test #88:

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

input:

2000 1
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
a
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
a
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
a
b
b
b
b
b
b
b
b
b
b
a
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
a
b
b
b
b
b...

output:

0

result:

ok answer is '0'

Test #89:

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

input:

2000 1
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
b
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a...

output:

0

result:

ok answer is '0'

Test #90:

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

input:

1 2000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

0

result:

ok answer is '0'

Test #91:

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

input:

1 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0

result:

ok answer is '0'

Test #92:

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

input:

1 2000
bbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbabbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbabbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

0

result:

ok answer is '0'

Test #93:

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

input:

1 2000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0

result:

ok answer is '0'

Test #94:

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

input:

1 2000
bbaaabbbabbbbabbbbbbbaaaabbabbbababbbbabaaaaababbabbbbbaabbbaababbabbbaaabaaabaabbabbababbbabbbbbbaabbbbbaaabbbaabababaaaaabbbaabbbaabbbaaaabbbbaaaababbbababaabaabbaabbabaaabaaaaababaaaabaaabababbbbbaababbaabaababbaababababbabaaababbaaabbbbabbbbbabbabbbaabbbaaaaaaaaaaabbabbbaaababbaababababba...

output:

0

result:

ok answer is '0'

Test #95:

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

input:

1 2000
ybznxtzkzdspabhllysnjejgxhynartagoluiafvuzylklphybjbgbydzwviwrjqqcocnryvxzhilkcbzljokipgrdvilnghahtznvxlfofzrhzqwotlfgeyaratruepvpnfianhskanisdjwmekyahnaaeagdxtplxxudezjkusekalweqvvkaghkhbewxufzucflhkkwjcfikolebosrreyfdoxwgjlqvtvmmbykpzlelzoufjtskvkhilfuesudaugjalzhsjmnxhauphiglkrfpigxueotfds...

output:

0

result:

ok answer is '0'

Test #96:

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

input:

2000 1
a
b
a
b
b
a
a
b
b
a
b
b
a
b
b
b
b
b
b
b
b
b
a
b
a
a
b
b
b
a
a
b
a
a
a
a
b
b
a
b
b
b
a
a
a
b
a
b
b
b
b
a
a
b
b
b
b
b
b
b
b
a
b
b
b
a
a
a
b
a
b
a
b
a
a
b
a
a
b
b
b
b
b
a
a
a
a
b
a
a
b
b
a
b
a
b
b
a
b
a
b
a
b
a
b
b
b
b
b
b
a
b
a
b
a
a
b
a
b
b
a
b
a
b
a
b
a
b
a
a
a
a
a
b
a
b
b
b
b
a
a
a
a
a
b
b
b...

output:

0

result:

ok answer is '0'

Test #97:

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

input:

2000 1
v
o
j
f
d
l
i
c
u
z
s
u
a
r
w
a
i
a
m
o
m
r
a
e
h
j
l
x
s
v
b
v
p
a
l
s
h
x
r
j
w
w
k
u
i
x
f
m
b
v
j
w
u
u
s
g
n
v
e
t
u
u
y
h
n
x
y
k
k
l
d
g
g
q
z
h
t
m
v
p
w
e
k
t
p
p
o
f
q
d
d
g
f
h
u
m
l
z
n
w
r
n
a
g
h
h
s
i
k
k
u
l
f
i
d
p
r
d
b
t
d
x
y
d
n
l
t
p
g
r
g
e
h
p
e
c
b
f
j
i
h
y
p
u
t
r
w...

output:

0

result:

ok answer is '0'