Many electronic devices have digital read-outs that are made using light-emitting diode (LED) arrays. A common digital display element uses seven, bar-shaped LED's, with the seven LED bars (segments) arranged and identified as:
Digit Segments Illuminated (Y-Yes, N-No)
Displayed a b c d e f g
0 Y Y Y Y Y Y N
1 N Y Y N N N N
2 Y Y N Y Y N Y
3 Y Y Y Y N N Y
4 N Y Y N N Y Y
5 Y N Y Y N Y Y
6 Y N Y Y Y Y Y
7 Y Y Y N N N N
8 Y Y Y Y Y Y Y
9 Y Y Y Y N Y Y
The input consists of a series of data sets having the following format:
First line -
A single unsigned integer, N, with value greater than zero (0) and less than eleven (11). The integer is left-justified on the input line.
Next N lines -
Each line has a string of seven (7) contiguous Y/N characters showing the light condition of the segments of the LED display. These successive lines supposedly represent a ``count down" sequence. The first of these seven characters, the illumination reading for the ``a" segment, will be the first character on a line.
The end of data is signaled by a null data set having a zero on the first line and no further data.
There is no information about where the ``count down" sequence begins for a given data set. There is no information that carries over from one data set to the next; each data set represents a different LED being tested.
Foreach supposed ``count down" sequence you receive as a data set, you are to reply either:
MATCH
-or-
MISMATCH
depending on whether this sequence could possibly be a valid ``count down" sequence somewhere within the sequence { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } if an unknown number of burned-out segments were present at the beginning of the test, and, with possible burn-outs occurring during the test. Your output must be at the beginning of the line.
1 YYYYNYY 2 NNNNNNN NNNNNNN 2 YYYYYYY YYYYYYY 3 YNYYYYY YNYYNYY NYYNNYY 3 YNYYYYN YNYYNYN NYYNNYN 3 YNYYYYN YNYYNYN NYYNYYN 4 YYYYYYY NYYNNNN NNYYYYN NNNYNNN 3 NNNNNNN YNNNNNN NNNNYNN 0
MATCH MATCH MISMATCH MATCH MATCH MISMATCH MATCH MATCH