QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#246911#7686. The Phantom Menaceucup-team052#AC ✓616ms547264kbC++234.2kb2023-11-11 11:54:102023-11-11 11:54:11

Judging History

你现在查看的是测评时间为 2023-11-11 11:54:11 的历史记录

  • [2024-10-13 19:43:23]
  • 管理员手动重测本题所有得分≥97分的提交记录
  • 测评结果:AC
  • 用时:606ms
  • 内存:532576kb
  • [2024-10-08 14:11:03]
  • hack成功,自动添加数据
  • (/hack/941)
  • [2024-10-08 10:05:28]
  • hack成功,自动添加数据
  • (/hack/940)
  • [2024-10-07 19:51:15]
  • hack成功,自动添加数据
  • (/hack/938)
  • [2024-10-07 19:28:01]
  • hack成功,自动添加数据
  • (/hack/937)
  • [2024-10-07 17:16:32]
  • hack成功,自动添加数据
  • (/hack/936)
  • [2024-10-07 16:53:09]
  • hack成功,自动添加数据
  • (/hack/935)
  • [2024-10-07 16:22:17]
  • hack成功,自动添加数据
  • (/hack/934)
  • [2023-11-11 11:54:11]
  • 评测
  • 测评结果:100
  • 用时:616ms
  • 内存:547264kb
  • [2023-11-11 11:54:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 1000005
string s[N],t[N];
int n,m;
struct Hash
{
	int mod,B;
	inline int add(int x,int y) {return x+y>=mod?x+y-mod:x+y;}
	inline int add(int x,int y,int z) {return add(add(x,y),z);}
	inline int sub(int x,int y) {return x-y<0?x-y+mod:x-y;}
	inline int mul(int x,int y) {return 1LL*x*y%mod;}
	inline int mul(int x,int y,int z) {return mul(mul(x,y),z);}
	#define inc(x,y) x=add(x,y)
	#define dec(x,y) x=sub(x,y)
	int pw[N];
	vector<int> hs[N],ht[N];
	void init(int md,int b)
	{
		mod=md; B=b;
		pw[0]=1; for(int i=1;i<=m+1;i++) pw[i]=mul(pw[i-1],B);
		for(int i=1;i<=n;i++)
		{
			hs[i].resize(m+1);
			ht[i].resize(m+1);
			hs[i][0]=0;
			ht[i][0]=0;
			for(int j=1;j<=m;j++)
			{
				hs[i][j]=add(mul(hs[i][j-1],B),s[i][j-1]);
				ht[i][j]=add(mul(ht[i][j-1],B),t[i][j-1]);
			}
		}
	}
	int shsh(int id,int l,int r) {return sub(hs[id][r],mul(hs[id][l-1],pw[r-l+1]));}
	int thsh(int id,int l,int r) {return sub(ht[id][r],mul(ht[id][l-1],pw[r-l+1]));}
}h1,h2;
unordered_map<string,vector<int>> mp;
int chksame()
{
	vector<int> ans;
	for(int i=1;i<=n;i++) mp[s[i]].pb(i);
	for(int i=1;i<=m;i++)
	{
		if(mp[t[i]].empty()) return 0;
		ans.pb(mp[t[i]].back());
		mp[t[i]].pop_back();
	}
	for(int i=1;i<=n;i++) printf("%d%c",i," \n"[i==n]);
	print(ans);
	return 1;
}
const int M=N*4;
struct N1
{
	struct Edge{int u,v,nxt;};
	Edge edge[M];
	int fir[M],id[M],od[M],ss;
	void clear()
	{
		ss=0;
		for(int i=1;i<=n*4;i++) fir[i]=0,id[i]=0,od[i]=0;
	}
	void addedge(int u,int v)
	{
		// printf("%d %d\n",u,v);
		edge[++ss]=(Edge){u,v,fir[u]}; fir[u]=ss;
		id[u]++,od[v]++;
	}
	int vis[M],ans[M],dgr[M],cnt;
	void dfs(int u)
	{
		for(int i=fir[u];i!=0;i=fir[u])
		{
			for(;i&&vis[i];i=edge[i].nxt);
			fir[u]=i;
			if(i) vis[i]=1,dfs(edge[i].v),ans[++cnt]=edge[i].u;
		}
	}
	vector<int> work()
	{
		for(int i=1;i<=n*4;i++) if(id[i]!=od[i]) return {-1};
		// printf("doing\n");
		cnt=0;
		for(int i=1;i<=n*4;i++) vis[i]=0;
		dfs(1);
		// cout<<cnt<<endl;
		vector<int> w;
		if(cnt!=n*4) return {-1};
		for(int i=1;i<=4;i++) ans[i+cnt]=ans[i];
		// for(int i=1;i<=cnt;i++) printf("%d%c",ans[i]," \n"[i==cnt]);
		for(int i=ans[cnt]<=n*2?cnt:cnt-1;i>=1;i-=2) w.pb(ans[i]);
		return w;
	}
}et;
ll shsh(int id,int l,int r)
{
	ll w1=h1.shsh(id,l,r);
	ll w2=h2.shsh(id,l,r);
	return (w1<<32)|w2;
}
ll thsh(int id,int l,int r)
{
	ll w1=h1.thsh(id,l,r);
	ll w2=h2.thsh(id,l,r);
	return (w1<<32)|w2;
}
unordered_map<ll,int> id1;
unordered_map<ll,int> id2;
void work()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++) cin>>t[i];
	// chksame();
	h1.init(1004535809,13131);
	h2.init(1000000009,23333);
	for(int i=0;i<m;i++)
	{
		id1.clear();
		id2.clear();
		id1.reserve(n);
		id2.reserve(n);
		int cnt=n+n;
		et.clear();
		// printf("* %d\n",i);
		for(int j=1;j<=n;j++)
		{
			ll w=shsh(j,1,i);
			if(!id1[w]) id1[w]=++cnt;
			// printf("%d %d\n",w,id1[w]);
			et.addedge(id1[w],j);
			w=shsh(j,i+1,m);
			if(!id2[w]) id2[w]=++cnt;
			et.addedge(j,id2[w]);
		}
		int ok=1;
		for(int j=1;j<=n;j++)
		{
			ll w=thsh(j,1,m-i);
			if(!id2[w]) ok=0;
			et.addedge(id2[w],j+n);
			w=thsh(j,m-i+1,m);
			if(!id1[w]) ok=0;
			// printf("%d %d\n",w,id1[w]);
			et.addedge(j+n,id1[w]);
		}
		if(!ok) continue;
		// printf("\n");
		vector<int> w=et.work();
		if(w[0]==-1) continue;
		for(int i=w[0]<=n?0:1;i<(int)w.size();i+=2) printf("%d ",w[i]);
		printf("\n");
		for(int i=w[0]<=n?1:0;i<(int)w.size();i+=2) printf("%d ",w[i]-n);
		printf("\n");
		return ;
	}
	printf("-1\n");
}
signed main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int T; cin>>T; while(T--) work();
	return 0;
}



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

