#include <bits/stdc++.h>
using namespace std;
long long dp[2010][2010];
const int mod = 1000000007;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= m; i++) dp[1][i] = 1;
  for (int i = 2; i <= n; i++) {
    long long s1 = 0, s2 = 0;
    for (int j = 2; j <= m; j++) {
      s1 = (s1 + dp[i - 1][j]) % mod;
      s2 = (s2 - dp[i - 1][j] * j) % mod;
      dp[i][j] = (s2 + s1 * (j + 1) + 1) % mod;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 2; j <= m; j++) {
      ans = (ans + dp[i][j] * dp[n - i + 1][j] % mod * (m - j + 1)) % mod;
      if (i < n)
        ans = (ans - dp[i][j] * dp[n - i][j] % mod * (m - j + 1)) % mod;
    }
  printf("%I64d\n", (ans + mod) % mod);
  return 0;
}
