#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dirx[] = {-1, 0, 1, 0};
int diry[] = {0, 1, 0, -1};
const int M = 1010;
char map[M][M];
int vis[M][M], ans[M*M];
int n, m, num, id;
void dfs(int x, int y)
{
vis[x][y] = id;
for(int i = 0; i < 4; ++i)
{
int dx = x+dirx[i];
int dy = y+diry[i];
if(dx > 0 && dx <= n && dx > 0 && dy <= m && !vis[dx][dy])
{
if(map[dx][dy] == '*') num++;
else dfs(dx, dy);
}
}
}
int main()
{
int t;
scanf("%d%d%d", &n,&m,&t);
int i, j, k;
for(i = 1; i <= n; ++i) scanf("%s", map[i]+1);
id = 0;
memset(vis, 0, sizeof(vis));
for(i = 1; i <= n; ++i)
{
for(j = 1; j <= m; ++j)
{
if(map[i][j] == '.' && !vis[i][j])
{
num = 0, ++id, dfs(i, j), ans[id] = num;
}
}
}
while(t--)
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", ans[vis[a][b]]);
}
return 0;
}