QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#359229#7686. The Phantom MenaceCodeChildAC ✓2440ms427780kbC++205.5kb2024-03-20 15:00:212024-10-08 10:18:37

Judging History

你现在查看的是测评时间为 2024-10-08 10:18:37 的历史记录

  • [2024-10-13 19:48:45]
  • 管理员手动重测本题所有得分≥97分的提交记录
  • 测评结果:AC
  • 用时:2508ms
  • 内存:428268kb
  • [2024-10-08 14:36:42]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:2546ms
  • 内存:428404kb
  • [2024-10-08 14:11:03]
  • hack成功,自动添加数据
  • (/hack/941)
  • [2024-10-08 10:18:37]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:2440ms
  • 内存:427780kb
  • [2024-10-08 10:05:28]
  • hack成功,自动添加数据
  • (/hack/940)
  • [2024-10-07 20:01:50]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:2437ms
  • 内存:427860kb
  • [2024-10-07 19:51:15]
  • hack成功,自动添加数据
  • (/hack/938)
  • [2024-10-07 19:39:30]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:3184ms
  • 内存:428536kb
  • [2024-10-07 19:28:01]
  • hack成功,自动添加数据
  • (/hack/937)
  • [2024-10-07 17:29:55]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:2581ms
  • 内存:428344kb
  • [2024-10-07 17:16:32]
  • hack成功,自动添加数据
  • (/hack/936)
  • [2024-10-07 17:08:25]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:2626ms
  • 内存:428704kb
  • [2024-10-07 16:53:09]
  • hack成功,自动添加数据
  • (/hack/935)
  • [2024-10-07 16:44:29]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:2529ms
  • 内存:427692kb
  • [2024-10-07 16:22:17]
  • hack成功,自动添加数据
  • (/hack/934)
  • [2024-03-20 15:00:25]
  • 评测
  • 测评结果:100
  • 用时:2905ms
  • 内存:321384kb
  • [2024-03-20 15:00:21]
  • 提交

answer

// Problem: J. The Phantom Menace
// Contest: Codeforces - 2023 China Collegiate Programming Contest (CCPC) Guilin Onsite (The 2nd Universal Cup. Stage 8: Guilin)
// URL: https://codeforces.com/gym/104768/problem/J
// Memory Limit: 1024 MB
// Time Limit: 4000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <cstdio>
#include <unordered_map>
#include <deque>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <bitset>
#include <limits.h>
#define x first
#define y second
 
using namespace std;
typedef  long long LL;
typedef long long ll  ; 
typedef pair<int,int> PII;
typedef pair<int,LL> PIL;
typedef pair<int ,PII> PIII ;
typedef pair<int, pair<PII ,int > > PIIII;
typedef pair<LL , LL> PLL ; 
typedef pair<LL ,int > PLI ;
typedef pair<int,char > PIC ; 
typedef unsigned long long ULL ;
 
const int N = 1e6+10,M = 4e5+10  ;
const LL mod = 1e9+7 , INF = 1e18+10;
const int inf =  1e8 ; 
const double eps = 1e-7 ;
const ULL  P=  131 ;
int n , m  , k   ;
#include <random>
#include <chrono>
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());

bool isprime(int n) {
    if (n <= 1) return false;
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
            return false;
    return true;
}
int findPrime(int n) {
    while (!isprime(n))
        n++;
    return n;
}

template<int N>
struct StringHash {
    static array<int, N> mod;
    static array<int, N> base;
    vector<array<int, N>> p, h;
    StringHash() = default;
    StringHash(const string& s) {
        int n = s.size();
        p.resize(n);
        h.resize(n);
        fill(p[0].begin(), p[0].end(), 1);
        fill(h[0].begin(), h[0].end(), 1);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < N; j++) {
                p[i][j] = 1ll * (i == 0 ? 1ll : p[i - 1][j]) * base[j] % mod[j];
                h[i][j] = (1ll * (i == 0 ? 0ll : h[i - 1][j]) * base[j] + s[i]) % mod[j];
            }
    }
    array<int, N> query(int l, int r) {
        array<int, N> ans{};
        if (l > r) return {0, 0};
        for (int i = 0; i < N; i++) {
            ans[i] = (h[r][i] - 1ll * (l == 0 ? 0ll : h[l - 1][i]) * (r - l + 1 == 0 ? 1ll : p[r - l][i]) % mod[i] + mod[i]) % mod[i];
        }
        return ans;
    }
};

