#include <bits/stdc++.h>
int DEBUG = 1;
int n;
using namespace std;
void Floyd(int tab[][11], int size) {
  for (int i = 0; i < size; i++)
    for (int j = 0; j < size; j++)
      for (int k = 0; k < size; k++) {
        if (tab[j][k] > tab[j][i] + tab[i][k]) {
          tab[j][k] = tab[j][i] + tab[i][k];
        }
      }
}
vector<vector<int>> AllSets(int e) {
  vector<vector<int>> ans;
  for (int i = 0; i < (1 << e); i++) {
    vector<int> a;
    for (int j = 0; j < (e + 1); j++) {
      if ((1 << j) & i) {
        a.push_back(j);
        cout << "     " << j << endl;
      }
    }
    if (a.size() > 0) ans.push_back(a);
  }
  return ans;
}
int main() {
  int n, m, k;
  int* ans_a = new int[250000];
  int ans_p = 1;
  std::cin >> n >> m >> k;
  char v[1051][1051];
  int vis[1051][1051];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      std::cin >> v[i + 1][j + 1];
      vis[i + 1][j + 1] = 0;
    }
  std::queue<std::pair<int, int>> q;
  for (int i = 0; i < 250000; i++) ans_a[i] = -1;
  int x, y;
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    std::cin >> x >> y;
    if (vis[x][y] != 0) {
      cout << ans_a[vis[x][y]] << std::endl;
    } else {
      q.push(make_pair(x, y));
      ans = 0;
      vis[x][y] = ans_p;
      while (!q.empty()) {
        auto tmp = q.front();
        q.pop();
        auto a = tmp.first;
        auto b = tmp.second;
        if (vis[a + 1][b] == 0 && v[a + 1][b] == '.')
          q.push(make_pair(a + 1, b)), vis[a + 1][b] = ans_p;
        else if (v[a + 1][b] == '*')
          ans++;
        if (vis[a - 1][b] == 0 && v[a - 1][b] == '.')
          q.push(make_pair(a - 1, b)), vis[a - 1][b] = ans_p;
        else if (v[a - 1][b] == '*')
          ans++;
        if (vis[a][b + 1] == 0 && v[a][b + 1] == '.')
          q.push(make_pair(a, b + 1)), vis[a][b + 1] = ans_p;
        else if (v[a][b + 1] == '*')
          ans++;
        if (vis[a][b - 1] == 0 && v[a][b - 1] == '.')
          q.push(make_pair(a, b - 1)), vis[a][b - 1] = ans_p;
        else if (v[a][b - 1] == '*')
          ans++;
      }
      ans_a[ans_p] = ans;
      ans_p++;
      std::cout << ans << std::endl;
    }
  }
}
