Bingo is a game in which players try to form patterns on a 5 x 5
Given the amount of numbers for each letter already called and information
used to determine the set of winning patterns, write a program to determine the
fewest amount of numbers that still need to be called for a possible bingo.
Input to this problem will begin with a line containing a single integer
n
The next 5 lines in each data set will be a series of 5 x 5
the set of winning patterns (of which only one must be marked to have a
bingo) is:
For each data set, output a single line containing the fewest amount of
numbers that still need to be called to form a bingo.
Input
X
19
Y
minimum(5, X)
For example, given an X
XXOOO OOOXX OOOOO OOOOO
XXOOO OOOXX OOOOO OOOOO
OOOOO OOOOO OOOOO OOOOO
OOOOO OOOOO XXOOO OOOXX
OOOOO OOOOO XXOOO OOOXX
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
Output
Sample
Input
3
0 1 0 2 1 4 2
XXOOO OOOXX OOOOO OOOOO
XXOOO OOOXX OOOOO OOOOO
OOOOO OOOOO OOOOO OOOOO
OOOOO OOOOO XXOOO OOOXX
OOOOO OOOOO XXOOO OOOXX
1 1 0 1 1 5 1
XXXXX OOOOO OOOOO OOOOO OOOOO
OOOOO XXXXX OOOOO OOOOO OOOOO
OOOOO OOOOO XXXXX OOOOO OOOOO
OOOOO OOOOO OOOOO XXXXX OOOOO
OOOOO OOOOO OOOOO OOOOO XXXXX
15 15 15 15 4 1 1
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
Sample
Output
4
0
1