1997-98 ACM North-Eastern European Regional Programming
Puncher is a device with several needles for making holes in tickets. At the factory there is a rectangular template with M rows and N columns (the diagram below shows M=3 and N=4) to make different punchers with 1, 2, ... , M*N needles. The rows and columns of needles are perpendicular to each other, and the distance between the rows is equal to the distance between the columns. It is possible to make 2M*N - 1 different punchers in this way, since a puncher with no needles is not a puncher at all.
Sometimes it is not possible to distinguish tickets that are perforated by different punchers. Let us assume that -- whenever a ticket is punched -- two opposite borders of the ticket are parallel to the rows of the needles, and the other pair of opposite borders are parallel to the columns of the needles. The number of the holes in a perforated ticket is always equal to the number of the needles in the corresponding puncher. When perforating a ticket, any composition of the following transformations is allowed:
The input file consists of lines of two positive integers M ( <=
4 ) and N ( <= 8 ), separated by a single space.
The output file consists of a single integer indicating the number of
1 1Output for the sample input