#include <bits/stdc++.h>
using namespace std;
vector<string> v;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
void dfs(int i, int j, int &cnt, vector<pair<int, int>> &temp,
         vector<vector<int>> &vis) {
  vis[i][j] = 1;
  temp.push_back(make_pair(i, j));
  for (int k = 0; k < 4; k++) {
    int x = i + dx[k];
    int y = j + dy[k];
    if (v[x][y] == '.' && !vis[x][y]) {
      dfs(x, y, cnt, temp, vis);
    } else if (v[x][y] == '*') {
      cnt++;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  v = vector<string>(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<vector<int>> vis(n, vector<int>(m, 0)), counted(n, vector<int>(m, 0)),
      ans(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] == '*') {
      } else if (v[i][j] == '.' && !vis[i][j]) {
        int cnt = 0;
        vector<pair<int, int>> temp;
        dfs(i, j, cnt, temp, vis);
        for (auto i : temp) {
          ans[i.first][i.second] = cnt;
        }
      }
    }
  }
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    cout << ans[x - 1][y - 1] << "\n";
  }
  return 0;
}
