#include <bits/stdc++.h>
using namespace std;
int const N = 1e3 + 5;
int cnt = 0, anss = 0;
char mat[N][N];
int ans[N * N], n, m, vis[N][N];
int di[] = {0, -1, 0, 1, -1, 1, -1, 1};
int dj[] = {-1, 0, 1, 0, 1, -1, -1, 1};
void dfs(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= m) return;
  if (vis[i][j]) return;
  if (mat[i][j] == '*') {
    anss++;
    return;
  }
  vis[i][j] = cnt;
  for (int x = 0; x < 4; x++) {
    dfs(i + di[x], j + dj[x]);
  }
}
void solv() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (vis[i][j] || mat[i][j] == '*') continue;
      anss = 0, cnt++;
      dfs(i, j);
      ans[cnt] = anss;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    cin >> mat[i];
  }
  solv();
  while (k--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << ans[vis[x][y]] << "\n";
  }
}
