/* O(N log N) time, O(N) space.

There is probably a simpler solution, but I couldn't think of one that I could
also prove to be correct.

Assessment: pretty hard!
    The basic idea is easy enough, but an efficient and correct implementation
    is hard, especially since there is lots of room for off-by-one errors and
    integer overflow.

The basic idea is that we want to minimize:
    dist(x,y) = sum( abs(X[n] - x) + abs(Y[n] - y)) for all n
We can rewrite this to:
    dist(x,y) = sum(abs(X[n] - x)) for all n +
                sum(abs(Y[n] - y)) for all n
              = dist(x) + dist(y)
And find the optimal x and y coordinates independently.

To determine the optimal coordinates, we simply sort the x coordinates and
the y coordinates independently, and pick the median points. (If there are
an even number of points, there are two median points which are both
optimal, and all points in between are as well.) (TODO: proof for this)

We have now found a rectangle (possibly of size 1) that contains all optimal
points. We have to distinguish between two cases:
 - at least one of the optimal points is free
 - all optimal points are taken and we must search for other points

We can determine the number of free optimal points by computing the area of the
rectangle of optimal points and then subtracting all points that lie in the
area of the optimal rectangle. If the result is non-zero, we can return
immediately. Otherwise, we have to find what we will call near-optimal points:
the points with the lowest summed distance of all points not covered by cows.

The candidates for near-optimal-points are the cells on the perimeter of the
occupied area covered by the optimal rectangle. We can find these points by
flood filling starting from an optimal point.
(TODO: proof other points cannot be near-optimal, since it will be possible to
       move toward the center until you do reach the perimeter)

Since the number of cows is at most 10,000, the number of points on the
perimeter is less than 40,000. For each point on the perimeter, we have to
calculate the summed distance. A naive implementation would simply sum the
distance for all N points, for an O(N*N) time complexity.

However, there is a more efficient way to find the sum of (for example) the
points on the left of a certain point. Suppose our points are sorted by X
coordinate, and we have precalculated (in linear time):
	S[0] = 0
	S[n] = S[n - 1] + n*(X[n] - X[n - 1])
or in other words: S[n] is the sum of the distances of all points to the left
of the nth point (considering the X axis only). If we want to find the sum for
points to the left of some coordinate "x", we can binary search for the last
point to the left of x, say "n", and compute the sum as: S[n] + n*(p + 1).

Now calculating the summed distance for a point is an O(log N) operation (even
though we have to do it four times: once for the points on the left, right,
top and bottom), yielding an O(N*log N) worst case solution.
*/

#include <algorithm>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
using namespace std;

int N, X[10000], Y[10000];
long long IXL[10000], IXR[10000], IYL[10000], IYR[10000];
long long inc, cnt;
set<pair<int, int> > taken, visited;

long long inconvenience(int x, int *X, long long *IXL, long long *IXR)
{
    int i = lower_bound(X, X + N, x) - X - 1,
        j = upper_bound(X, X + N, x) - X;
    return (i >= 0 ? IXL[i] + (long long)(i + 1)*(x - X[i]) : 0LL) +
           (j <  N ? IXR[j] + (long long)(N - j)*(X[j] - x) : 0LL);
}

long long inconvenience(int x, int y)
{
    return inconvenience(x, X, IXL, IXR) +
           inconvenience(y, Y, IYL, IYR);
}

void search(int x, int y)
{
    pair<int,int> p(x, y);
    if (visited.find(p) != visited.end())
        return;
    visited.insert(p);

    if (taken.find(p) != taken.end())
    {
        search(x + 1, y    );
        search(x    , y + 1);
        search(x - 1, y    );
        search(x    , y - 1);
    }
    else
    {
        long long i = inconvenience(x, y);
        if (i < inc)
            inc = i, cnt = 1;
        else
        if (i == inc)
            ++cnt;
    }
}

void calc(int *X, long long *IXL, long long *IXR)
{
    IXL[0] = 0;
    for (int n = 1; n < N; ++n)
        IXL[n] = IXL[n - 1] + n*(X[n] - X[n - 1]);

    IXR[N - 1] = 0;
    for (int n = N - 2; n >= 0; --n)
        IXR[n] = IXR[n + 1] + (N - n - 1)*(X[n + 1] - X[n]);
}

void run()
{
    taken.clear();
    visited.clear();
    for (int n = 0; n < N; ++n)
        taken.insert(make_pair(X[n], Y[n]));

    sort(X, X + N);
    sort(Y, Y + N);
    calc(X, IXL, IXR);
    calc(Y, IYL, IYR);

    int minx = X[(N - 1)/2], maxx = X[N/2],
        miny = Y[(N - 1)/2], maxy = Y[N/2];
    cnt = (long long)(maxx - minx + 1)*(maxy - miny + 1);
    for (set<pair<int, int> >::const_iterator i = taken.begin(); i != taken.end(); ++i)
        if (i->first >= minx && i->first <= maxx && i->second >= miny && i->second <= maxy)
            --cnt;
    if (cnt > 0)
    {
        // Easy case: some optimal spots are available
        inc = inconvenience(minx, miny);
    }
    else
    {
        // Hard case: search for best free spots
        inc = (long long)1e18;
        search(minx, miny);
    }
}

int main()
{
    int cases;
    cin >> cases;
    while (cases-- > 0)
    {
        cin >> N;
        for (int n = 0; n < N; ++n)
            cin >> X[n] >> Y[n];
        run();
        cout << inc << ' ' << cnt << '\n';
    }
}
