#include <bits/stdc++.h>
using namespace std;
char str[1005][1005];
int answer[1500000], vis[1005][1005], n, m, par[1005][1005];
int X[] = {1, -1, 0, 0};
int Y[] = {0, 0, 1, -1};
int total, val;
void dfs(int x, int y) {
  par[x][y] = val;
  vis[x][y] = 1;
  int i;
  for (i = 0; i < 4; i++) {
    int _x = x + X[i], _y = y + Y[i];
    if (_x < 0 || _x >= n || _y < 0 || _y >= m) continue;
    if (str[_x][_y] == '*') {
      total++;
      continue;
    }
    if (vis[_x][_y]) continue;
    dfs(_x, _y);
  }
}
int main() {
  int t;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &t);
  getchar();
  int i;
  for (i = 0; i < n; i++) gets(str[i]);
  memset(vis, 0, sizeof(vis));
  int j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (str[i][j] == '*' || vis[i][j]) continue;
      total = 0;
      val = i * m + j;
      dfs(i, j);
      answer[val] = total;
    }
  }
  for (i = 0; i < t; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    x--;
    y--;
    printf("%d\n", answer[par[x][y]]);
  }
  return 0;
}
