#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int n, m, k, vis[maxn][maxn], col, ans[maxn * maxn];
char s[maxn][maxn];
struct node {
  int x, y;
};
queue<node> q;
int bfs(node st) {
  int ret = 0;
  col++;
  q.push(st);
  vis[st.x][st.y] = col;
  while (!q.empty()) {
    node cs = q.front();
    q.pop();
    for (int i = 0; i <= 3; ++i) {
      node ns = cs;
      ns.x += dx[i];
      ns.y += dy[i];
      if (ns.x < 1 || ns.y < 1 || ns.x > n || ns.y > m || vis[ns.x][ns.y])
        continue;
      if (s[ns.x][ns.y] == '*') {
        ret++;
        continue;
      }
      vis[ns.x][ns.y] = col;
      q.push(ns);
    }
  }
  ans[col] = ret;
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
  }
  for (int i = 1; i <= k; ++i) {
    node cs;
    scanf("%d%d", &cs.x, &cs.y);
    if (vis[cs.x][cs.y])
      printf("%d\n", ans[vis[cs.x][cs.y]]);
    else
      printf("%d\n", bfs(cs));
  }
  return 0;
}
