#include <bits/stdc++.h>
using namespace std;
long long parent[1000 * 1000];
long long n, m, k, i, j;
string s[1000];
bool vis[1000][1000];
long long dsu_find(long long x) {
  if (x == parent[x]) return x;
  return parent[x] = dsu_find(parent[x]);
}
void dsu_union(long long x, long long y) {
  long long a = dsu_find(x);
  long long b = dsu_find(y);
  if (a != b) parent[a] = b;
}
long long dfs(long long i, long long j, long long p) {
  vis[i][j] = true;
  dsu_union(i * 1000 + j, p);
  long long ans = 0;
  if (i + 1 < n && s[i + 1][j] == '*') ans++;
  if (i - 1 >= 0 && s[i - 1][j] == '*') ans++;
  if (j + 1 < m && s[i][j + 1] == '*') ans++;
  if (j - 1 >= 0 && s[i][j - 1] == '*') ans++;
  if (i + 1 < n && vis[i + 1][j] == false) ans += dfs(i + 1, j, 1000 * i + j);
  if (i - 1 >= 0 && vis[i - 1][j] == false) ans += dfs(i - 1, j, 1000 * i + j);
  if (j + 1 < m && vis[i][j + 1] == false) ans += dfs(i, j + 1, 1000 * i + j);
  if (j - 1 >= 0 && vis[i][j - 1] == false) ans += dfs(i, j - 1, 1000 * i + j);
  return ans;
}
int main() {
  for (long long i = 0; i < 1000 * 1000; i++) parent[i] = i;
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) vis[i][j] = s[i][j] == '*';
  map<long long, long long> value;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (vis[i][j] == false) value[1000 * i + j] = dfs(i, j, 1000 * i + j);
  while (k--) {
    cin >> i >> j;
    i--;
    j--;
    cout << value[dsu_find(1000 * i + j)] << endl;
  }
}
