#include <bits/stdc++.h>
using namespace std;
bool was[2000][2000];
char a[2000][2000];
int b[2000][2000];
int kol, col, c[2000001], n, m, k, i, j, x, y;
void dfs(int x, int y) {
  was[x][y] = true;
  b[x][y] = col;
  if (a[x][y + 1] == '.' && !was[x][y + 1])
    dfs(x, y + 1);
  else if (a[x][y + 1] == '*')
    kol++;
  if (a[x][y - 1] == '.' && !was[x][y - 1])
    dfs(x, y - 1);
  else if (a[x][y - 1] == '*')
    kol++;
  if (a[x + 1][y] == '.' && !was[x + 1][y])
    dfs(x + 1, y);
  else if (a[x + 1][y] == '*')
    kol++;
  if (a[x - 1][y] == '.' && !was[x - 1][y])
    dfs(x - 1, y);
  else if (a[x - 1][y] == '*')
    kol++;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++) {
    scanf("\n");
    for (j = 1; j <= m; j++) {
      scanf("%c", &a[i][j]);
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (a[i][j] == '.' && !was[i][j]) {
        kol = 0;
        col++;
        dfs(i, j);
        c[col] = kol;
      }
    }
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &x, &y);
    printf("%d\n", c[b[x][y]]);
  }
  return 0;
}
