#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <fstream>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int MOD = 1000000007;
int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin>>n>>m;
	vector<vector<int> > dp(n+2, vector<int>(m+2, 0));
	for (int i=0; i<=n; ++i)dp[i][0]=dp[i][1]=1;
	for (int i=0; i<=m; ++i)dp[0][i]=dp[1][i]=1;
	for (int i=2; i<=n+1; ++i)for (int j=2; j<=m+1; ++j)dp[i][j]=(dp[i-1][j]+4*(j-1)*dp[i-1][j-1]+((i-2)*(j-1)*dp[i-2][j-1])+((j-1)*(j-2)*dp[i-1][j-2]/2))%MOD;
	cout<<dp[n+1][m+1];
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |