#include <bits/stdc++.h>
using namespace std;
char s[2000][2000];
int counter = 0;
int status[2000][2000];
int cnt = 0;
int n, m, k;
vector<int> dp(200000);
void dfs(int a, int b);
void print_it() {
  for (int l = 0; l < n; l++) {
    for (int j = 0; j < m; j++) cout << status[l][j] << " ";
    cout << endl;
  }
}
void fun(int a, int b) {
  if (s[a][b] == '*') {
    cnt++;
  } else if (status[a][b] != counter)
    dfs(a, b);
}
void dfs(int a, int b) {
  status[a][b] = counter;
  if (a - 1 >= 0) fun(a - 1, b);
  if (a + 1 < n) fun(a + 1, b);
  if (b - 1 >= 0) fun(a, b - 1);
  if (b + 1 < m) fun(a, b + 1);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (status[a][b])
      cout << dp[status[a][b]] << endl;
    else {
      counter++;
      dfs(a, b);
      cout << cnt << endl;
      dp[counter] = cnt;
      cnt = 0;
    }
  }
  return 0;
}
