#define REP(a,b) for(int a=0; a<(b); ++a)
#define REP2(a,b) for(int a=1; a<=(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define BCK(a,b,c) for(int a=(b)-1; a>=(c); --a)
#define BCK2(a,b,c) for(int a=(b); a>(c); --a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define FILL(x,y) memset(x,y,sizeof(x))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define x first
#define y second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define l(n) (n<<1)
#define r(n) ((n<<1)+1)
#define f(n) (n>>1)
#define lsb(a) (a&-a)
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
#ifndef ONLINE_JUDGE
#include<fstream>
ifstream cin("plantatie.in");
ofstream cout("plantatie.out");
#else
#include<iostream>
#endif
const int NMAX = 505;
const int PMAX = 1015;
const int INF = 1 << 31;
const int dx[] = {0, 0, -1, 1}; //1,1,-1,1};
const int dy[] = {-1, 1, 0, 0}; //1,-1,1,-1};
typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef pair<K, K> PKK;
typedef vector<int> VI;
int n,m,q;
int Log[NMAX];
int t[10][505][505];
int main() {
FAST;
cin>>n>>m>>q;
REP2(i,n)
REP2(j,m)
cin>>t[0][i][j];
for(int i=2; i<=MAX(n,m); ++i)
Log[i] = Log[i/2]+1;
for(int p=1; (1<<p) < 2*MAX(n,m); ++p)
for(int i=1; i+(1<<p) <= 2*n; ++i)
for(int j=1; j+(1<<p) <= 2*m; ++j)
t[p][i][j]=
MAX(
MAX(
t[p-1][i][j],
t[p-1][i][j+(1<<(p-1))]
),
MAX(
t[p-1][i+(1<<(p-1))][j],
t[p-1][i+(1<<(p-1))][j+(1<<(p-1))]
)
);
REP(o,q)
{
int i,j,k;
cin>>i>>j>>k;
int p=Log[k];
cout<<p<<" ";
cout<<
MAX(
MAX(
t[p][i][j],
t[p][i][j+k-(1<<p)]
),
MAX(
t[p][i+k-(1<<p)][j],
t[p][i+k-(1<<p)][j+k-(1<<p)]
)
)<<"\n";
}
return 0;
}