#include <bits/stdc++.h>
using namespace std;
const int N = 1111, M = 1111, INF = 1e9;
struct pt {
  int x, y;
};
bool cmp(pt a, pt b) { return 1; }
char a[N][N];
int u[N][N], col[N][N];
int n, m, t, x, y;
vector<int> comp;
int bfs(pt v) {
  int ans = 0;
  u[v.x][v.y] = 1;
  queue<pt> q;
  q.push(v);
  int sz = comp.size();
  while (!q.empty()) {
    pt v = q.front();
    q.pop();
    col[v.x][v.y] = sz;
    v.x++;
    if (a[v.x][v.y] == '*')
      ans++;
    else if (!u[v.x][v.y]) {
      u[v.x][v.y] = 1;
      q.push(v);
    }
    v.x -= 2;
    if (a[v.x][v.y] == '*')
      ans++;
    else if (!u[v.x][v.y]) {
      u[v.x][v.y] = 1;
      q.push(v);
    }
    v.x++;
    v.y++;
    if (a[v.x][v.y] == '*')
      ans++;
    else if (!u[v.x][v.y]) {
      u[v.x][v.y] = 1;
      q.push(v);
    }
    v.y -= 2;
    if (a[v.x][v.y] == '*')
      ans++;
    else if (!u[v.x][v.y]) {
      u[v.x][v.y] = 1;
      q.push(v);
    }
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  getchar();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &a[i][j]);
    }
    getchar();
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '*' || u[i][j]) continue;
      pt v;
      v.x = i;
      v.y = j;
      comp.push_back(bfs(v));
    }
  }
  while (t--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    printf("%d\n", comp[col[x][y]]);
  }
}