constexpr int HN = 2;
template<>
array<int, 2> StringHash<HN>::mod =
        {findPrime(rng() % 900000000 + 100000000),
         findPrime(rng() % 900000000 + 100000000)};
template<>
array<int, 2> StringHash<HN>::base {13331, 131};
using Hashing = StringHash<HN>;
string s[N] ,t[N]; 


void solve( ) {
	cin >> n >> m ;
	vector<Hashing> hs( n + 1 ) , ht( n + 1 ) ; 
	for(int i =1; i <= n ; ++ i ) cin >> s[i] , hs[i] = Hashing( s[i]) ;
	for(int i =1; i <=n ; ++ i ) cin >> t[i] , ht[i] = Hashing( t[i]);  
	
	vector<int>  p1( n + 1 ) , p2( n +1 ) ;
	for(int i =1;i <=n ; ++ i ) p1[i] = p2[i] = i ; 
	sort( p1.begin() + 1 ,p1.end() , [&](int x, int y ) { return s[x] < s[y] ; } ) ;
	sort( p2.begin() + 1 ,p2.end() , [&](int x, int y ) { return t[x] < t[y] ; } ) ;
	bool same = true ;
	for(int i =1;i <=n ; ++ i ) 
		if( s[ p1[i] ] != t[ p2[i]  ] )   
			same =false ;
	if( same ) {
		for(int i =1; i<=n ; ++ i ) cout << p1[i] <<" \n"[i == n ] ;
		for(int i =1; i<=n ; ++ i ) cout << p2[i] <<" \n"[i == n ] ;
		return ;
	} 
	
	
	auto check =[&]( int x )->bool{
		map< array<int,2> , int> sld , srd,  tld, trd  ;
		vector< array<int,3>> edge;
		int tot = 0 ;
		for(int i =1; i <=n ; ++ i ) {
			auto l = hs[i].query( 0 , x- 1) , r = hs[i].query( x , m  -1 ) ;
			if(  !sld[l] ) sld[l] = ++tot ;
			if(  !srd[r])   srd[r] = ++tot ;
			edge.push_back( { srd[r] , sld[l] , i }) ;
 		}
 		for(int i = 1 ; i <=n ; ++ i ) {
 			auto l = ht[i].query( 0 , m - 1 -  x ) , r = ht[i].query(  m - x  ,  m-1 ) ;
			if(  !tld[l] ) tld[l] = ++tot ;
			if(  !trd[r])   trd[r] = ++tot ;
			edge.push_back( { trd[r] , tld[l] , i + n }) ;
 		}
 		for(int i =1; i <=n ; ++ i ) {
 			auto l = hs[i].query( 0 , x- 1) ; 
 			if( trd[l]) {
 				edge.push_back( { sld[l] , trd[l] , inf }) ;
 			}
 		}
 		for(int i = 1 ; i <=n ; ++ i ) {
 			auto r = ht[i].query( 0  ,  m- x -1 ) ;
 			if( srd[r] ) {
 				edge.push_back( { tld[r] , srd[r] , inf }) ;
 			}
 		}
		vector<int> inv( tot + 1 , 0 ) ;
 		vector< vector<PII> > adj( tot + 1 ) ;
 		for(auto [u , v , _ ] : edge)  adj[u].push_back( { v , _ }) , inv[v] ++ ; 
 		
 		for(int i = 1 ; i <=tot ; ++ i ) {
 			if( inv[i] != adj[i].size() ) return false ;
  		}
 		vector<int> res ;
 		auto dfs =[&](auto self , int u )->void {
 			while( adj[u].size() ) {
 				auto  [ v  , id ] = adj[u].back() ; adj[u].pop_back( ) ;
 				self( self , v )  ;
 				res.push_back( id ) ;
 			}
 		} ;
		dfs( dfs , 1 ) ;
		if( res.size() != edge.size() ) return false ;
		vector<int> ans1 , ans2;
		for(auto ans : res ){
			if( ans == inf ) continue ;
			if( ans <=n ) ans1.push_back( ans ) ;
			else ans2.push_back( ans - n ) ;
		}
		for(auto ans : ans1) cout << ans <<" ";cout <<'\n';
		for(auto ans : ans2) cout << ans <<" ";cout <<'\n';
 		return true ;
		
	};
	
	for(int i = 1 ; i < m ; ++ i  ) {
		if( check( i )) return ;
	}
	cout << -1 <<'\n'; return ;
} 	
 
 
 
