#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int u[1005][1005];
char a[1005][1005];
int comp;
int ans[1000005];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int n, m;
void bfs(int sx, int sy) {
  queue<pair<int, int> > q;
  q.push(make_pair(sx, sy));
  u[sx][sy] = comp;
  while (!q.empty()) {
    int cx = q.front().first, cy = q.front().second;
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if (nx > 0 && nx <= n && ny > 0 && ny <= m && a[nx][ny] == '*') {
        ++ans[comp];
      }
      if (nx > 0 && nx <= n && ny > 0 && ny <= m && a[nx][ny] == '.' &&
          !u[nx][ny]) {
        u[nx][ny] = comp;
        q.push(make_pair(nx, ny));
      }
    }
  }
}
int main() {
  int q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    scanf(" %s", a[i] + 1);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (!u[i][j] && a[i][j] == '.') {
        ++comp;
        bfs(i, j);
      }
    }
  }
  while (q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", ans[u[x][y]]);
  }
  return 0;
}