详细

Test #1:

score: 100
Accepted
time: 23ms
memory: 176040kb

input:

2
3 3
abc
ghi
def
bcd
efg
hia
1 3
abc
def

output:

1 3 2 
1 2 3 
-1

result:

ok 2 cases (2 test cases)

Test #2:

score: 0
Accepted
time: 493ms
memory: 174360kb

input:

1000000
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
b
b
1 1
a
b
1 1
b
a
1 1
a
a
1 1
...

output:

1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
-1
-1
...

result:

ok 1000000 cases (1000000 test cases)

Test #3:

score: 0
Accepted
time: 293ms
memory: 174520kb

input:

500000
1 2
dd
ba
1 2
cd
ba
1 2
b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
-1
-1
-1
1 2 
2 1 
1 2 
2 1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 2 
1 2 
-1
-1
1 2 
2 1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 2 
1 2 
-1
-1
-1
-1
-1
1 2 
2 1 
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 500000 cases (500000 test cases)

Test #5:

score: 0
Accepted
time: 268ms
memory: 175180kb

input:

333333
1 3
cbb
bfa
1 3
bbb
bfa
1 3
abb
bfa
1 3
fab
bfa
1 3
eab
bfa
1 3
dab
bfa
1 3
cab
bfa
1 3
bab
bfa
1 3
aab
bfa
1 3
ffa
bfa
1 3
efa
bfa
1 3
dfa
bfa
1 3
cfa
bfa
1 3
bfa
bfa
1 3
afa
bfa
1 3
fea
bfa
1 3
eea
bfa
1 3
dea
bfa
1 3
cea
bfa
1 3
bea
bfa
1 3
aea
bfa
1 3
fda
bfa
1 3
eda
bfa
1 3
dda
bfa
1 3
c...

output:

-1
-1
-1
1 
1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 
1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 
1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 333333 cases (333333 test cases)

Test #6:

score: 0
Accepted
time: 262ms
memory: 175256kb

input:

333333
3 1
c
b
b
b
f
a
3 1
b
b
b
b
f
a
3 1
a
b
b
b
f
a
3 1
f
a
b
b
f
a
3 1
e
a
b
b
f
a
3 1
d
a
b
b
f
a
3 1
c
a
b
b
f
a
3 1
b
a
b
b
f
a
3 1
a
a
b
b
f
a
3 1
f
f
a
b
f
a
3 1
e
f
a
b
f
a
3 1
d
f
a
b
f
a
3 1
c
f
a
b
f
a
3 1
b
f
a
b
f
a
3 1
a
f
a
b
f
a
3 1
f
e
a
b
f
a
3 1
e
e
a
b
f
a
3 1
d
e
a
b
f
a
3 1
c...

output:

-1
-1
-1
1 3 2 
2 1 3 
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 3 2 
1 3 2 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 3 2 
2 3 1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 3 2 
3 2 1 
-1
-1
-1
-1
-...

result:

ok 333333 cases (333333 test cases)

Test #7:

score: 0
Accepted
time: 247ms
memory: 174212kb

input:

250000
1 4
hbca
fhaa
1 4
gbca
fhaa
1 4
fbca
fhaa
1 4
ebca
fhaa
1 4
dbca
fhaa
1 4
cbca
fhaa
1 4
bbca
fhaa
1 4
abca
fhaa
1 4
haca
fhaa
1 4
gaca
fhaa
1 4
faca
fhaa
1 4
eaca
fhaa
1 4
daca
fhaa
1 4
caca
fhaa
1 4
baca
fhaa
1 4
aaca
fhaa
1 4
hhba
fhaa
1 4
ghba
fhaa
1 4
fhba
fhaa
1 4
ehba
fhaa
1 4
dhba
fhaa...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 
1 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 250000 cases (250000 test cases)

Test #8:

score: 0
Accepted
time: 241ms
memory: 175228kb

input:

250000
4 1
h
b
c
a
f
h
a
a
4 1
g
b
c
a
f
h
a
a
4 1
f
b
c
a
f
h
a
a
4 1
e
b
c
a
f
h
a
a
4 1
d
b
c
a
f
h
a
a
4 1
c
b
c
a
f
h
a
a
4 1
b
b
c
a
f
h
a
a
4 1
a
b
c
a
f
h
a
a
4 1
h
a
c
a
f
h
a
a
4 1
g
a
c
a
f
h
a
a
4 1
f
a
c
a
f
h
a
a
4 1
e
a
c
a
f
h
a
a
4 1
d
a
c
a
f
h
a
a
4 1
c
a
c
a
f
h
a
a
4 1
b
a
c
a
f...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 4 3 2 
1 4 3 2 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 250000 cases (250000 test cases)

Test #9:

score: 0
Accepted
time: 245ms
memory: 176016kb

input:

200000
1 5
jjjjj
baaaa
1 5
ijjjj
baaaa
1 5
hjjjj
baaaa
1 5
gjjjj
baaaa
1 5
fjjjj
baaaa
1 5
ejjjj
baaaa
1 5
djjjj
baaaa
1 5
cjjjj
baaaa
1 5
bjjjj
baaaa
1 5
ajjjj
baaaa
1 5
jijjj
baaaa
1 5
iijjj
baaaa
1 5
hijjj
baaaa
1 5
gijjj
baaaa
1 5
fijjj
baaaa
1 5
eijjj
baaaa
1 5
dijjj
baaaa
1 5
cijjj
baaaa
1 5
b...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 cases (200000 test cases)

Test #10:

score: 0
Accepted
time: 241ms
memory: 175052kb

input:

200000
5 1
j
j
j
j
j
b
a
a
a
a
5 1
i
j
j
j
j
b
a
a
a
a
5 1
h
j
j
j
j
b
a
a
a
a
5 1
g
j
j
j
j
b
a
a
a
a
5 1
f
j
j
j
j
b
a
a
a
a
5 1
e
j
j
j
j
b
a
a
a
a
5 1
d
j
j
j
j
b
a
a
a
a
5 1
c
j
j
j
j
b
a
a
a
a
5 1
b
j
j
j
j
b
a
a
a
a
5 1
a
j
j
j
j
b
a
a
a
a
5 1
j
i
j
j
j
b
a
a
a
a
5 1
i
i
j
j
j
b
a
a
a
a
5 1
h...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 cases (200000 test cases)