int main(){ 	
 
	ios::sync_with_stdio(false);
	cin.tie( 0 ) ;
	int T ; cin >> T ;
	while(T-- ){	
		solve() ;  
   	}        
 	return  0 ;
}

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

详细

Test #1:

score: 100
Accepted
time: 10ms
memory: 66212kb

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: 339ms
memory: 66088kb

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
1
1
1
1
-1
-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: 358ms
memory: 66120kb

input:

500000
1 2
dd
ba
1 2
cd
ba
1 2
bd
ba
1 2
ad
ba
1 2
dc
ba
1 2
cc
ba
1 2
bc
ba
1 2
ac
ba
1 2
db
ba
1 2
cb
ba
1 2
bb
ba
1 2
ab
ba
1 2
da
ba
1 2
ca
ba
1 2
ba
ba
1 2
aa
ba
1 2
dd
aa
1 2
cd
aa
1 2
bd
aa
1 2
ad
aa
1 2
dc
aa
1 2
cc
aa
1 2
bc
aa
1 2
ac
aa
1 2
db
aa
1 2
cb
aa
1 2
bb
aa
1 2
ab
aa
1 2
da
aa
1 2...

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

result:

ok 500000 cases (500000 test cases)

Test #4:

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

input:

500000
2 1
d
d
b
a
2 1
c
d
b
a
2 1
b
d
b
a
2 1
a
d
b
a
2 1
d
c
b
a
2 1
c
c
b
a
2 1
b
c
b
a
2 1
a
c
b
a
2 1
d
b
b
a
2 1
c
b
b
a
2 1
b
b
b
a
2 1
a
b
b
a
2 1
d
a
b
a
2 1
c
a
b
a
2 1
b
a
b
a
2 1
a
a
b
a
2 1
d
d
a
a
2 1
c
d
a
a
2 1
b
d
a
a
2 1
a
d
a
a
2 1
d
c
a
a
2 1
c
c
a
a
2 1
b
c
a
a
2 1
a
c
a
a
2 1
d...

output:

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

result:

ok 500000 cases (500000 test cases)

Test #5:

score: 0
Accepted
time: 343ms
memory: 66088kb

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

result:

ok 333333 cases (333333 test cases)

Test #6:

score: 0
Accepted
time: 213ms
memory: 66088kb

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

result:

ok 333333 cases (333333 test cases)

Test #7:

score: 0
Accepted
time: 326ms
memory: 66100kb

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

result:

ok 250000 cases (250000 test cases)

Test #8:

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

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
3 4 1 2
3 4 1 2
-1
-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: 331ms
memory: 66124kb

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: 186ms
memory: 66152kb

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: 302ms
memory: 66092kb

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
2 1
2 1
-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: 289ms
memory: 66348kb

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: 262ms
memory: 66352kb

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: 281ms
memory: 66320kb

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: 228ms
memory: 66104kb

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: 281ms
memory: 66096kb

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: 222ms
memory: 66156kb

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
aa
aa
5 2
nt
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
mt
jm
aa
aa
aa
aa
aa
aa
aa
aa
5 2
lt
jm
aa
aa
aa
aa...

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 #18:

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

input:

111111
3 3
oqa
bba
aaa
aaa
aaa
aaa
3 3
nqa
bba
aaa
aaa
aaa
aaa
3 3
mqa
bba
aaa
aaa
aaa
aaa
3 3
lqa
bba
aaa
aaa
aaa
aaa
3 3
kqa
bba
aaa
aaa
aaa
aaa
3 3
jqa
bba
aaa
aaa
aaa
aaa
3 3
iqa
bba
aaa
aaa
aaa
aaa
3 3
hqa
bba
aaa
aaa
aaa
aaa
3 3
gqa
bba
aaa
aaa
aaa
aaa
3 3
fqa
bba
aaa
aaa
aaa
aaa
3 3
eqa
bba
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 111111 cases (111111 test cases)

