#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 = 1050, MAXLOG = 12;
short a[2][MAXN][MAXN];
short pre[2][MAXN][MAXN][MAXLOG];
short pre_old[2][MAXN][MAXN][MAXLOG];
int N, M, Q, nextk;
void rmq_advance(int id) {
int k = nextk;
for (int i = 1; i <= N; ++i)
for (int j = 1; j <= M; ++j) {
if (k == 0)
pre[id][i][j][0] = a[id][i][j];
else {
pre[id][i][j][0] = pre_old[id][i][j][0];
int aux = i - (1 << (k - 1));
if (aux >= 1 && pre_old[id][aux][j][0] > pre[id][i][j][0])
pre[id][i][j][0] = pre_old[id][aux][j][0];
}
for (int l = 1; l < MAXLOG; ++l) {
pre[id][i][j][l] = pre[id][i][j][l - 1];
int aux = j - (1 << (l - 1));
if (aux >= 1 && pre[id][i][aux][l - 1] > pre[id][i][j][l])
pre[id][i][j][l] = pre[id][i][aux][l - 1];
}
}
memcpy(pre_old[id], pre[id], sizeof(pre[id]));
}
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 id, 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[id][ii][jj][Lj];
short cand = pre[id][i2][jj][Lj]; RELAX();
cand = pre[id][ii][j2][Lj]; RELAX();
cand = pre[id][i2][j2][Lj]; RELAX();
return (int)best;
}
void calc1(int dx, int dy, int &best, int &nr) {
for (int i1 = 1, i2 = i1 + dx - 1; i2 <= N; ++i1, ++i2)
for (int j1 = 1, j2 = j1 + dy - 1; j2 <= M; ++j1, ++j2) {
//printf("Considering (%d %d) (%d %d)", i1, j1, i2, j2);
int res0 = rmq(0, i1, j1, i2, j2), res1 = -rmq(1, i1, j1, i2, j2);
int res = res0 - res1;
//printf(" -- result %d : %d - %d\n", res, res0, res1);
if (res < best) {
best = res;
nr = 0;
}
if (res == best)
++nr;
}
}
typedef pair< pair<int, int>, int > query;
vector<query> queries;
pair<int, int> qres[25];
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[0][i][j]);
a[1][i][j] = -a[0][i][j];
}
else {
scanf("%hd", &a[0][j][i]);
a[1][j][i] = -a[0][j][i];
}
}
if (N > M)
swap(N, M);
for (int i = 0; i < Q; ++i) {
qres[i].first = INT_MAX, qres[i].second = 0;
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();
nextk = 0;
sort(queries.begin(), queries.end());
for (const auto &it : queries) {
for (; nextk <= LOG2(it.first.first - 1); ++nextk)
rmq_advance(0), rmq_advance(1);
calc1(it.first.first, it.first.second, qres[it.second].first, qres[it.second].second);
}
for (int i = 0; i < Q; ++i)
printf("%d %d\n", qres[i].first, qres[i].second);
return 0;
}