#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define PB push_back
#define SZ(v) ((int)(v).size())
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))

typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef long long ll;
typedef vector<ll> VLL;

typedef struct P { int x,y,xind,yind; } P;

int n;
vector<P> p;
VI x,y;
VI xcnt,ycnt;
VI leftxcnt,rightxcnt;
VI leftycnt,rightycnt;
VLL leftxsum,rightxsum;
VLL leftysum,rightysum;

#define assert(a)	


void run() {
	scanf("%d",&n);
	p.resize(n); REP(i,n) scanf("%d%d",&p[i].x,&p[i].y);
	VPII xx; REP(i,n) xx.PB(MP(p[i].x,i)); sort(xx.begin(),xx.end()); x.clear(); REP(i,n) { if(i==0||x.back()!=xx[i].first) x.PB(xx[i].first); p[xx[i].second].xind=SZ(x)-1; }
	VPII yy; REP(i,n) yy.PB(MP(p[i].y,i)); sort(yy.begin(),yy.end()); y.clear(); REP(i,n) { if(i==0||y.back()!=yy[i].first) y.PB(yy[i].first); p[yy[i].second].yind=SZ(y)-1; }
	xcnt=VI(SZ(x),0); REP(i,n) xcnt[p[i].xind]++; ycnt=VI(SZ(y),0); REP(i,n) ycnt[p[i].yind]++;
	leftxcnt=rightxcnt=VI(SZ(x),0); rightxcnt[0]=n-xcnt[0]; FORSZ(i,1,x) leftxcnt[i]=leftxcnt[i-1]+xcnt[i-1],rightxcnt[i]=n-leftxcnt[i]-xcnt[i];
	leftycnt=rightycnt=VI(SZ(y),0); rightycnt[0]=n-ycnt[0]; FORSZ(i,1,y) leftycnt[i]=leftycnt[i-1]+ycnt[i-1],rightycnt[i]=n-leftycnt[i]-ycnt[i];
	leftxsum=rightxsum=VLL(SZ(x),0); FORSZ(i,1,x) leftxsum[i]=leftxsum[i-1]+(long long)leftxcnt[i]*(x[i]-x[i-1]); for(int i=SZ(x)-2;i>=0;--i) rightxsum[i]=rightxsum[i+1]+(long long)rightxcnt[i]*(x[i+1]-x[i]);
	leftysum=rightysum=VLL(SZ(y),0); FORSZ(i,1,y) leftysum[i]=leftysum[i-1]+(long long)leftycnt[i]*(y[i]-y[i-1]); for(int i=SZ(y)-2;i>=0;--i) rightysum[i]=rightysum[i+1]+(long long)rightycnt[i]*(y[i+1]-y[i]);
//	REPSZ(i,x) printf("%d [%d,%d,%d] [%lld,%lld]\n",x[i],leftxcnt[i],xcnt[i],rightxcnt[i],leftxsum[i],rightxsum[i]); REP(i,n) printf("%d: %d => %d = %d\n",i,p[i].x,p[i].xind,x[p[i].xind]);
//	REPSZ(i,y) printf("%d [%d,%d,%d] [%lld,%lld]\n",y[i],leftycnt[i],ycnt[i],rightycnt[i],leftysum[i],rightysum[i]); REP(i,n) printf("%d: %d => %d = %d\n",i,p[i].y,p[i].yind,y[p[i].yind]);


	ll best=9223372036854775807LL,bestcnt=0;
	do {
		int i1=(n-1)/2,i2=n/2;
		int x1=p[xx[i1].second].xind,x2=p[xx[i2].second].xind,y1=p[yy[i1].second].yind,y2=p[yy[i2].second].yind;
		assert(leftxsum[x1]+rightxsum[x1]==leftxsum[x2]+rightxsum[x2]);
		assert(leftysum[y1]+rightysum[y1]==leftysum[y2]+rightysum[y2]);
		ll cur=leftxsum[x1]+rightxsum[x1]+leftysum[y1]+rightysum[y1];
		ll cnt=(long long)(x[x2]-x[x1]+1)*(y[y2]-y[y1]+1);
		REP(i,n) if(x[x1]<=p[i].x&&p[i].x<=x[x2]&&y[y1]<=p[i].y&&p[i].y<=y[y2]) --cnt;
		if(cnt==0) continue;
		if(cur>best) continue;
		if(cur<best) best=cur,bestcnt=0;
		bestcnt+=cnt;
	} while(0);
	
	if(bestcnt==0) {
		int DX[]={-1,0,+1,0},DY[]={0,-1,0,+1};
		set<PII> exists; REP(i,n) exists.insert(MP(p[i].x,p[i].y));
		REP(i,n) REP(k,4) {
			int nx=p[i].x+DX[k],ny=p[i].y+DY[k];
			ll xval=leftxsum[p[i].xind]+rightxsum[p[i].xind]; if(DX[k]!=0) xval+=xcnt[p[i].xind]-DX[k]*(rightxcnt[p[i].xind]-leftxcnt[p[i].xind]);
			ll yval=leftysum[p[i].yind]+rightysum[p[i].yind]; if(DY[k]!=0) yval+=ycnt[p[i].yind]-DY[k]*(rightycnt[p[i].yind]-leftycnt[p[i].yind]);
			ll cur=xval+yval;
			if(cur>best) continue;
			if(exists.count(MP(nx,ny))) continue; else exists.insert(MP(nx,ny));
			if(cur<best) best=cur,bestcnt=0;
//			printf("%d %d => %lld %lld [%d,%d] {%d,%d}\n",nx,ny,xval,yval,DX[k],DY[k],xcnt[p[i].xind]-DX[k]*(rightxcnt[p[i].xind]-leftxcnt[p[i].xind]),ycnt[p[i].yind]-DY[k]*(rightycnt[p[i].yind]-leftycnt[p[i].yind]));
			++bestcnt;
		}
	}
	printf("%lld %lld\n",best,bestcnt);
}

int main() {
	int n; scanf("%d",&n); FORE(i,1,n) run();
	return 0;
}
	