Test #19:

score: 0
Accepted
time: 242ms
memory: 66104kb

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: 235ms
memory: 66148kb

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: 242ms
memory: 66188kb

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: 204ms
memory: 66152kb

input:

66666
5 3
bqu
daa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
5 3
aqu
daa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
5 3
zpu
daa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
5 3
ypu
daa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
5 3
xpu
daa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
5 3
wpu
daa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
aaa
5 3
vpu
daa
aaa
aaa
aaa
aaa
aa...

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 #23:

score: 0
Accepted
time: 184ms
memory: 66196kb

input:

20833
6 8
gvebaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
6 8
fvebaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
6 8
evebaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
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 20833 cases (20833 test cases)

Test #24:

score: 0
Accepted
time: 172ms
memory: 66212kb

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: 157ms
memory: 66200kb

input:

10000
10 10
puoaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
10 10
ouoaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaa...

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 10000 cases (10000 test cases)

Test #26:

score: 0
Accepted
time: 277ms
memory: 66144kb

input:

250000
2 2
od
ah
ha
do
2 2
il
ng
il
ng
2 2
cf
pf
pf
cf
2 2
wx
ll
wx
ll
2 2
fg
ge
ge
fg
2 2
dg
mj
dg
mj
2 2
rj
vw
wr
jv
2 2
er
pv
pv
er
2 2
kc
lb
cl
bk
2 2
dh
zc
hz
cd
2 2
qv
ce
eq
vc
2 2
lz
um
zu
ml
2 2
hw
xx
hw
xx
2 2
uk
un
ku
nu
2 2
sg
kx
gs
xk
2 2
ib
xw
ib
xw
2 2
ar
pd
pd
ar
2 2
ij
si
ii
js
2 2
p...

output:

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

result:

ok 250000 cases (250000 test cases)

Test #27:

score: 0
Accepted
time: 273ms
memory: 66136kb

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

result:

ok 166666 cases (166666 test cases)

Test #28:

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

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
il
3 2
up
mr
ex
ru
xe
pm
3 2
pk
vn
pk
pk
vn
pk
3 2
ke
vj
cp
ke
cp
vj
3 2
aq
...

output:

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

result:

ok 166666 cases (166666 test cases)

Test #29:

score: 0
Accepted
time: 259ms
memory: 66392kb

input:

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

output:

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

result:

ok 125000 cases (125000 test cases)

Test #30:

score: 0
Accepted
time: 289ms
memory: 66312kb

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

result:

ok 100000 cases (100000 test cases)

Test #31:

score: 0
Accepted
time: 345ms
memory: 66136kb

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

result:

ok 28571 cases (28571 test cases)

Test #32:

score: 0
Accepted
time: 1462ms
memory: 100436kb

input:

1
1000 1000
plxpgukngtaywjrcxufvdwswaozxzeeduaeqslxuzcevplzosuqsedbplkmzbpyogbndbzmyfeyqamtetcjmaosbaxcrmjanjeglavxlwksvvenehzgrovffaebdtpynzajedywisavqgjjtjnqktzltyfzbvrtsfmdkzsyougzyqcckjcjjtkewysagddaizqnnptunmfyqagnxrzjqpsoqzqptzvjnfilpbgmjbetcgnewclwqxmftpepudwufcmbqtpyxajfmabqyvlgqxzhgumauzxms...

output:

-1

result:

ok 1 cases (1 test case)

Test #33:

score: 0
Accepted
time: 481ms
memory: 427316kb

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 7 22 20 33 60 25 47 30 6 41 44 35 23 3 2 31 10 55 19 9 13 53 40 46 17 21 4 37 5 18 93 12 38 132 27 147 15 62 59 11 48 61 151 52 8 95 156 43 81 68 175 16 92 49 57 69 107 193 39 29 91 102 84 111 88 146 34 199 90 201 50 152 65 114 36 211 159 58 109 26 51 67 196 54 171 254 63 106 24 112 56 228 245 108...

