Burned Calendar
A year calendar is printed using the monospace font according to the following rules:
All spaces on the printed calendar are represented by the dot character (ASCII 46).
Every month occupies a rectangle of 17 by 8 characters, with the name of the month written in all capital letters starting from the 2^nd character of the first line.
All days of the months are printed in 4, 5, or 6 columns 2 characters wide and 7 characters high, with one space between the columns. The first day of the week is Monday.
a. Months of the year are arranged in the three rows separated by horizontal and vertical lines of spaces. Each row contains four months. The calendar margins are of 1 space from all sides. Therefore, the whole calendar has size of 73 by 28 characters.
Note that January 1^st, 1900 was Monday. Also note that a leap year number is divisible by 4 and not divisible by 100, or divisible by 400. For example, a part of the printed calendar from October to December 2002 may look like this:
A calendar was printed and then burned, with only a small rectangular piece left. Your program must determine to which of years from 1900 to 2100 this piece could belong.
Input
The first line of the input file contains integer numbers N and M (2 ≤ N, M ≤ 10), separated by spaces — the size of the piece. The following M lines contain N characters each — the piece of calendar.
Output
Output file must contain an ordered list of year numbers, one year per line. If given piece could not belong to any calendar, output must contain a single integer 0 (zero).