#P4537. Partitioning a Rectangular Grid

    ID: 17783 Type: Default 1000ms 256MiB

Partitioning a Rectangular Grid

Partitioning a Rectangular Grid

Given a rectangular grid of size \(a \times b\) made up of \(a \times b\) unit squares, you are required to partition the grid along the grid lines into two non-empty parts. Each part must be 4-connected (i.e. any two cells in the same part can reach each other via a path moving horizontally or vertically through adjacent cells) and each part must contain at least one cell on the boundary of the original rectangle. Two parts that are simply swapped are considered the same partition.

For example, a \(3 \times 2\) rectangle has 15 valid partitions.

Your task is to count the total number of valid partitions.

Note: The partition is done by drawing a cut along the grid lines such that the two resulting regions satisfy the connectivity and boundary conditions.

inputFormat

The input consists of a single line containing two integers \(a\) and \(b\) (\(1 \leq a, b \leq 6\)), representing the number of rows and columns of the grid respectively.

outputFormat

Output a single integer, the total number of valid partitions.

sample

1 1
0