The first line is an integer T which indicates the case number.
And as for each case, first line is two integer N and M which indicates the size of maze.
Next N line, each line M character which indicates the maze.
Next seven line, each line is two integer A and H, which indicates the monsters ATK and HP
Next line is four integer As, Ds, Hs, Ms which indicates Warriors Gumball initial state
Next line is four integer Am, Dm, Hm, Mm which indicates information of magic
Next line is four integer Ab, Db, Hb, Mb which indicates information of buff
Limit
$1 \leq T \leq 20$
$1 \leq N, M \leq 100$
$1 \leq Ai, Hi \leq 20$
$1 \leq As, Ds, Hs, Ms \leq 100000$
$1 \leq Am, Dm, Hm, Mm \leq 100000$
$1 \leq Ab, Db, Hb, Mb \leq 100000$