#include <bits/stdc++.h>
using namespace std;
int n, m, k, a, b, ii;
int ans;
char ch[1500][1500];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int dp[1500][1500];
int p[100007];
void dfs(int x, int y) {
  if (x > n || x < 1 || y > m || y < 1) return;
  if (ch[x][y] == '*') {
    ans++;
    return;
  }
  if (dp[x][y] != 0) return;
  dp[x][y] = ii;
  for (int i = 0; i < 4; i++) {
    int temp_x = x + dx[i];
    int temp_y = y + dy[i];
    dfs(temp_x, temp_y);
  }
  return;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> ch[i][j];
    }
  }
  for (ii = 1; ii <= k; ii++) {
    cin >> a >> b;
    ans = 0;
    if (!dp[a][b])
      dfs(a, b);
    else
      ans = p[dp[a][b]];
    p[ii] = ans;
    cout << ans << endl;
  }
  return 0;
}
