#include <bits/stdc++.h>
using namespace std;
char a[1001][1001];
int b[1001][1001];
bool check[1001][1001];
map<int, int> ans;
int n, m, k;
int cnt;
void dfs(int x, int y, int ptr) {
  check[x][y] = true;
  b[x][y] = ptr;
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      if (abs(i) + abs(j) != 1) {
        continue;
      }
      if (x + i < 0 || x + i >= n) {
        continue;
      }
      if (y + j < 0 || y + j >= m) {
        continue;
      }
      if (check[x + i][y + j]) {
        continue;
      }
      if (a[x + i][y + j] == '*') {
        cnt++;
        continue;
      }
      dfs(x + i, y + j, ptr);
    }
  }
}
int x, y;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      b[i][j] = -1;
    }
  }
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    x--;
    y--;
    if (b[x][y] == -1) {
      cnt = 0;
      dfs(x, y, i);
      ans[i] = cnt;
      cout << cnt << endl;
    } else {
      cout << ans[b[x][y]] << endl;
    }
  }
  return 0;
}
