G. Pandemic
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
2
3 1
1 3
IHH
FFE
5 0
IHIHI
FEEEE
Output
2
0