#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long powmd(long long a, long long b) {
  a = a % md;
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      ret = ret * b % md;
    }
    b = b * b % md;
  }
  return ret;
}
const int MAX = 1010;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int p[MAX * MAX];
int vis[MAX][MAX];
char mat[MAX][MAX];
int n, m, k;
int ans;
bool inside(int x, int y) { return (x >= 0 && y >= 0 && x < n && y < m); }
void dfs(int x, int y, int c) {
  vis[x][y] = c;
  for (int i = 0; i < 4; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (inside(nx, ny)) {
      if (mat[nx][ny] == '*')
        ans++;
      else if (!vis[nx][ny])
        dfs(nx, ny, c);
    }
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> mat[i][j];
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    ans = 0;
    if (!vis[x][y])
      dfs(x, y, i + 1);
    else
      ans = p[vis[x][y]];
    p[i + 1] = ans;
    cout << ans << '\n';
  }
}
