#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
	int T;
	int n,xmax,ymax,xmin,ymin;
	int x,y,a,b,m,res;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&a,&b);
		scanf("%d%d",&x,&y);
		xmax=x;xmin=x;ymax=y;ymin=y;
		scanf("%d",&m);
		while(m--)
		{
			scanf("%d%d",&x,&y);
			if(x>xmax)
				xmax=x;
			if(y>ymax)
				ymax=y;
			if(x<xmin)
				xmin=x;
			if(y<ymin)
				ymin=y;
		res=2*(fabs(ymax-ymin)+fabs(xmax-xmin));
		}
		printf("The shortest path has length %d\n",res);
	}
	return 0;
}