A full one-year calendar is printed in a monospace font according to the following rules:
. (ASCII 46).January 1, 1900 was a Monday. A year is a leap year when it is divisible by 4 and not by 100, or when it is divisible by 400. For example, part of the printed calendar from October to December 2002 may look like this:
.OCTOBER...........NOVEMBER..........DECEMBER.........
....7.14.21.28........4.11.18.25........2..9.16.23.30.
.1..8.15.22.29........5.12.19.26........3.10.17.24.31.
.2..9.16.23.30........6.13.20.27........4.11.18.25....
.3.10.17.24.31........7.14.21.28........5.12.19.26....
.4.11.18.25........1..8.15.22.29........6.13.20.27....
.5.12.19.26........2..9.16.23.30........7.14.21.28....
.6.13.20.27........3.10.17.24........1..8.15.22.29....
......................................................
One such printed calendar was burned, and only a small rectangular piece survived. Determine every year from 1900 to 2100 whose calendar this piece could have come from.
The first line contains two integers N and M (2≤N,M≤10) separated by a space — the width N and the number of lines M of the piece. Each of the next M lines contains exactly N characters: the surviving piece of the calendar (blanks shown as dots).
Print, in increasing order, every year (one per line) whose printed calendar could contain the given piece. If no year's calendar could contain it, print a single 0.