#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 7;
const int INF = 1e9;
int s, k, n, m, x, y, p, q, c, d, a, b;
char ar[MAX][MAX];
int ans[MAX][MAX];
int ret[MAX][MAX];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool vis[MAX][MAX];
int dfs(int x, int y, int cnt) {
  vis[x][y] = true;
  for (int k = 0; k < 4; ++k) {
    int p = x + dx[k];
    int q = y + dy[k];
    if (ar[p][q] == '.' && vis[p][q] == false &&
        (p > 0 && q > 0 && p <= n && q <= m))
      cnt += dfs(p, q, 0);
  }
  return cnt + ans[x][y];
}
void DFS(int x, int y, int cnt) {
  ret[x][y] = cnt;
  vis[x][y] = false;
  for (int k = 0; k < 4; ++k) {
    int p = x + dx[k];
    int q = y + dy[k];
    if (ar[p][q] == '.' && vis[p][q] == true &&
        (p > 0 && q > 0 && p <= n && q <= m))
      DFS(p, q, cnt);
  }
  return;
}
int MAIN() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> ar[i][j];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (ar[i][j] == '*')
        for (int k = 0; k < 4; ++k) {
          int p = i + dx[k];
          int q = j + dy[k];
          if (ar[p][q] == '.' && (p > 0 && q > 0 && p <= n && q <= m))
            ans[p][q]++;
        }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (ar[i][j] == '.' && ret[i][j] == 0) {
        int an = dfs(i, j, 0);
        DFS(i, j, an);
      }
    }
  while (k--) {
    cin >> a >> b;
    cout << ret[a][b] << endl;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  return MAIN();
}