Test #11:

score: 0
Accepted
time: 297ms
memory: 176320kb

input:

250000
2 2
hb
ca
fh
aa
2 2
gb
ca
fh
aa
2 2
fb
ca
fh
aa
2 2
eb
ca
fh
aa
2 2
db
ca
fh
aa
2 2
cb
ca
fh
aa
2 2
bb
ca
fh
aa
2 2
ab
ca
fh
aa
2 2
ha
ca
fh
aa
2 2
ga
ca
fh
aa
2 2
fa
ca
fh
aa
2 2
ea
ca
fh
aa
2 2
da
ca
fh
aa
2 2
ca
ca
fh
aa
2 2
ba
ca
fh
aa
2 2
aa
ca
fh
aa
2 2
hh
ba
fh
aa
2 2
gh
ba
fh
aa
2 2
f...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 2 
1 2 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 250000 cases (250000 test cases)

Test #12:

score: 0
Accepted
time: 227ms
memory: 175372kb

input:

166666
2 3
jef
aia
aaa
aaa
2 3
ief
aia
aaa
aaa
2 3
hef
aia
aaa
aaa
2 3
gef
aia
aaa
aaa
2 3
fef
aia
aaa
aaa
2 3
eef
aia
aaa
aaa
2 3
def
aia
aaa
aaa
2 3
cef
aia
aaa
aaa
2 3
bef
aia
aaa
aaa
2 3
aef
aia
aaa
aaa
2 3
ldf
aia
aaa
aaa
2 3
kdf
aia
aaa
aaa
2 3
jdf
aia
aaa
aaa
2 3
idf
aia
aaa
aaa
2 3
hdf
aia
a...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 166666 cases (166666 test cases)

Test #13:

score: 0
Accepted
time: 217ms
memory: 174692kb

input:

166666
3 2
je
fa
ia
aa
aa
aa
3 2
ie
fa
ia
aa
aa
aa
3 2
he
fa
ia
aa
aa
aa
3 2
ge
fa
ia
aa
aa
aa
3 2
fe
fa
ia
aa
aa
aa
3 2
ee
fa
ia
aa
aa
aa
3 2
de
fa
ia
aa
aa
aa
3 2
ce
fa
ia
aa
aa
aa
3 2
be
fa
ia
aa
aa
aa
3 2
ae
fa
ia
aa
aa
aa
3 2
ld
fa
ia
aa
aa
aa
3 2
kd
fa
ia
aa
aa
aa
3 2
jd
fa
ia
aa
aa
aa
3 2
id
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 166666 cases (166666 test cases)

Test #14:

score: 0
Accepted
time: 203ms
memory: 174928kb

input:

125000
2 4
heio
baaa
aaaa
aaaa
2 4
geio
baaa
aaaa
aaaa
2 4
feio
baaa
aaaa
aaaa
2 4
eeio
baaa
aaaa
aaaa
2 4
deio
baaa
aaaa
aaaa
2 4
ceio
baaa
aaaa
aaaa
2 4
beio
baaa
aaaa
aaaa
2 4
aeio
baaa
aaaa
aaaa
2 4
pdio
baaa
aaaa
aaaa
2 4
odio
baaa
aaaa
aaaa
2 4
ndio
baaa
aaaa
aaaa
2 4
mdio
baaa
aaaa
aaaa
2 4
l...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 125000 cases (125000 test cases)

Test #15:

score: 0
Accepted
time: 178ms
memory: 175304kb

input:

125000
4 2
he
io
ba
aa
aa
aa
aa
aa
4 2
ge
io
ba
aa
aa
aa
aa
aa
4 2
fe
io
ba
aa
aa
aa
aa
aa
4 2
ee
io
ba
aa
aa
aa
aa
aa
4 2
de
io
ba
aa
aa
aa
aa
aa
4 2
ce
io
ba
aa
aa
aa
aa
aa
4 2
be
io
ba
aa
aa
aa
aa
aa
4 2
ae
io
ba
aa
aa
aa
aa
aa
4 2
pd
io
ba
aa
aa
aa
aa
aa
4 2
od
io
ba
aa
aa
aa
aa
aa
4 2
nd
io
ba
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 125000 cases (125000 test cases)

Test #16:

score: 0
Accepted
time: 185ms
memory: 175468kb

input:

100000
2 5
ttjma
aaaaa
aaaaa
aaaaa
2 5
stjma
aaaaa
aaaaa
aaaaa
2 5
rtjma
aaaaa
aaaaa
aaaaa
2 5
qtjma
aaaaa
aaaaa
aaaaa
2 5
ptjma
aaaaa
aaaaa
aaaaa
2 5
otjma
aaaaa
aaaaa
aaaaa
2 5
ntjma
aaaaa
aaaaa
aaaaa
2 5
mtjma
aaaaa
aaaaa
aaaaa
2 5
ltjma
aaaaa
aaaaa
aaaaa
2 5
ktjma
aaaaa
aaaaa
aaaaa
2 5
jtjma
aaa...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 cases (100000 test cases)

Test #17:

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

input:

100000
5 2
tt
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
st
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
rt
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
qt
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
pt
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
ot
jm
aa
aa
aa
aa
aa
aa
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1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 111111 cases (111111 test cases)

Test #19:

score: 0
Accepted
time: 148ms
memory: 175420kb

input:

83333
3 4
eqag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
dqag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
cqag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
bqag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
aqag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
xpag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
wpag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
vpag
aaaa
aaaa
aaaa
aaaa
aaaa
3 4
upag
aaaa
aaaa
aaa...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 83333 cases (83333 test cases)

Test #20:

score: 0
Accepted
time: 169ms
memory: 176524kb

input:

83333
4 3
eqa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
dqa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
cqa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
bqa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
aqa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
xpa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
wpa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
vpa
gaa
aaa
aaa
aaa
aaa
aaa
aaa
4 3
up...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 83333 cases (83333 test cases)

Test #21:

score: 0
Accepted
time: 163ms
memory: 174980kb

input:

66666
3 5
bquda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
aquda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
zpuda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
ypuda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
xpuda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
wpuda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
vpuda
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
3 5
upuda
aaaa...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 66666 cases (66666 test cases)

Test #22:

score: 0
Accepted
time: 142ms
memory: 175364kb

input:

66666
5 3
bqu
daa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-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 20833 cases (20833 test cases)

Test #24:

score: 0
Accepted
time: 127ms
memory: 175132kb

input:

15873
9 7
mmxaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
9 7
lmxaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaa...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 15873 cases (15873 test cases)

Test #25:

score: 0
Accepted
time: 106ms
memory: 175640kb

input:

10000
10 10
puoaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
a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 
1 2 
1 2 
-1
1 2 
2 1 
1 2 
2 1 
1 2 
2 1 
1 2 
1 2 
1 2 
1 2 
1 2 
1 2 
-1
1 2 
2 1 
1 2 
2 1 
1 2 
2 1 
1 2 
1 2 
1 2 
2 1...

result:

ok 250000 cases (250000 test cases)

Test #27:

score: 0
Accepted
time: 280ms
memory: 175500kb

input:

166666
2 3
aib
avi
aib
avi
2 3
btw
xjw
xjw
btw
2 3
dng
ouv
uvd
ngo
2 3
ctq
sve
sve
ctq
2 3
ott
obm
ott
obm
2 3
aly
tmx
aly
tmx
2 3
nhm
zar
arn
hmz
2 3
knr
qpa
nrq
pak
2 3
gsw
fyn
sng
ywf
2 3
qcy
rov
qcy
rov
2 3
nmj
tyx
tyx
nmj
2 3
dbu
pim
pim
dbu
2 3
afj
zwf
ffa
wjz
2 3
vgo
sky
gyv
kos
2 3
zru
bog
u...

output:

1 2 
1 2 
1 2 
2 1 
1 2 
2 1 
1 2 
2 1 
1 2 
1 2 
1 2 
1 2 
1 2 
2 1 
1 2 
1 2 
-1
1 2 
1 2 
1 2 
2 1 
1 2 
2 1 
-1
-1
-1
-1
1 2 
1 2 
-1
1 2 
1 2 
1 2 
1 2 
-1
1 2 
2 1 
1 2 
2 1 
1 2 
2 1 
1 2 
1 2 
1 2 
2 1 
1 2 
1 2 
1 2 
1 2 
1 2 
1 2 
-1
1 2 
1 2 
1 2 
1 2 
1 2 
2 1 
1 2 
1 2 
1 2 
1 2 
-1
1 2...

result:

ok 166666 cases (166666 test cases)

Test #28:

score: 0
Accepted
time: 283ms
memory: 174608kb

input:

166666
3 2
yx
pd
tl
dt
xy
lp
3 2
xb
pc
cr
xb
pc
cr
3 2
bw
bl
so
bw
bl
so
3 2
oq
eu
tx
eu
oq
tx
3 2
tk
ul
ep
le
kt
pu
3 2
ze
en
iq
qe
ei
nz
3 2
zn
vd
nz
nv
zn
dz
3 2
sn
aa
sl
aa
sn
sl
3 2
cn
lx
jn
cn
lx
jn
3 2
il
td
rf
rf
td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2 
2 7 3 5 1 4...

result:

ok 125000 cases (125000 test cases)

Test #30:

score: 0
Accepted
time: 205ms
memory: 174648kb

input:

100000
1 10
klhmhvkswy
wykjhmhvks
1 10
uqieigoabd
qieigoabdu
1 10
bunljqpvov
vbunljqivo
1 10
ytkmhxtntc
xtntcytkmh
1 10
lufmlhxbvz
ufmlcxbvzl
1 10
cuemsefukn
sefukncueq
1 10
oomyzzliuk
zzliukoomy
1 10
piekrxtsag
rxtsagpiek
1 10
pwhbveolnf
nfpwhbveol
1 10
wsyjzqnbtj
jzqnbojwsy
1 10
iqayiqecea
aiqaytq...

output:

-1
1 
1 
-1
1 
1 
-1
-1
1 
1 
1 
1 
1 
1 
-1
-1
1 
1 
-1
-1
1 
1 
1 
1 
-1
1 
1 
-1
-1
-1
-1
-1
1 
1 
1 
1 
-1
1 
1 
1 
1 
-1
1 
1 
-1
-1
1 
1 
-1
1 
1 
1 
1 
-1
-1
1 
1 
1 
1 
1 
1 
1 
1 
1 
1 
-1
1 
1 
1 
1 
1 
1 
1 
1 
-1
1 
1 
-1
-1
-1
1 
1 
-1
1 
1 
-1
-1
1 
1 
-1
-1
-1
1 
1 
1 
1 
-1
-1
1 
1 
...

result:

ok 100000 cases (100000 test cases)

Test #31:

score: 0
Accepted
time: 207ms
memory: 175508kb

input:

28571
7 5
rpdbr
kijbw
qotha
wvxmn
frbey
tdjed
vqpoy
havot
bwfrb
edrpd
mnkij
eyqqp
oytdj
brwvx
7 5
pecul
iozuk
kxkfg
ivcha
erold
abatw
otvoe
otvoe
kxkfg
abatw
ivcha
pecul
erold
iozuk
7 5
qmwhz
odnhu
dkzle
roeec
xftep
axzal
kgusp
ecdgu
huxft
epqmw
lekkz
alroe
hzaxz
spodn
7 5
aefno
popfk
shavv
cvhdy
na...

output:

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

result:

ok 28571 cases (28571 test cases)

Test #32:

score: 0
Accepted
time: 353ms
memory: 192108kb

input:

1
1000 1000
plxpgukngtaywjrcxufvdwswaozxzeeduaeqslxuzcevplzosuqsedbplkmzbpyogbndbzmyfeyqamtetcjmaosbaxcrmjanjeglavxlwksvvenehzgrovffaebdtpynzajedywisavqgjjtjnqktzltyfzbvrtsfmdkzsyougzyqcckjcjjtkewysagddaizqnnptunmfyqagnxrzjqpsoqzqptzvjnfilpbgmjbetcgnewclwqxmftpepudwufcmbqtpyxajfmabqyvlgqxzhgumauzxms...

output:

-1

result:

ok 1 cases (1 test case)

Test #33:

score: 0
Accepted
time: 270ms
memory: 363440kb

input:

1
500000 2
bh
nk
zd
bw
cc
la
zr
if
ts
tq
nz
td
rv
th
nw
az
pa
qy
cq
uu
rk
sl
du
ll
jn
fw
qm
rw
va
ii
as
hw
wo
vt
zi
yt
wx
xd
en
ws
we
rw
gk
lp
hh
qp
fj
cu
uu
bp
uq
ge
lb
sa
hg
yx
gm
cu
tr
wj
ws
ei
cv
ct
wn
at
ju
mo
bm
ht
ep
ul
jt
yw
wu
ml
sh
vt
kp
ha
ws
qy
pn
nz
aq
wa
my
mf
bq
ff
xo
br
uc
pt
ne
ya
i...

