Welcome to ZOJ
Select Problem
ZOJ Problem Set - 2253
Fill the Grid

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Given an m*n grid, you're required to fill it with the numbers from 1 to m*n but the following rules should be satisfied:

1. each number in grid is larger than its above;
2. each number in grid is larger than its left.

Now, I wonder how many distinct solutions I could make on a grid.

For example. Consider such a 2*3 grid, we have the following solutions:

		123  124  134  135  125
		456  356  256  246  346

Thus, the sum is 5.


Two positive integer m, n (0 < m, n < 10) per line. Two zeros indicate the end of input.


A single integer per line for each case -- the number of distinct solutions.

Sample Input

2 3
0 0

Sample Output


Author: HE, Tao
Source: ZOJ Monthly, November 2004
Submit    Status