#include <bits/stdc++.h>
using namespace std;
int movi[4] = {-1, 1, 0, 0};
int movj[4] = {0, 0, -1, 1};
int n, m, casos;
char v[2000][2000];
int visto[2000][2000];
int sol[2000][2000];
int cuenta(int i, int j) {
  if (visto[i][j]) return 0;
  if (v[i][j] == '*') return 1;
  visto[i][j] = 1;
  int c = 0;
  for (int k = 0; k < 4; k++) {
    int nexti = i + movi[k];
    int nextj = j + movj[k];
    c += cuenta(nexti, nextj);
  }
  return c;
}
void inserta(int i, int j, int c) {
  if (visto[i][j] == 2) return;
  if (v[i][j] == '*') return;
  visto[i][j] = 2;
  sol[i][j] = c;
  for (int k = 0; k < 4; k++) {
    int nexti = i + movi[k];
    int nextj = j + movj[k];
    inserta(nexti, nextj, c);
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &casos);
  for (int i = 1; i <= n; i++) scanf("%s", (v[i]) + 1);
  for (int i = 2; i < n; i++) {
    for (int j = 2; j < m; j++) {
      if (not visto[i][j]) {
        int c = cuenta(i, j);
        inserta(i, j, c);
      }
    }
  }
  for (int cas = 0; cas < casos; cas++) {
    int i, j;
    scanf("%d %d", &i, &j);
    printf("%d\n", sol[i][j]);
  }
}
