#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int inf = 100000;
int w, h;
pair<int, int> ch(pair<int, int> a) {
	if (a.first == -1) {
		a.first = w - 1;
	}
	else if (a.first == w) {
		a.first = 0;
	}
	if (a.second == -1) {
		a.second = h - 1;
	}
	else if (a.second == h) {
		a.second = 0;
	}
	return a;
}
class point {
public:
	int fast, num;
	bool used;
	point() :fast(inf), num(0), used(false) {

	}
};
int main() {
	cin >> w >> h;
	vector<vector<point> > map(w, vector<point>(h));
	int mx[]{ 1,0,-1,0 }, my[]{ 0,1,0,-1 };
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	map[a][b].num = 1;
	map[a][b].fast = 0;
	queue<pair<int, int> >que;
	que.push(pair<int, int>(a, b));
	while (!que.empty()) {
		pair<int,int> du = que.front(); que.pop();
		pair<int, int> du2;
		for (int i = 0; i < 4; ++i) {
			du2 = ch(pair<int, int>(du.first + mx[i], du.second + my[i]));
			if (map[du2.first][du2.second].fast > map[du.first][du.second].fast) {
				map[du2.first][du2.second].num = (map[du2.first][du2.second].num + map[du.first][du.second].num) % 100000007;
				if (!map[du2.first][du2.second].used) {
					que.push(du2);
					map[du2.first][du2.second].fast = map[du.first][du.second].fast + 1;
					map[du2.first][du2.second].used = true;
				}
			}
		}
	}
	cout << map[c][d].num << endl;
	return 0;
}