output:

1 499980 499918 499976 499988 499961 499975 499936 499959 499991 499922 499990 499968 499951 499866 499965 499999 499960 499998 499993 499983 499964 499863 499984 499986 499909 499949 499932 499966 499852 499994 499972 499948 499917 499938 499985 499839 499989 499859 499940 499848 499979 499894 4999...

result:

ok 1 cases (1 test case)

Test #34:

score: 0
Accepted
time: 434ms
memory: 546344kb

input:

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

output:

1 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 999959 999...

result:

ok 1 cases (1 test case)

Test #35:

score: 0
Accepted
time: 140ms
memory: 195272kb

input:

1
2 500000
yoskytdthibiosryionvxhjbnvwyrumjrmogzlngtxwkyxpketeperfdqboobxcccofgoxsjjffgdymvbhrnmcfiresutjbeadpbwuyxbirokynuisiezakhyivnbelkoexbfertmmmpjyerxyrnxvseyyipjqexidomwdzwqgqopwvnguawlvdyqgpsoxuliobzndxyfondeygqyxujboqcmqmwlptkpxflccjwfbzvwjkmddqxuenqirajuqplwjfyumjycekqzgavjrpanuxixmwlmnnvv...

output:

1 2 
2 1 

result:

ok 1 cases (1 test case)

Test #36:

score: 0
Accepted
time: 120ms
memory: 195596kb

input:

1
1 1000000
vvzoohphaekmooymvzpvxqaxbgyabgrgrdetsieivthqtvackeaapshmaybrwivlzjtjymeqmjqjoioeknzlajdqeptnywzscjthxqahapfnktonvxbyridjhokyielyfuzzgciiulnuetgfmdppmpywhoouwbbwyhlufupqwkhjubvkplfbzxiegngnewwfpupzypskuhtopvqzczthyaxpepvbkhvitkxgopxprykcrbjnuiideigftkhgzpykkoijuiquebxaaiwaabuxssgqgsofmiid...

output:

1 
1 

result:

ok 1 cases (1 test case)

Test #37:

score: 0
Accepted
time: 194ms
memory: 193012kb

input:

1
1000 1000
nnnaamfktzgakyenqodpbujtlowzoloijjqorpyvgfbujjivqhgrvcsuajhkfnxfrtrrhfanoutnxetnhowuknugksqgbtpyixedmyepfgyluqjvgadnsosbevsprmupvmymsmohjpimcbgkrybnnlrgqewddkotengibpfdpfqbehofyslubivwusaxzjnbbuczjponsogapfzqnshokuerpwuewcedjmtykebmibjanhyfhvuieexfxijacmpkqatvctadngmkuefrfqthukhywwqllwwy...

output:

1 701 271 197 452 550 3 128 130 751 760 687 911 307 319 158 59 934 287 446 219 114 786 696 476 785 252 628 708 606 273 978 238 848 928 231 269 907 265 21 715 676 426 441 545 268 714 402 810 719 475 962 693 700 946 104 153 309 884 630 382 873 568 502 524 936 399 626 640 15 138 140 756 333 991 759 765...

result:

ok 1 cases (1 test case)

Test #38:

score: 0
Accepted
time: 251ms
memory: 367248kb

input:

1
500000 2
lm
hm
wf
rl
ze
qc
ku
dz
is
dg
lc
kw
ys
ho
re
gu
pb
on
oe
wc
ya
kx
zh
fg
lb
fn
ys
ci
da
ta
mg
nc
qj
tx
tn
zw
gu
na
ee
oa
qm
zz
hx
rs
fl
bz
ik
fm
sq
xr
tf
id
lh
bk
sw
qx
lw
aa
bx
cg
ns
vl
bg
im
qp
pc
rh
pa
ns
kf
la
pl
am
sz
xs
xq
uc
wf
lz
iq
ok
mh
wi
kj
ui
xl
na
fs
vg
wf
qg
rn
th
ju
rp
fs
w...

output:

1 500000 499999 499998 499997 499996 499995 499994 499993 499992 499991 499990 499989 499988 499987 499986 499985 499984 499983 499982 499981 499980 499979 499978 499977 499976 499975 499974 499973 499972 499971 499970 499969 499968 499967 499966 499965 499964 499963 499962 499961 499960 499959 4999...

result:

ok 1 cases (1 test case)

Test #39:

score: 0
Accepted
time: 420ms
memory: 545340kb

input:

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

output:

1 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 999959 999...

result:

ok 1 cases (1 test case)

Test #40:

score: 0
Accepted
time: 293ms
memory: 193768kb

input:

1
2 500000
csbazestpjffzjvrjztjidouhfewitwyhczwalacmlfmfpjozlnojeeltcyjkgbwpnzhzdeeublvjcgepkupvlqxhzkjfudcojhtxsrndyipgsuexhdjxodymiofmaxdkhsyallmorhqdrosgvzwvsgobotbwlwnqvohekjougktqmjaknocgtumjjvmtphfnoqrsrfgztpufvtnafmhmmcpxkrjyokgrlvaswhkkxfxguuakezavqkbkvnhjpycgvrsefranfttvrfnoaeempqhlsdzwtrvf...

output:

-1

result:

ok 1 cases (1 test case)

Test #41:

score: 0
Accepted
time: 118ms
memory: 196048kb

input:

1
1 1000000
zcgzehvspliuqlawrvemmxvlapmqsnpdieaqubpadgbsduckarfgikvmcphtdjtgczbfuivcjhpmwgaxoqvbmwldxvqwtcqizfyvxoahqcuyyvdgxzsohnkjblrwuyietchhqusxamzculyvhaqzoftboauhkdxnpxuxbljmftjtyrczfxxsbwkvzhehmwkhvbkjmnuypbjgibszsdtocihfzwuvdpvszccyroufgktzfytdkcrneuvelrcoufxvmxajvhlnikzfemppharjuwicizqodvrj...

output:

1 
1 

result:

ok 1 cases (1 test case)

Test #42:

score: 0
Accepted
time: 339ms
memory: 191532kb

input:

