#include <bits/stdc++.h>
using namespace std;
char matrix[1001][1001];
bool mark[1001][1001];
int check[1001][1001];
int cc[200000];
int n, m, k;
int movx[] = {1, -1, 0, 0};
int movy[] = {0, 0, 1, -1};
int DFS(int x, int y, int cont) {
  mark[x][y] = true;
  check[x][y] = cont;
  int cuantos = 0;
  for (int i = 0; i < 4; ++i) {
    int aux = x + movx[i];
    int auy = y + movy[i];
    if (mark[aux][auy]) continue;
    if (matrix[aux][auy] == '*')
      cuantos++;
    else {
      cuantos += DFS(aux, auy, cont);
    }
  }
  return cuantos;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    cin >> matrix[i];
  }
  memset(check, 0, sizeof(check));
  int cont = 0;
  while (k--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (!mark[x][y]) {
      cc[cont] = DFS(x, y, cont);
      cont++;
    }
    cout << cc[check[x][y]] << endl;
  }
  return 0;
}
