import std.stdio;
import std.math;
import std.algorithm;
import std.functional;
import std.typecons;

const int C = 100000007;

alias Tuple!(int, "y", int, "x") P;
void main() {
    int r, c, a1, a2, b1, b2; readf("%d %d %d %d %d %d\n", &r, &c, &a1, &a2, &b1, &b2);
    auto ds = [
        abs(b1 - a1) + abs(b2 - a2), // (b1, b2)
        abs(r - b1 - a1) + abs(b2 - a2), // (b1 - r, b2)
        abs(b1 - a1) + abs(c - b2 - a2),// (b1, b2 - c)
        abs(r - b1 - a1) + abs(c - b2 - a2) //(b1 - r, b2 - c)
    ];
    int d = ds.reduce!min;
    int count = cast(int)ds.count(d);
    int y = abs(a1 - b1);
    y = min(y, r - y) + 1;
    int x = abs(a2 - b2);
    x = min(x, c - x) + 1;
    int[][] dp = new int[][y];
    foreach (ref _; dp) _ = new int[x];
    foreach (i; 0 .. y) dp[i][0] = 1;
    foreach (j; 0 .. x) dp[0][j] = 1;
    foreach (i; 1 .. y) {
        foreach (j; 1 .. x) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % C;
        }
    }
    writeln(dp[y - 1][x - 1] * count % C);
}