#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6, pi = acos(-1);
const int N = 1e3 + 5, M = 1e6, OO = 0x3f3f3f3f;
int t, n, m, k;
char grid[N][N];
int cnt[N * N];
int ids[N][N];
bool valid(int r, int c) { return r < n && c < m && r >= 0 && c >= 0; }
int dfs(int r, int c, int id) {
  ids[r][c] = id;
  int ret = 0;
  for (int i = -1; i < 2; ++i) {
    for (int j = -1; j < 2; ++j) {
      if (abs(i) == abs(j)) continue;
      int ni = r + i;
      int nj = c + j;
      if (!valid(ni, nj)) continue;
      if (grid[ni][nj] == '.' && ids[ni][nj] == -1) {
        ret += dfs(ni, nj, id);
      }
      if (grid[ni][nj] == '*') {
        ++ret;
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 0; i < n; ++i) scanf("%s", grid[i]);
  int id = 0;
  memset(ids, -1, sizeof ids);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (grid[i][j] == '.' && ids[i][j] == -1) {
        cnt[id] = dfs(i, j, id);
        ++id;
      }
    }
  }
  while (t--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x, --y;
    printf("%d\n", cnt[ids[x][y]]);
  }
  return 0;
}
