#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
string a[1002];
long long visited[1002][1002];
long long an[1002][1002];
queue<pair<long long, long long> > q;
long long dfs(long long x, long long y) {
  visited[x][y] = 1;
  q.push(make_pair(x, y));
  long long ans = 0;
  for (long long i = 0; i < 4; i++) {
    long long p = x + dx[i];
    long long q = y + dy[i];
    if (a[p][q] == '.' && !visited[p][q])
      ans += dfs(p, q);
    else if (a[p][q] == '*')
      ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= k; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    if (an[x][y] != 0)
      cout << an[x][y] << endl;
    else {
      long long pp = dfs(x, y);
      cout << pp << endl;
      while (!q.empty()) {
        pair<long long, long long> tmp;
        tmp = q.front();
        q.pop();
        visited[tmp.first][tmp.second] = 0;
        an[tmp.first][tmp.second] = pp;
      }
    }
  }
}
