#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <cstring>
#include <cstdlib>
using namespace std;
//看博友分析 经典dfs
int G[30][30];
int vis[30];
int n;
bool check()
{
for(int i=0;i<n;i++)
{
if(vis[i]<1)
{
return false;
}
}
return true;
}
int jg;
int js;
void dfs(int u)
{
//cout<<u<<" "<<js<<endl;
vis[u]++;//位置
if(check() && vis[0]==2)
{
//cout<<"hi "<<js<<endl;
if(jg==-1 || jg>js)
{
jg=js;
}
vis[u]--;//需要
return;
}
for(int i=0;i<n;i++)
{
if(i!=u && (vis[i]==0 || (check() && i==0 && vis[0]==1)))
{
js=js+G[i][u];
//cout<<"to "<<u<<" "<<i<<endl;
dfs(i);
js=js-G[i][u];
}
}
vis[u]--;
}
int main()
{
int T;
cin>>T;
for(int o=0;o<T;o++)
{
memset(G,-1,sizeof(G));
vector<pair<int,int> > ve;
int tx,ty;
cin>>tx>>ty;
cin>>tx>>ty;
ve.push_back(make_pair(tx,ty));
cin>>n;
for(int i=0;i<n;i++)
{
cin>>tx>>ty;
ve.push_back(make_pair(tx,ty));
}
n++;
for(int i=0;i<ve.size();i++)
{
for(int j=i+1;j<ve.size();j++)
{
G[i][j]=G[j][i]=abs(ve[i].first-ve[j].first)+abs(ve[i].second-ve[j].second);
}
}
jg=-1;
js=0;
//cout<<endl;//
dfs(0);
cout<<"The shortest path has length "<<jg<<endl;
}
return 0;
}