#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
char str[maxn][maxn];
int n, m, q, k, indx, dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
map<int, int> id, sz;
bool used[maxn][maxn];
int dfs(int x, int y) {
  if (used[x][y]) return 0;
  used[x][y] = true;
  int lpos = x * m + y;
  id[lpos] = indx;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (!used[nx][ny] && nx >= 0 && ny >= 0 && nx < n && ny < m) {
      if (str[nx][ny] == '*')
        k++;
      else
        dfs(nx, ny);
    }
  }
  return 0;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  indx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (str[i][j] == '.' && !used[i][j]) {
        indx++;
        k = 0;
        dfs(i, j);
        sz[indx] = k;
      }
    }
  }
  int x, y;
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    indx = id[x * m + y];
    printf("%d\n", sz[indx]);
  }
  return 0;
}
