Bingo is played on a $5 \times 5$ grid, called a card. The five columns are labeled with the letters of the game's name: B, I, N, G, and O. Every square holds a number, and a player marks a square as soon as its number is drawn. A player wins a bingo the moment every square of some winning pattern on the card is marked.
The center square of the grid is a free space: it is already marked for every player from the start of the game.
The numbers drawn are the integers from $1$ to $75$. Each block of fifteen consecutive numbers belongs to one column:
You are told how many numbers have already been drawn in each column, together with the information that defines the winning patterns. In the most favorable case, determine the fewest additional numbers that still have to be drawn so that a bingo becomes possible.
The first line contains a single integer $n$, the number of data sets.
Each data set begins with a line of the form B I N G O X Y:
B, I, N, G, O — how many numbers have already been drawn in the corresponding column;X ($1 \le X \le 19$) — the number of input patterns;Y ($1 \le Y \le \min(5, X)$) — how many input patterns are combined to form a winning pattern.The next $5$ lines describe the $X$ input patterns, printed side by side as $5 \times 5$ grids. Inside a grid, X marks a square that must be covered and O marks a square that need not be covered.
A winning pattern is obtained by overlaying (taking the union of the marked squares of) any $Y$ of the input patterns. The full set of winning patterns is every such combination, and marking all squares of any one of them yields a bingo.
For example, with $X = 4$, $Y = 2$, and the input patterns
XXOOO OOOXX OOOOO OOOOO
XXOOO OOOXX OOOOO OOOOO
OOOOO OOOOO OOOOO OOOOO
OOOOO OOOOO XXOOO OOOXX
OOOOO OOOOO XXOOO OOOXX
the resulting winning patterns (marking any single one of them gives a bingo) are
XXOXX XXOOO XXOOO OOOXX OOOXX OOOOO
XXOXX XXOOO XXOOO OOOXX OOOXX OOOOO
OOOOO OOOOO OOOOO OOOOO OOOOO OOOOO
OOOOO XXOOO OOOXX XXOOO OOOXX XXOXX
OOOOO XXOOO OOOXX XXOOO OOOXX XXOXX
For each data set, print a single line containing the fewest additional numbers that still need to be drawn for a bingo to be possible.