#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt")
using namespace std;
#define int long long
#define double long double
#define codetiger_orz cin.tie(0);cin.sync_with_stdio(0);
signed main() {
codetiger_orz
int r, c;
cin >> r >> c;
const int mod = 1000000007;
vector<vector<int>> dp(r + 1, vector<int>(c + 1, 1));
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
dp[i][j] = dp[i - 1][j] + 4 * j * dp[i - 1][j - 1];
if (i != 1){
dp[i][j] += (i - 1) * j * dp[i - 2][j - 1];
}
if (j != 1){
dp[i][j] += j * (j - 1) / 2 * dp[i - 1][j - 2];
}
dp[i][j] %= mod;
}
}
cout << (dp[r][c] + mod - 1) % mod << "\n";
}
/*
____ ___ ___ ____ _____ ____ ____ ___
| | | | \ | | /| | | | \
| | | | | |____ | | | _ |____ |___/
| | | | | | | | | | | | \
|____ |___| |___/ |____ | __|__ |____| |____ | \
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |