//NWERC-2007-H

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

#define VI vector<int>
#define int64 long long
#define VVI vector <vector<int> >

#define SZ(a) a.size()
#define MP make_pair
#define PII pair<int, int>
#define PB push_back
#define ALL(a) a.begin(), a.end()
#define CLA(a) memset(a, 0, sizeof(a))
#define FOR(i,n) for (int i = 0; i < int(n); i++)
#define FORR(i,n) for (int i = n - 1; i >=0; i--)
#define REP(n) for (int _foo = n - 1; _foo >= 0; _foo--)

#define INF 1000000000

int ri() {int t; scanf("%d", &t); return t;}
void rs(char *s) {scanf("%s", s);}
void pi(int n){printf("%d\n", n);}

int n, res, m, d, k, x00, y00, ynn, xnn;

int a[1024][1024];

const int dx4[] = {-1, 0, 1, 0};
const int dy4[] = {0, 1, 0 , -1};

PII q[1024*1024]; int qh, qt;

void ffill(int x, int y)
{
	//queue <PII > q;
	//q.push(MP(x, y)); 
	qh = qt = 0;
	q[qh++] = MP(x, y);
	a[x][y] = 0;
	while (qh != qt)
	{
		PII t = q[qt++];
		x = t.first, y = t.second;
		int d = a[x][y] + 1;
		FOR(k,4)
		{
			int xx = x + dx4[k];
			int yy = y + dy4[k];
			if (xx < 0 || xx >= n || yy < 0 || yy >= m) continue;
			if (a[xx][yy] > d)
			{
				a[xx][yy] = d;
				//q.push(MP(xx, yy));
				q[qh++] = MP(xx, yy);

			}
		}
	}
}

int v[1024][1024];

int can(int d)
{
	CLA(v);
	int x = x00, y = y00;
	if (a[x][y] < d) return -1;
	qh = qt = 0;
	q[qh++] = MP(x, y); 
	v[x][y] = 1;
	while (qh != qt)
	{
		PII t = q[qt++];//q.front(); q.pop();
		x = t.first, y = t.second;
		int dd = v[x][y] + 1;
		if (x == xnn && y == ynn)
		{
			return v[x][y] - 1;
		}
		FOR(k,4)
		{
			int xx = x + dx4[k];
			int yy = y + dy4[k];
			if (xx < 0 || xx >= n || yy < 0 || yy >= m) continue;
			if (a[xx][yy] >= d && !v[xx][yy])
			{
				v[xx][yy] = dd;
				q[qh++] = MP(xx, yy);
			}
		}
	}
	return -1;
}

void solve()
{
	int l = 0, r = max(n, m), m;
	while (r - l > 1)
	{
		m = (l + r) / 2;
		if (can(m) > 0)
			l = m;
		else
			r = m - 1;
	}
	if ((res = can(l + 1)) >= 0) d = l + 1;
	else if ((res = can(l)) >= 0) d = l;
	else if ((res = can(l-1)) >= 0) d = l-1;
}	

int main()
{
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif

	REP(ri())
	{
		k = ri();
		n = ri();
		m = ri();
		x00 = ri();
		y00 = ri();
		xnn = ri();
		ynn = ri();
		FOR(i,n) FOR(j,m)a[i][j] = INF;
		REP(k)
		{
			int x = ri();
			int y = ri();
			ffill(x, y);
		}
		solve();
		printf("%d %d\n", d, res);
	}

}
