#include <bits/stdc++.h>
using namespace std;
bool vis[1000][1000];
bool lab[1000][1000];
vector<int> ans;
int comp[1000][1000];
int cur_ans;
int cur_comp = 0;
int dfs(int x, int y) {
  if (!lab[x][y]) {
    ++cur_ans;
    return 0;
  }
  if (!vis[x][y]) {
    comp[x][y] = cur_comp;
    vis[x][y] = true;
    dfs(x + 1, y);
    dfs(x, y + 1);
    dfs(x - 1, y);
    dfs(x, y - 1);
  }
  return 0;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char c;
      cin >> c;
      if (c == '*') {
        lab[i][j] = false;
      } else {
        lab[i][j] = true;
      }
    }
  }
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    if (!vis[x][y]) {
      cur_ans = 0;
      dfs(x, y);
      cur_comp++;
      ans.push_back(cur_ans);
      cout << cur_ans << endl;
    } else {
      cout << ans[comp[x][y]] << endl;
    }
  }
  return 0;
}
