import java.util.*;
import static java.lang.System.*;
public class main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int cases = sc.nextInt();
for(int t = 0; t < cases; t++)
{
int m = sc.nextInt();
int n = sc.nextInt();
int q = sc.nextInt();
System.out.printf("%d %d %d\r\n", m, n, q);
char[][] datas = new char[m][n];
for(int i = 0; i < m; i++)
{
String str = sc.next();
for(int j = 0; j < n; j++)
datas[i][j] = str.charAt(j);
}
for(int k = 0; k < q; k++)
{
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int i;
for(i = 0; i < m; i++)
{
boolean flag = true;
for(int x = x1 - i; x <= x1 + i; x++)
{
for(int y = y1 - i; y <= y1 + i; y++)
{
if(x < 0 || y < 0 || x >= m || y >= n || datas[x][y] != datas[x1][y1])
{
flag = false;
break;
}
}
if(!flag)
break;
}
if(!flag)
break;
}
System.out.println(i * 2 - 1);
}
}
}
};
留言
張貼留言