#include <iostream>
#include <queue>
#include <set>

using namespace std;
typedef pair<int, int> Point;
typedef pair<pair<Point, Point>, int> Node;
int main() {
	int x;
	int y;
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { 1, 0, -1, 0 };
	while (cin >> x >> y, x | y) {
		int sax;
		int say;
		int sbx;
		int sby;
		cin >> sax >> say >> sbx >> sby;
		sax--;
		say--;
		sbx--;
		sby--;
		int map[y][x];
		for (int i = 0; i < y; i++) {
			for (int j = 0; j < x; j++) {
				cin >> map[i][j];
			}
		}
		queue<Node> q;
		Point sa = make_pair(sax, say);
		Point sb = make_pair(sbx, sby);
		q.push(make_pair(make_pair(sa, sb), 0));
		set<pair<Point, Point> > visited;
		while (1) {
			if (q.empty()) {
				cout << "NA" << endl;
				break;
			}
			Node tmp = q.front();
			q.pop();
			pair<Point, Point> ps = tmp.first;
			int t = tmp.second;
			int size = visited.size();
			visited.insert(ps);
			if (size == visited.size()) {
				continue;
			}
			Point a = ps.first;
			Point b = ps.second;
			int ax = a.first;
			int ay = a.second;
			int bx = b.first;
			int by = b.second;
			if (t > 100) {
				cout << "NA" << endl;
				break;
			}
			if (ax == bx && ay == by) {
				cout << t << endl;
				break;
			}
			for (int i = 0; i < 4; i++) {
				int nax = ax + dx[i];
				int nay = ay + dy[i];
				int nbx = bx - dx[i];
				int nby = by - dy[i];
				if (nax < 0 || nay < 0 || nax >= x || nay >= y
						|| map[nay][nax]) {
					nax = ax;
					nay = ay;
				}
				if (nbx < 0 || nby < 0 || nbx >= x || nby >= y
						|| map[nby][nbx]) {
					nbx = bx;
					nby = by;
				}
				Point na = make_pair(nax, nay);
				Point nb = make_pair(nbx, nby);
				q.push(make_pair(make_pair(na, nb), t + 1));
			}
		}
	}
	return 0;
}