#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll,ll> P;
typedef std::pair<ll,P> State;

const ll MOD = 100000007;

// 2 3 -> (1, -1, 1)
// 6 27 -> (3, -4, 1)
State extgcd(ll a, ll b){
    if(b == 0){
        return mp(a, mp(1, 0));
    }
    State s = extgcd(b, a%b);
    P p = s.second;
    return mp(s.first, mp(p.second, p.first-(a/b)*p.second));
}

// 3 7 -> 5
// 11 7 -> 2
ll mod_inverse(ll a, ll m){
    State s = extgcd(a, m);
    return (m + s.second.first % m) % m;
}

ll fact[2001];
P mod_fact(ll n, ll p){
    int e = 0, _n = n;
    while(_n > 0){
        e += _n / p;
        _n /= p;
    }

    if(n / p % 2 == 0){return mp(fact[n/p] * fact[n%p] % p, e);}
    return mp(fact[n/p] * (p - fact[n%p]) % p, e);
}

ll mod_combination(ll n, ll k, ll p){
    if(n < 0 || k < 0 || n < k){return 0;}
    P p1 = mod_fact(n, p), p2 = mod_fact(k, p), p3 = mod_fact(n-k, p);
    if(p1.second > p2.second + p3.second){return 0;}
    return p1.first * mod_inverse(p2.first * p3.first % p, p) % p;
}

int main(){
    fact[0] = 1;
    FOR(i, 1, 2001){
        fact[i] = (fact[i-1] * i) % MOD;
    }

    int r, c, a1, a2, b1, b2;
    std::cin >> r >> c >> a1 >> a2 >> b1 >> b2;

    if(a1 > b1){std::swap(a1, b1);}
    if(a2 > b2){std::swap(a2, b2);}

    int dx[2] = {b1-a1, a1+r-b1}, dy[2] = {b2-a2, a2+c-b2};
    
    int shortestPath = INF;
    
    REP(i, 2){
        REP(j, 2){
            shortestPath = std::min(shortestPath, dx[i]+dy[j]);
        }
    }

    ll res = 0;
    REP(i, 2){
        REP(j, 2){
            if(dx[i] + dy[j] == shortestPath){
                res = (res + mod_combination(dx[i]+dy[j], dx[i], MOD)) % MOD;
            }
        }
    }

    std::cout << res << std::endl;
}