N, M = map(int, input().split()) md = 1000000007 ncrs = [[0] * (max(N, M) + 10) for _ in range(N + M + 1)] ncrs[0][0] = 1 for i in range(1, len(ncrs)): ncrs[i][0] = 1 for j in range(1, len(ncrs[i])): ncrs[i][j] = ncrs[i - 1][j - 1] + ncrs[i - 1][j] if ncrs[i][j] >= md: ncrs[i][j] -= 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] = ncrs[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 += ncrs[N - 1][npos] * ncrs[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 += ncrs[N][nnonzero] * ncrs[nnonzero][npos] % md * coeff % md print(ret % md)