Key Insight

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description

 

Input

 

Output

 

Sample Input

4 
treewood 
ertedowo 
1 
nwerc 
ncrew 
6 
secret 
etrcse 
1 
impossibru 
youdontsay 

Sample Output

1
0
2
0

Hint

 

Source