#include <iostream>
#include <algorithm>

using namespace std;

const int N = 3000;
const int M = 100000007;

int C[N+1][N+1];

void init(){
  for(int i=0;i<N;i++){
    C[i][0] = C[i][i] = 1;
    for(int j=0;j<i;j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % M;
  }
}

int main(){
  int r, c, sy, sx, ty, tx, by, bx;
  init();
  int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
  int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
  cin >> r >> c >> sy >> sx >> ty >> tx;
  int ans = 0;
  by = bx = M;
  for(int i=0;i<9;i++){
    int ny = abs(ty + r * dy[i] - sy);
    int nx = abs(tx + c * dx[i] - sx);
    if(by + bx > ny + nx){
      by = ny; bx = nx;
      ans = C[by+bx][by];
    }else if(by + bx == ny + nx){
      ans = (ans + C[ny+nx][ny]) % M;
    }
  }
  cout << ans << endl;
}