1
1000 1000
vkrkwbibcsuczrgypnuclsmvexjomqttgzmpebzbtmtltqyekywmlpmluwwmjjybbnztlxthcphhfayjjegghgyuippcrweyyzgjfnzemamafgtexvhxofarelxdoptwfohqrnjepcpxzkoepuluocahihxhqipydaiermnrbxjpkeundrirpdcalvbjyhhdazarjuwepzaiafcmbaxqlfqcnbzvlamfwgpqoutqvwhilaqswbqzvohiayenlifowexxzvuxrldswlfpjugwozxwzpxeqtkb...

output:

-1

result:

ok 1 cases (1 test case)

Test #43:

score: 0
Accepted
time: 264ms
memory: 367056kb

input:

1
500000 2
pa
fn
bi
ka
az
wj
sf
db
xb
ad
di
ur
he
dq
bv
zf
cw
yw
ha
to
hl
al
wi
pq
pq
ao
eh
ua
xo
oi
dw
nz
do
dn
oq
sd
bn
nj
fa
mx
vx
ss
pp
dz
jk
us
mv
ko
gk
wa
ju
em
bc
tp
qx
cr
rh
ro
qx
vk
bm
ju
ir
kd
ny
gw
sg
js
qt
zi
uf
pg
md
du
he
qy
ur
ge
dp
ho
hb
ig
zi
dr
wq
ix
my
gz
tf
kb
ab
ye
zf
rx
cy
mq
o...

output:

1 499984 499996 499949 499998 499988 500000 499967 499976 499977 499983 499973 499961 499987 499908 499975 499959 499997 499995 499989 499880 499946 499991 499868 499994 499945 499902 499969 499892 499972 499990 499971 499960 499962 499986 499982 499979 499939 499950 499992 499968 499980 499944 4999...

result:

ok 1 cases (1 test case)

Test #44:

score: 0
Accepted
time: 398ms
memory: 547264kb

input:

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

output:

1 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 999959 999...

result:

ok 1 cases (1 test case)

Test #45:

score: 0
Accepted
time: 523ms
memory: 238316kb

input:

1
100000 10
ehlimdmwkt
jlrfzdjvam
jwtsqoiebv
mlksfsakmd
zamugzmeha
nxepoofxsh
idoigdreky
ugarhoilzd
oalhajmyfd
vfnxfsoasz
fymboaopqw
rgyhcdtcxm
nvgtvzxgqs
uhwapwajcq
udicenzrkr
jgeaupojpv
efrdqjgayp
yvqwqkaipk
jlsbzxdzeh
btdjgvxcqd
uqcoyaaohl
szcxibrkvc
yzyntbtiuo
lbwkorixzq
lfffvwuktb
euhjmdnptr
tb...

output:

1 51746 40066 53594 77723 84016 89474 77557 27094 18261 54879 62978 77971 96260 25635 72637 19012 48494 37101 28138 79542 82872 58419 91540 73214 25035 2962 38380 51319 962 10056 55524 13504 79432 50524 26983 82467 75428 4886 29622 64354 89599 62919 85034 29360 36584 75096 81736 785 3932 29317 57507...

result:

ok 1 cases (1 test case)

Test #46:

score: 0
Accepted
time: 145ms
memory: 231492kb

input:

1
100000 10
mqpzaypqsg
rybikrqyzx
gxcfzgdglt
sszegicsli
oxzpnucwde
ezkskhdmiu
lqsgzsxckw
jlglibuvpi
ctqjnskviw
yqhiaisjxf
mpmgtaupwp
swrhvwtxpg
wcgchdtjyk
hynexzwpxj
veaomhaxnn
bluwuxnmyj
zeefjdwksv
lgegdqxuyt
ezkpautemn
ykbpibnfsp
ddbtafikzb
cetuawmhwo
epwldttkrv
lytomstlzm
wugxtmlmzf
atathrowwp
sv...

output:

1 99994 99999 99991 99973 99974 99970 99969 99944 99976 99917 99956 99967 100000 99963 99948 99984 99982 99932 99946 99952 99938 99972 99996 99980 99942 99990 99992 99941 99929 99987 99940 99981 99960 99998 99913 99986 99997 99968 99911 99959 99993 99989 99988 99975 99957 99985 99884 99983 99921 999...

result:

ok 1 cases (1 test case)

Test #47:

score: 0
Accepted
time: 341ms
memory: 233148kb

input:

1
200000 5
untrg
qewwk
zdlct
ltaki
tegsd
pllgg
jvwkk
pkcru
donwe
elvdq
crquy
yqlbl
yalff
rwhfy
xlsqg
vzjww
vjdni
vevwr
njecm
onvvj
ldfjq
ypgae
vuuvu
jxgce
weone
hnklb
hkkyw
tuwyp
kgcad
octvg
gfkei
ovmql
kxzta
npvrv
pxenv
hklvf
sfzso
blanl
jigxz
uqcrk
lbehm
cxwbq
ymdzw
hmvpk
wjdqq
kpfls
rktrp
ogdhs
f...

output:

-1

result:

ok 1 cases (1 test case)

Test #48:

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

input:

1
100000 10
fxhzgdmpvu
rbapkxuwdz
rcbtjgzlqz
vuwjdihqwk
brwenfhpot
cazbgafcaa
ylyhnyrgwt
sixsqzjakz
qdxsdrthuu
zdrwkcqqdk
xluoyqriep
wpcqewlpfo
ebcmamyzmt
fanzqaxbew
ikmsqafyun
xczrzagmdn
bbsvmsrtph
sjtudpeyqj
kdvxgfnozj
pnbefumkkh
xjahjflidu
begdvasklf
xcragpudlh
pkugzyrpgn
dtlznmvred
supuawndia
xa...

output:

1 100000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 999...

result:

ok 1 cases (1 test case)

Test #49:

score: 0
Accepted
time: 339ms
memory: 233076kb

input:

1
200000 5
rdaxv
rqwti
srbck
qdtal
ltoxk
ughkh
sywke
cigmu
fioqb
gnycn
cexck
tcekr
byyqn
cgokp
ausjo
ubsgq
sxouf
xxvnu
drjqw
nvaul
ashzf
scexc
ueyta
ryyny
xotaf
prjgo
hjfrk
alqrp
zggry
xrivg
wislr
lzygn
lleum
utbzq
dzbpn
kmkvp
bacqh
kdfik
xaqru
aeeem
otmht
exrjh
poyfh
rgggk
mhbof
kqyzm
czill
oygax
c...

output:

-1

result:

ok 1 cases (1 test case)

Test #50:

score: 0
Accepted
time: 292ms
memory: 193696kb

input:

