cf/mirror

Hard problem

CF
706C1600· expert1s256 MB⌨ stdin/stdout

Examples

Sample 1of 4
Input
2
1 2
ba
ac
Output
1
Sample 2of 4
Input
3
1 3 1
aa
ba
ac
Output
1
Sample 3of 4
Input
2
5 5
bbb
aaa
Output
-1
Sample 4of 4
Input
2
3 3
aaa
aa
Output
-1
706C.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)