#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int H,W;
int sx,sy,gx,gy;

const int mod=100000007;
const int MAX_FACT=10000;

ll fact[MAX_FACT];

ll pow_mod(ll a,ll n){
  ll cur=1;
  ll mul=a;
  while(n){
    if(n%2)cur=(cur*mul)%mod;
    mul=(mul*mul)%mod;
    n/=2;
  }
  return cur;
}

ll div_mod(int a){
  return pow_mod(a,mod-2);
}
// factを前計算
void calcFact(){
  fact[0]=1;
  for(int i=1;i<MAX_FACT;i++)
    fact[i]=(fact[i-1]*i)%mod;
}
// aCbのmodを計算
// 計算量はO(log(fact[a])+log(fact[a-b]))程度
ll comb(ll a,ll b){
  if(a<0||b<0)return 0;
  else if(b==0)return 1;
  ll res=fact[a];
  res=(res*div_mod(fact[b]))%mod;
  res=(res*div_mod(fact[a-b]))%mod;
  return res;
}

int main(){
  calcFact();
  cin>>H>>W>>sy>>sx>>gy>>gx;
  vector<pii> cand;
  ll res=0;
  cand.push_back(pii(gy,gx));
  // left
  cand.push_back(pii(gy,-(W-gx)));
  // right
  cand.push_back(pii(gy,W+gx));
  // up
  cand.push_back(pii(-(H-gy),gx));
  // down
  cand.push_back(pii(H+gy,gx));
  // left up
  cand.push_back(pii(-(H-gy),-(W-gx)));
  // right up
  cand.push_back(pii(-(H-gy),W+gx));
  // left down
  cand.push_back(pii(H+gy,-(W-gx)));
  // right down
  cand.push_back(pii(H+gy,W+gx));
  int minDist=1<<30;
  for(int i=0;i<9;i++)
    minDist=min(minDist,abs(sy-cand[i].first)
                +abs(sx-cand[i].second));
  for(int i=0;i<9;i++){
    int a=abs(sy-cand[i].first);
    int b=abs(sx-cand[i].second);
    if(minDist==(a+b))
      res=(res+comb(a+b,a))%mod;
  }
  cout<<res<<endl;
  
  return 0;
}