using namespace std;
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <functional>
#define pb push_back
#define f first
#define s second
#define sz size
#define II inline
#define ll long long
#define db double
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define all(v) v.begin() , v.end()
#define C(v) C.erase( all(v) )
#define FORit(it,v) for(it = (v).begin();it != (v).end();++it)
#define mp make_pair
#define N_MAX 1<<10
#define L_MAX 1<<23
#define oo 1<<28
#define IN "struti.in"
#define OUT "struti.out"
int K(-1);
int best,nr;
short int N,M,P;
short int S1[N_MAX][N_MAX],S2[N_MAX][N_MAX],H[N_MAX][N_MAX];
char buffer[L_MAX];
II short int read()
{
short int aux(0);
for(;buffer[K] > '9' || buffer[K] < '0';++K);
for(;buffer[K] <= '9' && buffer[K] >= '0';++K)
aux = aux * 10 + buffer[K] - '0';
return aux;
}
II void scan()
{
freopen(IN,"r",stdin);
freopen(OUT,"w",stdout);
fread(buffer,1,1<<23,stdin);
fclose(stdin);
N = read();
M = read();
P = read();
FOR(i,1,N)
FOR(j,1,M)
H[i][j] = read();
}
II void rmq(int X,int Y)
{
short int V0[N_MAX],V[N_MAX],V1[N_MAX]={0},V2[N_MAX]={0};
int aux,j,sz1(1),sz2(1);
FOR(k,1,N)
{
V1[0] = V2[0] = V1[1] = V2[1] = sz1 = sz2 = 1;
memcpy(V,H[k],sizeof(H[k]));
FOR(i,2,M)
{
for(j=V1[0];j >= sz1 && V[i] >= V[ V1[j] ];--j);
V1[0] = j;
V1[ ++V1[0] ] = i;
for(j=V2[0];j >= sz2 && V[i] <= V[ V2[j] ];--j);
V2[0] = j;
V2[++V2[0]] = i;
if(i<=Y)
continue;
for(;i-V1[sz1] >= Y+1;++sz1);
for(;i-V2[sz2] >= Y+1;++sz2);
S1[k][i-Y] = V[ V1[sz1] ];
S2[k][i-Y] = V[ V2[sz2] ];
}
}
FOR(k,1,M-Y)
{
V1[0] = V2[0] = V1[1] = V2[1] = sz1 = sz2 = 1;
FOR(i,1,N)
V[i] = S1[i][k],
V0[i] = S2[i][k];
FOR(i,2,N)
{
for(j=V1[0];j >= sz1 && V[i] >= V[ V1[j] ];--j);
V1[0] = j;
V1[ ++V1[0] ] = i;
for(j=V2[0];j >= sz2 && V0[i] <= V0[ V2[j] ];--j);
V2[0] = j;
V2[++V2[0]] = i;
if(i<=X)
continue;
for(;i-V1[sz1] >= X+1;++sz1);
for(;i-V2[sz2] >= X+1;++sz2);
aux = V[ V1[sz1] ] - V0[ V2[sz2] ];
if(aux == best)
++nr;
else
if(aux < best)
best = aux,
nr = 1;
}
}
}
II void solve()
{
int X,Y;
best = oo,nr = 0;
X = read();
Y = read();
--X,--Y;
rmq(X,Y);
if(X==Y)
{
printf("%d %d\n",best,nr);
return;
}
rmq(Y,X);
printf("%d %d\n",best,nr);
}
int main()
{
scan();
for(++P;--P;solve());
//printf("Your Program run for %d ms\n",clock() );
return 0;
}