result:

ok 1 cases (1 test case)

Test #34:

score: 0
Accepted
time: 491ms
memory: 292580kb

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:

285614 933994 285576 146699 146698 644264 343998 817299 644234 285609 413047 817270 343972 29693 146657 644222 146654 146653 343971 817339 644189 644311 344030 146755 963578 485243 817218 817222 285527 817230 571177 387094 571237 485271 571185 413064 644304 285554 817255 817262 344007 644295 485371 ...

result:

ok 1 cases (1 test case)

Test #35:

score: 0
Accepted
time: 156ms
memory: 99116kb

input:

1
2 500000
yoskytdthibiosryionvxhjbnvwyrumjrmogzlngtxwkyxpketeperfdqboobxcccofgoxsjjffgdymvbhrnmcfiresutjbeadpbwuyxbirokynuisiezakhyivnbelkoexbfertmmmpjyerxyrnxvseyyipjqexidomwdzwqgqopwvnguawlvdyqgpsoxuliobzndxyfondeygqyxujboqcmqmwlptkpxflccjwfbzvwjkmddqxuenqirajuqplwjfyumjycekqzgavjrpanuxixmwlmnnvv...

output:

1 2 
2 1 

result:

ok 1 cases (1 test case)

Test #36:

score: 0
Accepted
time: 152ms
memory: 99228kb

input:

1
1 1000000
vvzoohphaekmooymvzpvxqaxbgyabgrgrdetsieivthqtvackeaapshmaybrwivlzjtjymeqmjqjoioeknzlajdqeptnywzscjthxqahapfnktonvxbyridjhokyielyfuzzgciiulnuetgfmdppmpywhoouwbbwyhlufupqwkhjubvkplfbzxiegngnewwfpupzypskuhtopvqzczthyaxpepvbkhvitkxgopxprykcrbjnuiideigftkhgzpykkoijuiquebxaaiwaabuxssgqgsofmiid...

output:

1 
1 

result:

ok 1 cases (1 test case)

Test #37:

score: 0
Accepted
time: 721ms
memory: 100848kb

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: 268ms
memory: 178988kb

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:

160679 128946 59840 114414 488661 167241 300782 10828 215815 362807 377392 417992 129006 260818 474764 314423 392651 392443 207632 224583 200245 53489 451484 194541 73567 220025 145207 59925 117489 175307 80753 362779 80775 407039 452942 313960 216456 247528 350113 4814 130152 452876 332719 265988 1...

result:

ok 1 cases (1 test case)

Test #39:

score: 0
Accepted
time: 462ms
memory: 292444kb

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:

73949 388221 229700 689402 388234 388246 919114 388252 823097 388254 689397 945670 33621 154154 503949 73944 33641 779940 627198 988046 627201 503931 503930 33606 388171 945682 33596 689457 388172 229727 823077 504005 73965 823090 779937 229718 503984 33609 988053 503978 689429 388212 863425 388218 ...

result:

ok 1 cases (1 test case)

Test #40:

score: 0
Accepted
time: 369ms
memory: 98920kb

input:

1
2 500000
csbazestpjffzjvrjztjidouhfewitwyhczwalacmlfmfpjozlnojeeltcyjkgbwpnzhzdeeublvjcgepkupvlqxhzkjfudcojhtxsrndyipgsuexhdjxodymiofmaxdkhsyallmorhqdrosgvzwvsgobotbwlwnqvohekjougktqmjaknocgtumjjvmtphfnoqrsrfgztpufvtnafmhmmcpxkrjyokgrlvaswhkkxfxguuakezavqkbkvnhjpycgvrsefranfttvrfnoaeempqhlsdzwtrvf...

output:

-1

result:

ok 1 cases (1 test case)

Test #41:

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

input:

1
1 1000000
zcgzehvspliuqlawrvemmxvlapmqsnpdieaqubpadgbsduckarfgikvmcphtdjtgczbfuivcjhpmwgaxoqvbmwldxvqwtcqizfyvxoahqcuyyvdgxzsohnkjblrwuyietchhqusxamzculyvhaqzoftboauhkdxnpxuxbljmftjtyrczfxxsbwkvzhehmwkhvbkjmnuypbjgibszsdtocihfzwuvdpvszccyroufgktzfytdkcrneuvelrcoufxvmxajvhlnikzfemppharjuwicizqodvrj...

