#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; const int di[] = {1, 0, -1, 0}; const int dj[] = {0, 1, 0, -1}; } int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; sx--, sy--, gx--, gy--; bool visited[6][6]{}; int ans = 0; auto dfs = [&](auto&& self, int x, int y) -> void { if (x == gx && y == gy) { ans++; return; } visited[x][y] = true; rep(k1, 4) { int nx = x + di[k1], ny = y + dj[k1]; if (0 <= nx && nx < h && 0 <= ny && ny < w && !visited[nx][ny]) { // neighbor check bool ok = true; rep(k2, 4) if ((k1 ^ 2) != k2) { int nx2 = nx + di[k2], ny2 = ny + dj[k2]; if (0 <= nx2 && nx2 < h && 0 <= ny2 && ny2 < w && visited[nx2][ny2]) { ok = false; break; } } if (ok) self(self, nx, ny); } } visited[x][y] = false; }; dfs(dfs, sx, sy); cout << ans << '\n'; }