#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans;
vector<pair<int, int> > vec;
bool v[1010][1010];
int res[1010][1010];
char G[1010][1010];
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
void DFS(int x, int y) {
  v[x][y] = true;
  vec.push_back(pair<int, int>(x, y));
  int px, py;
  for (int i = 0; i < (int)(4); i++) {
    px = x + dx[i], py = y + dy[i];
    if (G[px][py] == '*') ans++;
  }
  for (int i = 0; i < (int)(4); i++) {
    px = x + dx[i], py = y + dy[i];
    if (G[px][py] == '.' && !v[px][py]) DFS(px, py);
  }
}
int main() {
  int x, y;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < (int)(n); i++) scanf("%s", G[i]);
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++)
      if (G[i][j] == '.' && !v[i][j]) {
        vec.clear();
        ans = 0;
        DFS(i, j);
        for (int k = 0; k < (int)(vec.size()); k++)
          res[vec[k].first][vec[k].second] = ans;
      }
  while (k--) {
    scanf("%d%d", &x, &y);
    x--, y--;
    ans = 0;
    printf("%d\n", res[x][y]);
  }
}