output:

1 
1 

result:

ok 1 cases (1 test case)

Test #42:

score: 0
Accepted
time: 1469ms
memory: 100408kb

input:

1
1000 1000
vkrkwbibcsuczrgypnuclsmvexjomqttgzmpebzbtmtltqyekywmlpmluwwmjjybbnztlxthcphhfayjjegghgyuippcrweyyzgjfnzemamafgtexvhxofarelxdoptwfohqrnjepcpxzkoepuluocahihxhqipydaiermnrbxjpkeundrirpdcalvbjyhhdazarjuwepzaiafcmbaxqlfqcnbzvlamfwgpqoutqvwhilaqswbqzvohiayenlifowexxzvuxrldswlfpjugwozxwzpxeqtkb...

output:

-1

result:

ok 1 cases (1 test case)

Test #43:

score: 0
Accepted
time: 513ms
memory: 427780kb

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:

43 81 42 2 8 14 45 69 49 9 1 7 52 90 67 15 65 17 4 91 54 79 21 13 72 149 18 61 139 53 31 75 12 78 24 47 19 92 82 56 46 20 25 68 40 16 26 97 28 29 51 76 63 41 5 158 33 27 71 60 55 57 77 162 100 194 59 127 10 66 186 22 36 62 34 39 212 84 3 86 231 281 290 175 124 248 87 144 35 250 48 147 99 181 50 201 ...

result:

ok 1 cases (1 test case)

Test #44:

score: 0
Accepted
time: 498ms
memory: 292368kb

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:

955905 733493 40575 733499 247533 733517 733530 247497 733556 247486 247484 955907 733581 733483 733593 247444 247435 247434 733624 733630 733631 733638 40606 733653 733670 247756 733083 733109 733124 40526 247845 733150 733151 733179 733187 247774 733209 247767 247365 733230 247750 733319 733356 73...

result:

ok 1 cases (1 test case)

Test #45:

score: 0
Accepted
time: 2112ms
memory: 205548kb

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 13456 62898 1033 9820 16856 18332 25957 47082 15267 4211 17653 21651 14815 4350 30714 13088 9099 821 32516 1830 15656 43607 47688 5928 35979 3121 31834 6015 40891 19775 43395 10608 31372 10661 8036 20846 14738 16395 28335 10077 6492 13342 57700 2303 12828 3646 5971 988 36597 19044 2636 1485 26606 ...

result:

ok 1 cases (1 test case)

Test #46:

score: 0
Accepted
time: 313ms
memory: 185108kb

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:

91513 6918 68647 29551 18327 12605 96293 13271 82693 3453 88592 24577 14190 61970 30791 43047 14914 28406 22793 75924 20962 69295 82692 85733 70944 40602 40703 37840 44499 14446 21633 96291 44456 37641 46334 26028 35130 55074 44535 64985 31873 59358 82599 27628 18631 31293 66341 29646 70094 10665 35...

result:

ok 1 cases (1 test case)

Test #47:

score: 0
Accepted
time: 1472ms
memory: 179004kb

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: 71ms
memory: 113588kb

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:

95476 13713 27723 49989 86742 36665 38089 32084 98966 87221 70778 79915 96796 22962 55610 92946 20843 28257 68359 21314 67802 2435 54044 30659 50335 41496 13509 59596 42302 50697 26990 17595 94704 82029 8003 40541 36792 66790 28502 58918 91078 37209 85520 31870 44548 29600 30071 41853 16390 19108 90...

result:

ok 1 cases (1 test case)

Test #49:

score: 0
Accepted
time: 1458ms
memory: 178872kb

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: 367ms
memory: 98976kb

input:

