#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
char graph[1350][1350];
int visited[1350][1350];
int pos[1000005];
int sol;
int addx[4] = {-1, 0, 0, 1};
int addy[4] = {0, -1, 1, 0};
int n, m, k;
void dfs(int x, int y, int i) {
  if (x == 0 || y == 0 || x == n + 1 || y == m + 1) return;
  if (graph[x][y] == '*') {
    sol++;
    return;
  }
  if (visited[x][y]) return;
  visited[x][y] = i;
  for (int j = 0; j < 4; j++) dfs(x + addx[j], y + addy[j], i);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> graph[i][j];
    }
  }
  for (int i = 1; i <= k; i++) {
    int x, y;
    cin >> x >> y;
    sol = 0;
    if (!visited[x][y])
      dfs(x, y, i);
    else
      sol = pos[visited[x][y]];
    pos[i] = sol;
    cout << sol << "\n";
  }
  return 0;
}
