#include <bits/stdc++.h>
using namespace std;
int n, m, vis[1011][1011], an[1011][1011];
string s[1011];
int ans;
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
void dfs(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= m) return;
  vis[i][j] = 1;
  for (int k = 0; k < 4; k++) {
    int x = i + dx[k];
    int y = j + dy[k];
    if (x < 0 || y < 0 || x >= n || y >= m) continue;
    if (s[x][y] == '*') ans++;
    if (s[x][y] == '.' && vis[x][y] == 0) dfs(x, y);
  }
}
void dfs1(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= m) return;
  vis[i][j] = 2;
  an[i][j] = ans;
  for (int k = 0; k < 4; k++) {
    int x = i + dx[k];
    int y = j + dy[k];
    if (x < 0 || y < 0 || x >= n || y >= m) continue;
    if (s[x][y] == '.' && vis[x][y] == 1) dfs1(x, y);
  }
}
int main() {
  int t, i, j;
  scanf("%d %d %d", &n, &m, &t);
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (vis[i][j] == 0 && s[i][j] == '.') {
        ans = 0;
        dfs(i, j);
        dfs1(i, j);
      }
    }
  }
  while (t--) {
    scanf("%d %d", &i, &j);
    i--;
    j--;
    printf("%d\n", an[i][j]);
  }
  return 0;
}
