#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 2010, mod = 1e9 + 7;
int n, m;
int dp[N][N], sum[N][N], Sum[N][N];
inline void init() {
  n = read(), m = read();
  for (register int i = (0); i <= (m - 2); i++)
    dp[1][i] = 1, sum[1][i] = sum[1][i - 1] + 1, Sum[1][i] = Sum[1][i - 1] + i;
  for (register int i = (2); i <= (n); i++)
    for (register int j = (0); j <= (m - 2); j++) {
      dp[i][j] =
          (1ll * sum[i - 1][j] * (j + 1) % mod - Sum[i - 1][j] + mod) % mod;
      sum[i][j] = (sum[i][j - 1] + dp[i][j]) % mod,
      Sum[i][j] = (Sum[i][j - 1] + 1ll * dp[i][j] * j % mod) % mod;
    }
}
int ans, Ans[N][N];
inline void calc() {
  for (register int i = (1); i <= (n); i++)
    for (register int j = (0); j <= (m - 2); j++)
      Ans[i][j] = (Ans[i - 1][j] + dp[i][j]) % mod;
  for (register int i = (1); i <= (n); i++)
    for (register int j = (0); j <= (m - 2); j++)
      ans =
          (ans + 1ll * Ans[i][j] * (m - j - 1) % mod * dp[n - i + 1][j] % mod) %
          mod;
  printf("%d\n", ans);
}
int main() { init(), calc(); }
