#include <bits/stdc++.h>
using namespace std;
int k[1005][1005], is[1005][1005];
int main() {
  int a, b, x, y, x1, y1;
  cin >> a >> b >> x >> y >> x1 >> y1;
  for (int i = 0; i < a; i++)
    for (int j = 0; j < b; j++) cin >> k[i][j];
  for (int i = 0; i < a; i++)
    for (int j = 0; j < b; j++) is[i][j] = INT_MAX;
  queue<pair<int, int> > q;
  is[x][y] = 0;
  return 0;
}