1
2 500000
tossrwlzkdzzrphwvvnkmdevslssgacszrojwkxgorcupejhwfybmoyegfhulclkqadmdjpfccnbxhsumeffzhfowyhxqqpdrjguansbqlyuglodfwxjphusmwlevcmpjfcbrjbmdbsqovuljaxqfeorcmgjsbwxappqwsuacmjtyhjubdjyevglxpkektgumdrvtwkuzdiyznzactijqouerxfqatzcwjqserfliiqihufyinagdbqglcnqttlhkebmezdjcfvdcmcjgqhygbxmvzndqnywm...

output:

-1

result:

ok 1 cases (1 test case)

Test #51:

score: 0
Accepted
time: 334ms
memory: 99000kb

input:

1
1 1000000
aqfomtfebdjjikpwsgohpqhvbrasmasgmocifvxczotxorlguxtriaftafotynozikgxytfzuztzapeayssibygltogshsbfwlfcqzbfkleizodgzztxzaysqtsvokwictzyehplvlkpucyizyrcimlczpucivarsihznzqmkjyuhajkgasakdeechddnrezbboozngkyxrjkzfgdlzjewmzhfwmfzguwukeeaambyszysderzrbbbdraxbdpqrurmztoepgptyjtbnrwpyntoagemsfeari...

output:

-1

result:

ok 1 cases (1 test case)

Test #52:

score: 0
Accepted
time: 1500ms
memory: 208456kb

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: 2339ms
memory: 170920kb

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: 1843ms
memory: 206704kb

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 36276 95548 92482 43111 94100 84599 59275 1229 94494 45487 296 52758 89714 76468 70876 42716 21216 78833 86006 62781 89581 71866 10013 53697 63899 29475 70251 64351 9241 223 51912 12789 32151 8246 18116 23740 4637 88745 97765 62379 24012 31925 93724 18207 1146 31563 82564 9...

result:

ok 1 cases (1 test case)

Test #55:

score: 0
Accepted
time: 2395ms
memory: 171132kb

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: 1497ms
memory: 208524kb

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: 1827ms
memory: 205956kb

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 13480 79901 96121 48886 83346 72931 39021 29550 44527 65050 89685 55031 86010 96314 31257 87335 40499 56135 84775 70677 26313 42541 7639 64330 28609 81156 59712 31897 62019 48287 87683 56869 6572 47525 86255 67125 6696 74302 34665 16647 93457 79005 14468 61458 63584 51399 14621 85155 68315 97051 5...

result:

ok 1 cases (1 test case)

Test #58:

score: 0
Accepted
time: 2431ms
memory: 205324kb

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 97 24 41 11 64 7 4 22 18 19 27 6 46 5 120 34 21 3 20 32 36 8 33 14 25 94 55 10 15 48 31 121 59 50 139 53 73 12 47 9 54 23 75 100 2 107 144 80 49 28 56 17 70 37 45 113 207 74 65 89 30 43 116 152 174 78 93 85 167 26 95 103 104 39 105 42 115 61 96 106 265 135 69 88 76 319 118 58 132 52 87 148 159 51 ...

result:

ok 1 cases (1 test case)

Test #59:

score: 0
Accepted
time: 2379ms
memory: 170952kb

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: 2407ms
memory: 208396kb

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: 2440ms
memory: 207076kb

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 51 8 35 78 9 115 4 101 2 31 138 12 37 102 24 65 50 29 58 15 48 45 10 39 20 27 40 5 144 32 73 158 72 110 49 14 34 53 3 26 30 22 16 6 81 11 89 88 43 47 44 7 181 179 18 85 60 23 104 183 54 19 28 52 46 112 75 152 224 74 107 79 86 69 125 177 57 117 139 70 61 145 36 90 153 190 13 83 93 92 192 171 100 11...

result:

ok 1 cases (1 test case)

Test #62:

score: 0
Accepted
time: 1802ms
memory: 207324kb

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 76004 39925 63722 51489 76454 31946 76903 35534 79594 94566 91221 19389 73549 94553 67472 67305 20953 45393 20607 53855 39517 42332 47465 70323 41502 61665 75227 40509 32609 3847 23086 99204 48815 98691 4446 56771 94824 16326 19782 51385 7754 45604 95360 32273 94473 87051 73341 99873 9...

result:

ok 1 cases (1 test case)

Test #63:

score: 0
Accepted
time: 2356ms
memory: 170900kb

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