import itertools N, M = map(int, input().split()) class facmod: def __init__(self, N: int, md: int) -> None: assert N < md self.md = md self.facs = [1] * (N + 1) self.facinvs = [1] * (N + 1) for i in range(1, N + 1): self.facs[i] = self.facs[i - 1] * i % md self.facinvs[N] = pow(self.facs[i], md - 2, md) for i in range(N - 1, 0, -1): self.facinvs[i] = self.facinvs[i + 1] * (i + 1) % md def nCr(self, n: int, r: int) -> int: if n < 0 or r < 0 or n < r: return 0 return (self.facs[n] * self.facinvs[r]) % md * self.facinvs[n - r] % md md = 1000000007 fac = facmod(N + M, md) precalc = [[0] * (M + 1) for _ in range(N + 1)] precalc[0][0] = 1 for n in range(N + 1): for m in range(M + 1): if n + m - 1 >= 0: precalc[n][m] = fac.nCr(n + m - 1, n - 1) if m >= 2: precalc[n][m] += precalc[n][m - 2] if precalc[n][m] >= md: precalc[n][m] -= md ret = 0 if N % 2 == 0: half = (N - 1) // 2 for nnonzero in range(half * 2 + 1): coeff = 0 for npos in range(half + 1): if nnonzero - npos < 0 or nnonzero - npos > half: continue coeff += fac.nCr(N - 1, npos) * fac.nCr(N - 1 - npos, nnonzero - npos) coeff %= md tmp = 0 for b0 in range(M + 1): if M - nnonzero - b0 < 0: break tmp += precalc[nnonzero][M - nnonzero - b0] * (2 - (b0 == 0)) ret += tmp % md * coeff ret %= md else: for npos in range(N // 2 + 1): for nneg in range(N // 2 + 1): nnonzero = npos + nneg coeff = 0 if M - (npos + nneg) >= 0: coeff += precalc[nnonzero][M - nnonzero] m = M - npos - (N - nneg) if m >= 0: coeff += precalc[nnonzero][m] * 2 m = M - (N - nnonzero) - (npos if npos > nneg else nneg) * 2 if m >= 0: coeff += md - precalc[nnonzero][m] ret += fac.nCr(N, nnonzero) * fac.nCr(nnonzero, npos) % md * (coeff % md) ret %= md print(ret)