#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
int Vist[1010][1010], R[1010 * 1010];
char Map[1010][1010];
int n, m, k;
PII iDirection[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int ans, id;
void MyDFS(PII head) {
  Vist[head.first][head.second] = id;
  for (int cnt = 0; cnt < 4; cnt++) {
    PII tmp;
    tmp.first = head.first + iDirection[cnt].first;
    tmp.second = head.second + iDirection[cnt].second;
    if (tmp.first > 0 && tmp.first <= n && tmp.second > 0 && tmp.second <= m &&
        !Vist[tmp.first][tmp.second]) {
      if (Map[tmp.first][tmp.second] == '*')
        ans++;
      else
        MyDFS(tmp);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int line = 1; line <= n; line++) {
    scanf("%s", Map[line] + 1);
  }
  memset(Vist, 0, sizeof Vist);
  id = 0;
  for (int line = 1; line <= n; line++) {
    for (int row = 1; row <= m; row++) {
      if (Map[line][row] == '.' && !Vist[line][row]) {
        PII tmp;
        tmp.first = line;
        tmp.second = row;
        ans = 0;
        id++;
        MyDFS(tmp);
        R[id] = ans;
      }
    }
  }
  while (k--) {
    PII tmp;
    scanf("%d%d", &tmp.first, &tmp.second);
    printf("%d\n", R[Vist[tmp.first][tmp.second]]);
  }
  return 0;
}
