#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& x) {
    clog << x << " ";
    return *this;
  }
} dbg;
auto ____ = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();
int cnt_paint(int i, int j, const vector<string>& B) {
  int ans = 0;
  if (B[i - 1][j] == '*') ++ans;
  if (B[i + 1][j] == '*') ++ans;
  if (B[i][j - 1] == '*') ++ans;
  if (B[i][j + 1] == '*') ++ans;
  return ans;
}
int try_visit(int x, int y, queue<pair<int, int> >& Q, vector<vector<int> >& C,
              const int c, const vector<string>& B) {
  int ans = 0;
  if (B[x][y] == '.' and C[x][y] == -1) {
    ans = cnt_paint(x, y, B);
    C[x][y] = c;
    Q.push(make_pair(x, y));
  }
  return ans;
}
int main(int argc, char* argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> B(n);
  for (int i = 0; i < (n); ++i) cin >> B[i];
  vector<vector<int> > C(n, vector<int>(m, -1));
  unordered_map<int, int> c2paint;
  int color = 0;
  for (int i = 1; i < (n - 1); ++i) {
    for (int j = 1; j < (m - 1); ++j) {
      if (B[i][j] == '.' and C[i][j] == -1) {
        ;
        C[i][j] = color;
        int cnt = cnt_paint(i, j, B);
        queue<pair<int, int> > Q;
        Q.push(make_pair(i, j));
        while (!Q.empty()) {
          auto p = Q.front();
          Q.pop();
          int x = p.first, y = p.second;
          cnt += try_visit(x - 1, y, Q, C, color, B);
          cnt += try_visit(x + 1, y, Q, C, color, B);
          cnt += try_visit(x, y - 1, Q, C, color, B);
          cnt += try_visit(x, y + 1, Q, C, color, B);
        };
        c2paint[color] = cnt;
        color++;
      }
    }
  }
  int x, y;
  while (k--) {
    cin >> x >> y;
    --x, --y;
    cout << c2paint[C[x][y]] << '\n';
  }
  return 0;
}
