statement
/*
{
######################
# Author #
# Gary #
# 2021 #
######################
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
// int x=0;
// char ch=getchar();
// while(ch<'0'||ch>'9'){
// ch=getchar();
// }
// while(ch>='0'&&ch<='9'){
// x=(x<<1)+(x<<3)+(ch^48);
// ch=getchar();
// }
// return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
#define lb long double
const lb eps=1e-6;
const lb rot=1.2333333+0.6666+0.19260817;
struct vec{
lb x,y;
lb operator * (vec oth){
return x*oth.y-oth.x*y;
}
vec operator - (vec oth){
return vec{x-oth.x,y-oth.y};
}
bool operator < (vec oth){
return x<oth.x;
}
};
vec tran(vec v){
v.x+=1926.0817;
lb len=sqrt(v.x*v.x+v.y*v.y);
lb ang=atan(v.y/v.x);
ang+=rot;
v.x=len*cos(ang);
v.y=len*sin(ang);
return v;
}
int n;
vec a[20];
int tmpw[20][20],w[20][20];
int ord[18];
bool cmp(int A,int B){
return a[A]<a[B];
}
pair<int,LL> dp[19][1<<18];
short nex[18][1<<18];
short pre[18][1<<18];
bool have[18][18][18];
int under[1<<18];
int sta[19],sz=0;
int lg[1<<18];
lb area(int A,int B,int C){
return abs((a[A]-a[B])*(a[C]-a[B]));
}
bool cmp2(int A,int B){
return under[A]<under[B];
}
int st=0,ed=0;
void tran(pair<int,LL>& A,pair<int,LL> B){
if(A.FIR==B.FIR) A=II(A.FIR,A.SEC+B.SEC);
else
A=min(A,B);
}
void solve(){
rep(i,n)
rep(j,n)
rep(k,n){
if(i!=j&&j!=k&&k!=i){
have[i][j][k]=false;
rep(l,n){
if(l!=i&&l!=j&&l!=k){
if(abs(area(i,j,k)-(area(i,j,l)+area(j,k,l)+area(i,k,l)))<eps){
have[i][j][k]=true;
break;
}
}
}
}
}
st=ed=0;
sz=0;
rep(i,n){
while(sz>=2&&(a[sta[sz-1]]-a[sta[sz]])*(a[i]-a[sta[sz]])>eps) --sz;
sta[++sz]=i;
}
rb(i,1,sz)
st|=1<<sta[i];
sz=0;
rep(i,n){
while(sz>=2&&(a[sta[sz-1]]-a[sta[sz]])*(a[i]-a[sta[sz]])<-eps) --sz;
sta[++sz]=i;
}
rb(i,1,sz){
ed|=1<<sta[i];
}
dp[0][st]=II(0,1);
// cout<<st<<endl;
rep(i,n){
if((st>>i)&1)
if(nex[i][st]!=18){
dp[0][st].FIR+=w[i][nex[i][st]];
}
}
vector<int> st;
rep(i,1<<n){
if(!i) continue;
st.PB(i);
under[i]=0;
int hb=lg[i];
while(pre[hb][i]!=-1){
rb(j,pre[hb][i],hb-1){
lb tt=(a[hb]-a[j])*(a[pre[hb][i]]-a[j]);
if(abs(tt)>eps){
if(tt>0){
under[i]++;
}
else{
under[i]--;
}
}
}
hb=pre[hb][i];
}
}
sort(ALL(st),cmp2);
rep(mask_,st.size()){
// cout<<st[mask_]<<endl;
rep(i,n){
int mask=st[mask_];
if((mask>>i)&1&&dp[i][mask].SEC);
else continue;
// cout<<i<<' '<<mask<<' '<<dp[i][mask].FIR<<" "<<dp[i][mask].SEC<<' '<<' '<<nex[i][mask]<<' '<<endl;
tran(dp[nex[i][mask]][mask],dp[i][mask]);
if(nex[i][mask]!=18&&pre[i][mask]!=-1){
int A,B,C;
C=nex[i][mask];
A=pre[i][mask];
B=i;
int nmask=mask;
if((a[C]-a[B])*(a[A]-a[B])>-eps&&!have[A][B][C]){
nmask^=1<<B;
// cout<<A<<'*'<<nmask<<' '<<dp[A][nmask].FIR<<endl;
tran(dp[A][nmask],II(dp[i][mask].FIR+w[A][C],dp[i][mask].SEC));
// cout<<dp[A][nmask].FIR<<' '<<dp[A][nmask].SEC<<endl;
}
}
int nx=nex[i][mask];
if(nx!=18)
rb(ne,i+1,nx-1){
int nmask=mask;
nmask|=1<<ne;
if((a[nx]-a[i])*(a[ne]-a[i])>-eps&&!have[i][nx][ne]){
tran(dp[i][nmask],II(dp[i][mask].FIR+w[ne][i]+w[ne][nx],dp[i][mask].SEC));
// cout<<i<<"_"<<nmask<<endl;
// cout<<dp[i][nmask].FIR<<' '<<dp[i][nmask].SEC<<endl;
}
}
}
}
printf("%d %lld\n",dp[18][ed].FIR,dp[18][ed].SEC);
}
int main(){
int T;
scanf("%d",&T);
lg[1]=0;
rep(mask,1<<18){
if(mask>1) lg[mask]=lg[mask>>1]+1;
}
rep(i,18) rep(mask,1<<18)
{
if((mask>>i)&1){
nex[i][mask]=18;
for(int j=i+1;j<18;++j){
if((mask>>j)&1){
nex[i][mask]=j;
break;
}
}
pre[i][mask]=-1;
for(int j=i-1;j>=0;--j){
if((mask>>j)&1){
pre[i][mask]=j;
break;
}
}
}
}
while(T--){
scanf("%d",&n);
rep(i,19) rep(j,1<<n)
dp[i][j]=II(INF,0);
rep(i,n)
scanf("%Lf%Lf",&a[i].x,&a[i].y),a[i]=tran(a[i]);
rep(i,n) rep(j,n) scanf("%d",&tmpw[i][j]);
rep(i,n) ord[i]=i;
sort(ord,ord+n,cmp);
sort(a,a+n);
rep(i,n) rep(j,n) w[i][j]=tmpw[ord[i]][ord[j]];
solve();
}
return 0;
}
/*
1
10
344435 176940
478645 222445
335423 839587
959721 163732
516274 304845
909268 959870
470493 131794
154431 136423
712185 539668
212126 922512
0 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1 0
*/