1
2 500000
tossrwlzkdzzrphwvvnkmdevslssgacszrojwkxgorcupejhwfybmoyegfhulclkqadmdjpfccnbxhsumeffzhfowyhxqqpdrjguansbqlyuglodfwxjphusmwlevcmpjfcbrjbmdbsqovuljaxqfeorcmgjsbwxappqwsuacmjtyhjubdjyevglxpkektgumdrvtwkuzdiyznzactijqouerxfqatzcwjqserfliiqihufyinagdbqglcnqttlhkebmezdjcfvdcmcjgqhygbxmvzndqnywm...

output:

-1

result:

ok 1 cases (1 test case)

Test #51:

score: 0
Accepted
time: 224ms
memory: 194068kb

input:

1
1 1000000
aqfomtfebdjjikpwsgohpqhvbrasmasgmocifvxczotxorlguxtriaftafotynozikgxytfzuztzapeayssibygltogshsbfwlfcqzbfkleizodgzztxzaysqtsvokwictzyehplvlkpucyizyrcimlczpucivarsihznzqmkjyuhajkgasakdeechddnrezbboozngkyxrjkzfgdlzjewmzhfwmfzguwukeeaambyszysderzrbbbdraxbdpqrurmztoepgptyjtbnrwpyntoagemsfeari...

output:

-1

result:

ok 1 cases (1 test case)

Test #52:

score: 0
Accepted
time: 372ms
memory: 238808kb

input:

1
100000 10
kxlhbmfknl
mldtlbegjo
roglqswqdz
fkcfeioyrf
varxnuxhyk
yputtwlqnj
qjfqxkpbug
thnarwcjpt
oqfpxygtat
hagzhuqeem
bwnnbeweqg
semgcubiaz
zoomamfsyb
lhocxkgyvp
nzqeqkhpes
hhhqaraqjq
mdcgqoqgbp
gvsxjqnvjv
sfkoamvaor
sngtozdbrc
yrhpdcfhhf
eptkmcorhi
hwszrfyvqr
xemzcudvkz
rjklevonsv
vnpmsgqdcb
sy...

output:

1 59599 66929 73633 34097 62179 91126 10039 45512 49620 44140 11166 50906 49981 50345 71716 19329 24226 50018 31552 23012 39096 73489 27739 8907 68429 23507 82363 55227 97796 45164 35712 41951 89979 41457 78737 57195 30144 15805 84028 90346 87184 19992 83648 92193 52510 46198 36344 67348 96298 98390...

result:

ok 1 cases (1 test case)

Test #53:

score: 0
Accepted
time: 515ms
memory: 223572kb

input:

1
100000 10
dplijbwkgs
yigahsojnn
ftafmnroiu
gklxajdgis
lkkiioljfz
mkckxjukta
rwxjqmbddd
opvmalbpzl
ngobvwffjt
ziszyyrvkb
hxjvrmnlnm
pcytdvmvcb
jyzqhxxzpd
ykfcpnynxt
tqfqojtyoc
cyphatoadm
nsibkreiqr
sjujphkbwv
wdccnduvvj
gefgntmint
qodiytabxc
vpeltdzowm
fppmxjflkq
vhohdpiocs
vuudozaxuh
uoonxsqeko
iq...

output:

-1

result:

ok 1 cases (1 test case)

Test #54:

score: 0
Accepted
time: 437ms
memory: 240124kb

input:

1
100000 10
qyjclrjhcv
hrexdepsrh
drbmgtcoed
twbslhlapq
tocwgicnrn
ndudcbqcoz
eunlkqeugj
ictesjwnlv
ukatawfiji
dktfpbehwi
yggzqhuccl
oznogatwir
efcduoftki
ojyrolvatq
fkpbtdwpmj
lliymvqkws
taqnrqowtg
uzfiimgmkz
lmavtcmajn
hagghgkdro
eprquadsxn
ztmzpejqea
vzitenazyw
nhcbbtdnuu
frafncvjoy
javzrcwaus
ap...

output:

1 35767 42520 53681 86955 11598 12777 25620 89709 99016 90955 2507 10424 10747 36339 90461 44658 96933 10277 45358 45316 35406 76713 52651 63980 28975 87299 76534 39979 48974 40447 90788 89302 24763 97413 36447 53333 47583 24073 77152 16428 89870 89542 5210 26329 61417 96129 63015 33910 41175 67967 ...

result:

ok 1 cases (1 test case)

Test #55:

score: 0
Accepted
time: 505ms
memory: 225672kb

input:

1
100000 10
sypalllczm
fyvwvgicyp
jqomdiqcfp
aeaaztogli
imxeiuthuk
ydkrfpfmft
udmkztmwfe
ohyczkizug
fzjyyniywg
itrowixklc
tussdfceqf
evpuvluxpg
iluimcnpco
olstppvixo
dvdpowweue
hxiodpcvjl
xhflfalebb
vpfsjldkqf
dfjslcblpv
dzfptmeyqv
rvgrnefzaj
illzbltjxb
xbbdvyufbw
frovlztkno
gsylowileo
zasbhsaiku
rw...

output:

-1

result:

ok 1 cases (1 test case)

Test #56:

score: 0
Accepted
time: 360ms
memory: 236672kb

input:

1
100000 10
jghpqhzbwn
khmnmmjces
evcbszdsee
cpedxvljuc
bijisgizio
lwybtheziw
azeowrjbes
bvcakdyowl
hqrgrmdxkv
latrynwkve
zbwrfmlfzl
bwsrqcxufw
mlxgssthvv
tbnlrnnagy
fumhlmrrsc
klisexvqbh
fuhiznqnbs
gydnvmatzs
kddgnpybzt
lqtposlfrf
teyereqlki
phffqzyxsk
zivoiupzye
fhyewkrofw
vmhqdpsznj
kkfzikuoop
fd...

output:

1 50473 61393 8558 92736 94583 44784 51973 32727 17375 4522 19110 87863 40624 38466 27204 78752 33133 45240 96159 75894 93178 51609 79339 18755 58042 27119 5760 35955 59462 3374 26038 34041 64755 81250 49964 8308 2260 80387 38145 9941 37930 47428 36944 7068 80293 44814 12153 94858 56174 34488 15075 ...

result:

ok 1 cases (1 test case)

Test #57:

score: 0
Accepted
time: 463ms
memory: 240052kb

input:

1
100000 10
ajdomreiyg
awhziinfwu
gtqxnxstjq
acgalthnvc
rlnbmtemxi
ouqfgtxjel
zrpqnultuj
ajpfxgstzw
ugccienqit
cgyjlqfkma
fvvzhsruhh
xzvtqxdzfx
bzklilivkt
vracwjjijn
pijsxthpiv
sloandhcmh
uezrrpwwrp
qizguxpvwx
fgfwudmpmw
zmddapzqly
fvxavrqcax
pstjlrahls
zaewasovpv
wxbnphincw
bcauhtuzyg
svvtswoswv
sy...

output:

1 57846 92013 21765 11918 68529 69110 13553 50631 74356 38235 73852 85060 10795 95548 37306 56169 69792 42634 78165 64900 44629 4340 77474 40780 83408 2983 68063 62707 55508 46320 24464 88689 78097 59127 41974 98400 50542 23903 46014 46112 59021 6301 63153 99644 64717 71953 45321 46122 51830 93757 6...

result:

ok 1 cases (1 test case)

Test #58:

score: 0
Accepted
time: 521ms
memory: 232412kb

input:

1
100000 10
otqeflvutp
ktjpzyjlbe
utqhsjbhxi
jmmcfrwiml
vfxvqrdzdk
aenkvqbzpo
bfdzgohawd
vdsqzihcsw
jicioserdw
eberxkmhko
vsmxkcsymw
aunqxqooio
fuserissyp
powkmizyqg
pklrsxredz
kvwierqibi
wrzusyeiou
odjaxqedqv
xxntmrkafl
wkgkolzgdv
jxwmcpjiya
pxyhhfzjsh
ewcjkdaymm
taklqmzazs
mwvlhirbzn
lfzultiztz
sn...

output:

1 53679 93443 3262 4945 70022 93564 76676 52299 68415 4939 36043 96246 18612 85456 54233 88666 37387 38982 6995 64493 47556 62620 33010 62596 65764 73466 23515 7347 57205 55731 38421 72870 29537 25985 94510 33875 6171 67583 71967 3304 69423 65886 69459 83072 24482 22915 21370 1019 40083 56055 3503 8...

result:

ok 1 cases (1 test case)

Test #59:

score: 0
Accepted
time: 541ms
memory: 222124kb

input:

1
100000 10
uxfboqjiml
urguovogte
hlfrgfwgkz
lnaljmgocb
cbkdynsxzg
jfggokuktr
fgeeeayprq
glgeqdexax
ccwqbwaake
pexvcckyid
rjvzlorehp
jwrolcaeqq
pwftjauyxv
dtblxopysv
pmvikikgse
pldtousdqo
tgenvzvdnr
payixpmmjr
urkthfeotj
pqomqonmqf
wsnfwcbqce
ynjhtrkmcg
nqjuozngbr
ombhjkloow
fxbwspocpf
ovcbrjolwn
yn...

output:

-1

result:

ok 1 cases (1 test case)

Test #60:

score: 0
Accepted
time: 577ms
memory: 240108kb

input:

1
100000 10
ipzgqbnfvd
sgfrlagntk
gwwweijzea
fxpgdtxgti
waobttsufl
nrdslhdkxf
ssrwruilxq
pdglmfvowa
azjbrlhzff
pchtakzdkl
ajsqpedcoy
pjsukcypln
fiognbhmxj
agpmnzvnms
ikdnsabypt
zaotlspbvj
nummgjsshd
mtteglneuy
eopvrvdxtb
nuwnziuqyv
pmqxpafghb
krwuxxunvh
dnumirddbi
oyiyooimqd
zmlwgndkny
ybxqktsjpq
kv...

output:

-1

result:

ok 1 cases (1 test case)

Test #61:

score: 0
Accepted
time: 616ms
memory: 234792kb

input:

1
100000 10
vhntzmzfjq
lpkanhwnma
hnshcjeytm
rroumhwnmt
jeweevjgqp
bsegdybxio
rwtjvtvlko
fmpcrdsdes
edijyqpurg
zghldxztvl
xbcsrduzmx
tguxmkqcfz
bajotxtuii
zsfgpkokbg
xrgnvbpctc
clxyepehzt
veudydfurf
mavbkeurwo
nfmwtnwspx
uahthuvvxc
vdaadmfinf
kyhxwovgtv
jnqppwnuvt
hiepfckmpa
oxrklvvyof
iintishepc
eq...

output:

1 560 69620 14839 19857 37861 49637 40661 21528 8592 70423 9913 36310 30283 61361 7333 81257 70082 86088 13823 46795 63832 80795 86535 25113 90810 6070 20396 96730 99735 1482 9437 96923 75528 20735 98206 70756 4544 99066 95984 76725 1496 16196 83728 60179 51719 80722 996 94146 3391 64028 20179 79398...

result:

ok 1 cases (1 test case)

Test #62:

score: 0
Accepted
time: 407ms
memory: 240032kb

input:

1
100000 10
uudwzdlejj
ivabpznlij
uqnmtxmmgg
ntzanognix
qdgoodcnun
pekrqklkez
eejprmjekr
pwblriymwp
rievkuhrez
npbdnosxjq
eoeicddyic
hotgqnlmge
iygqxwlogm
pnsgildmtr
rqkpassked
qpsqosjzsm
phxkunmotd
oohtwpcpli
ejeiosheqn
rzrjlvpkfa
ynajbomlnb
awxowbwzxx
hfajxtyefh
ulxeladiwo
mroseowqdn
fszffsdlmi
lm...

output:

1 88278 14640 77721 33950 19930 75078 82004 9823 76099 51583 10353 20723 45803 43503 563 71024 47251 78957 71242 84982 51624 23688 71472 24735 43579 18423 54425 1179 99128 80990 6580 57086 18874 72429 26993 57397 40212 28455 77333 7294 24370 56642 21611 71860 59179 84828 44261 26796 31733 89157 1275...

result:

ok 1 cases (1 test case)

Test #63:

score: 0
Accepted
time: 548ms
memory: 225736kb

input:

1
100000 10
akvvptzhlm
ukqiqwgjxr
raftyctsec
tljopwxqgm
odkoyjszvv
vuuxpzuwty
vugkbhgrbq
mghdhtbdmh
cmlrrcpkrj
fropiipnog
fippflholr
hxvyifxfhi
dstwpsdbxl
zekzumxmnr
qywqzyxvln
jacdvjvczu
dpmjugphun
hhrhfdjzkx
jfwnfjfokw
ygziaihrgd
ybrhjiwfaj
nketysvhiu
sydarvrsdv
zlhwpjkvmc
ynaolmsimg
tgjfocrgba
kh...

output:

-1

result:

ok 1 cases (1 test case)

Extra Test:

score: 0
Extra Test Passed