Greg has a pad. The pad's screen is an n × m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right.

Greg thinks that the pad's screen displays a cave if the following conditions hold:

  * There is a segment [l, r] (1 ≤ l ≤ r ≤ n), such that each of the rows l, l + 1, ..., r has exactly two black cells and all other rows have only white cells. 
  * There is a row number t (l ≤ t ≤ r), such that for all pairs of rows with numbers i and j (l ≤ i ≤ j ≤ t) the set of columns between the black cells in row i (with the columns where is these black cells) is the subset of the set of columns between the black cells in row j (with the columns where is these black cells). Similarly, for all pairs of rows with numbers i and j (t ≤ i ≤ j ≤ r) the set of columns between the black cells in row j (with the columns where is these black cells) is the subset of the set of columns between the black cells in row i (with the columns where is these black cells). 



Greg wondered, how many ways there are to paint a cave on his pad. Two ways can be considered distinct if there is a cell that has distinct colors on the two pictures.

Help Greg.

Input

The first line contains two integers n, m — the pad's screen size (1 ≤ n, m ≤ 2000).

Output

In the single line print the remainder after dividing the answer to the problem by 1000000007 (109 + 7).

Examples

Input

1 1


Output

0


Input

4 4


Output

485


Input

3 5


Output

451
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD_EgorAndCaves solver = new TaskD_EgorAndCaves();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD_EgorAndCaves {
    public static final int MOD = (int)1e9 + 7;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();

        if (m < 2) {
            out.println(0);
            return;
        }
        long[][] dp = new long[n+1][m+1];
        long[][] lastRow = new long[n+1][m+1];

        for (int width = 2; width <= m; ++width) {
            dp[0][width] = 1;
        }
        long[] sum = new long[m+1];
        long[] sum2 = new long[m+1];
        for (int row = 1; row < n; ++row) {
            sum[0] = sum[1] = 0;
            sum2[0] = sum2[1] = 0;
            for (int i = 2; i <= m; ++i) {
                sum[i] = sum[i-1] + dp[row-1][i];
                if (sum[i] >= MOD) sum[i] -= MOD;
                sum2[i] = sum2[i-1] + (dp[row-1][i] * i) % MOD;
                if (sum2[i] >= MOD) sum2[i] -= MOD;
            }
            for (int width = 2; width <= m; ++width) {
                dp[row][width] = 1;
                lastRow[row][width] = 0;
                dp[row][width] += ((width + 1) * sum[width]) % MOD;
                if (dp[row][width] >= MOD) {
                    dp[row][width] -= MOD;
                }
                dp[row][width] -= sum2[width];
                if (dp[row][width] < 0) {
                    dp[row][width] += MOD;
                }
                lastRow[row][width] += ((width + 1) * sum[width-1]) % MOD;
                if (lastRow[row][width] >= MOD) {
                    lastRow[row][width] -= MOD;
                }
                lastRow[row][width] -= sum2[width-1];
                if (lastRow[row][width] < 0) {
                    lastRow[row][width] += MOD;
                }
            }
        }

        long res = 0;
        for (int t = 0; t < n; ++t) {
            for (int width = 2; width <= m; ++width) {
                res += ((dp[t][width]) % MOD) * (m - width + 1) % MOD;
                if (res >= MOD) {
                    res -= MOD;
                }
                res += ((dp[t][width] * lastRow[n - t - 1][width]) % MOD) * (m - width + 1) % MOD;
                if (res >= MOD) {
                    res -= MOD;
                }
            }
        }
        out.println(res);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

