#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char grid[1010][1010];
int region[1010][1010];
int score[1001001];
int x, y, reg;
void flood_fill(int a, int b) {
  if (a >= 0 && a < n && b >= 0 && b < m && !region[a][b]) {
    region[a][b] = reg;
    if (a > 0 && grid[a - 1][b] == '*') score[reg]++;
    if (a < n - 1 && grid[a + 1][b] == '*') score[reg]++;
    if (b > 0 && grid[a][b - 1] == '*') score[reg]++;
    if (b < m - 1 && grid[a][b + 1] == '*') score[reg]++;
    flood_fill(a + 1, b);
    flood_fill(a - 1, b);
    flood_fill(a, b + 1);
    flood_fill(a, b - 1);
  }
}
void search(int a, int b) {
  if (region[a][b]) return;
  reg++;
  flood_fill(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  reg = 0;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == '*')
        region[i][j] = -1;
      else
        region[i][j] = 0;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) search(i, j);
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    cout << score[region[x - 1][y - 1]] << '\n';
  }
  return 0;
}
