#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <climits>
#include <queue>
using namespace std;
typedef long long LL;
#ifdef INFOARENA
#define ProblemName "struti"
#endif
#define MCONCAT(A, B) A B
#ifdef ProblemName
#define InFile MCONCAT(ProblemName, ".in")
#define OuFile MCONCAT(ProblemName, ".out")
#else
#define InFile "fis.in"
#define OuFile "fis.out"
#endif
const int MAXN = 1010, MAXLOG = 11;
short a[MAXN][MAXN];
short pre[MAXN][MAXN][MAXLOG];
short pre_old[MAXN][MAXN][MAXLOG];
int N, M, Q, nextk; int id_global;
void rmq_advance() {
int k = nextk;
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= M; ++j) {
if (k == 0)
pre[i][j][0] = a[i][j];
else {
pre[i][j][0] = pre_old[i][j][0];
int aux = i - (1 << (k - 1));
if (aux >= 1 && pre_old[aux][j][0] > pre[i][j][0])
pre[i][j][0] = pre_old[aux][j][0];
}
for (int l = 1; l < MAXLOG; ++l) {
pre[i][j][l] = pre[i][j][l - 1];
int aux = j - (1 << (l - 1));
if (aux >= 1 && pre[i][aux][l - 1] > pre[i][j][l])
pre[i][j][l] = pre[i][aux][l - 1];
}
}
memcpy(pre_old, pre, sizeof(pre));
}
int logtable[MAXN];
void precomputeLogs() {
int cur = 0;
for (int i = 1; i < MAXN; ++i) {
if ((1 << (cur + 1)) <= i)
++cur;
logtable[i] = cur;
}
}
inline int LOG2(int x) {
return logtable[x];
}
#define RELAX() if(cand > best) best = cand;
int rmq(int i1, int j1, int i2, int j2) {
int Li = LOG2(i2 - i1), Lj = LOG2(j2 - j1);
int ii = i1 + (1 << Li) - 1, jj = j1 + (1 << Lj) - 1;
short best = pre[ii][jj][Lj];
short cand = pre[i2][jj][Lj]; RELAX();
cand = pre[ii][j2][Lj]; RELAX();
cand = pre[i2][j2][Lj]; RELAX();
return (int)best;
}
vector<int> tmpres[25][2];
void calc1(int dx, int dy, int qid) {
for (int i1 = 1, i2 = i1 + dx - 1; i2 <= N; ++i1, ++i2)
for (int j1 = 1, j2 = j1 + dy - 1; j2 <= M; ++j1, ++j2)
tmpres[qid][id_global].push_back(rmq(i1, j1, i2, j2));
}
typedef pair< pair<int, int>, int > query;
vector<query> queries;
void solveOnce() {
nextk = 0;
for (const auto &it : queries) {
for (; nextk <= LOG2(it.first.first - 1); ++nextk)
rmq_advance();
calc1(it.first.first, it.first.second, it.second);
}
++id_global;
}
void input() {
scanf("%d%d%d", &N, &M, &Q);
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= M; ++j) {
if (N <= M)
scanf("%hd", &a[i][j]);
else
scanf("%hd", &a[j][i]);
}
if (N > M)
swap(N, M);
for (int i = 0; i < Q; ++i) {
int dx, dy;
scanf("%d%d", &dx, &dy);
queries.push_back(make_pair(make_pair(dx, dy), i));
if (dx != dy)
queries.push_back(make_pair(make_pair(dy, dx), i));
}
}
int main() {
assert(freopen(InFile, "r", stdin));
assert(freopen(OuFile, "w", stdout));
precomputeLogs();
input();
sort(queries.begin(), queries.end());
solveOnce();
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= M; ++j)
a[i][j] = -a[i][j];
solveOnce();
for (int i = 0; i < Q; ++i) {
int best = INT_MAX, cnt = 0;
int ress = tmpres[i][0].size();
for (int j = 0; j != ress; ++j) {
int cand = tmpres[i][0][j] + tmpres[i][1][j];
if (cand < best) {
best = cand;
cnt = 0;
}
if (cand == best)
++cnt;
}
printf("%d %d\n", best, cnt);
}
return 0;
}