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

const int C = 100000007;

alias Tuple!(int, "y", int, "x") Pair;

void main() {
    int r, c, a1, a2, b1, b2; readf("%d %d %d %d %d %d\n", &r, &c, &a1, &a2, &b1, &b2);
    Pair[] ps;
    foreach (i; -1 .. 1 + 1) {
        foreach (j; -1 .. 1 + 1) {
            ps ~= Pair(b1 + i * r, b2 + j * c);
        }
    }
    int d = int.max;
    int count = 0;
    int y, x;
    foreach (i; 0 .. 9) {
        int _y = max(a1, ps[i].y) - min(a1, ps[i].y);
        int _x = max(a2, ps[i].x) - min(a2, ps[i].x);
        if (d == _y + _x) {
            count++;
        }
        else if (d > _y + _x) {
            y = _y;
            x = _x;
            d = y + x;
            count = 1;
        }
    }
    y++; x++;
    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);
}