using
System;
public
class
GFG {
static
long
[, , ] dp;
static
int
mod = 1000000007;
static
long
FindPaths(
int
startRow,
int
startCol,
int
k,
int
m,
int
n)
{
if
(startRow >= m || startRow < 0 || startCol >= n
|| startCol < 0)
return
1;
if
(k == 0)
return
0;
if
(dp[startRow, startCol, k] != -1)
return
dp[startRow, startCol, k];
long
down = FindPaths(startRow + 1, startCol, k - 1,
m, n);
long
up = FindPaths(startRow - 1, startCol, k - 1,
m, n);
long
right = FindPaths(startRow, startCol + 1,
k - 1, m, n);
long
left = FindPaths(startRow, startCol - 1, k - 1,
m, n);
return
dp[startRow, startCol, k]
= (((down + up) % mod + right) % mod + left)
% mod;
}
public
static
void
Main()
{
int
m = 2, n = 2, k = 2, startRow = 0, startCol = 0;
dp =
new
long
[m, n, k + 1];
for
(
int
i = 0; i < m; i++) {
for
(
int
j = 0; j < n; j++) {
for
(
int
l = 0; l <= k; l++) {
dp[i, j, l] = -1;
}
}
}
Console.WriteLine(
FindPaths(startRow, startCol, k, m, n));
}
}