#include <bits/stdc++.h>
using namespace std;
char cells[1001][1001] = {0};
int scope[1001][1001] = {0};
int processNum[100001] = {0};
int ans[100001] = {0};
int pictFound = 0;
int nCells, mCells, startingPoint, rowPos, colPos, maxPict, i;
void visit(int rowPos, int colPos) {
  if (rowPos == 0 || colPos == 0 || rowPos == nCells + 1 ||
      colPos == mCells + 1)
    return;
  if (cells[rowPos][colPos] == '*') {
    maxPict++;
    return;
  }
  if (scope[rowPos][colPos] != 0) return;
  scope[rowPos][colPos] = i;
  visit(rowPos + 1, colPos);
  visit(rowPos, colPos + 1);
  visit(rowPos - 1, colPos);
  visit(rowPos, colPos - 1);
  return;
}
int main() {
  cin >> nCells >> mCells >> startingPoint;
  for (int i = 1; i <= nCells; i++) {
    for (int j = 1; j <= mCells; j++) {
      cin >> cells[i][j];
    }
  }
  for (i = 1; i <= startingPoint; i++) {
    cin >> rowPos >> colPos;
    pictFound++;
    maxPict = 0;
    if (!scope[rowPos][colPos])
      visit(rowPos, colPos);
    else
      maxPict = processNum[scope[rowPos][colPos]];
    processNum[i] = maxPict;
    cout << maxPict << endl;
  }
  return 0;
}
