#include <bits/stdc++.h>
using namespace std;
char a[1111][1111];
int was[1111][1111];
int qAns[111111];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dfs(int vx, int vy, int q) {
  was[vx][vy] = q;
  int res = 0;
  for (int i = 0; i < 4; i++) {
    int x = vx + dx[i];
    int y = vy + dy[i];
    if (a[x][y] == '*') {
      res++;
    } else if (was[x][y] == 0) {
      res += dfs(x, y, q);
    }
  }
  return res;
}
int main() {
  int n, m, k;
  scanf("%d %d %d\n", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
  }
  for (int i = 1; i <= k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    if (was[x][y] != 0) {
      cout << qAns[was[x][y]] << "\n";
      continue;
    }
    cout << (qAns[i] = dfs(x, y, i)) << "\n";
  }
  return 0;
}
