#include <bits/stdc++.h>
using namespace std;
char maze[1005][1005];
int n, m, k;
int vis[1005][1005];
int ans[100005];
int cnt = 0;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void dfs(int x, int y) {
  vis[x][y] = cnt;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (maze[nx][ny] == '*') ans[cnt]++;
    if (maze[nx][ny] == '.' && vis[nx][ny] == 0) dfs(nx, ny);
  }
  return;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> maze[i][j];
    }
  }
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    if (vis[x][y])
      cout << ans[vis[x][y]] << endl;
    else {
      cnt++;
      dfs(x, y);
      cout << ans[cnt] << endl;
    }
  }
  return 0;
}
