#include <iostream>
using namespace std;
int Combination(int k, int n)
{
if (n/2 < k) k = n-k;
long long r = 1;
for (int i = 0; i < k; ++i)
r = r * (n-i) / (i+1);
return r;
}
int UniquePaths(int m, int n)
{
int dp[n][m];
for (int i = 0; i < n; ++i)
dp[i][m-1] = 1;
for (int j = 0; j < m; ++j)
dp[n-1][j] = 1;
for (int i = n-2; i >=0; --i)
for (int j = m-2; j >=0; --j)
dp[i][j] = dp[i+1][j] + dp[i][j+1];
return dp[0][0];
}
int main(int argc, char** argv)
{
int limit = 10;
for (int i = 2; i < limit; ++i)
{
for (int j = 2; j < limit; ++j)
{
printf("%d, %d : ", i, j);
cout << UniquePaths(j, i) << " ";
cout << Combination(i-1, (i+j-2)) << endl;
}
}
return 0;
}