#include <bits/stdc++.h>
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
using namespace std;
string to_string(int a) {
  stringstream ss;
  ss << a;
  string s = ss.str();
  return s;
}
char mat[1005][1005];
int vis[1005][1005];
int ans[1005 * 1005];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int cnt = 0;
void dfs(int x, int y) {
  vis[x][y] = cnt;
  for (int k = 0; k < 4; k++) {
    if (vis[x + dy[k]][y + dx[k]]) continue;
    if (mat[x + dy[k]][y + dx[k]] == '*') ans[cnt]++;
    if (mat[x + dy[k]][y + dx[k]] == '.') dfs(x + dy[k], y + dx[k]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> mat[i][j];
  while (k--) {
    int a, b;
    cin >> a >> b;
    ++cnt;
    if (!vis[a][b]) dfs(a, b);
    cout << ans[vis[a][b]] << endl;
  }
  return 0;
}
