#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int lb(vector<T> &v, const T &x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
template <class T>
inline int ub(vector<T> &v, const T &x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin();
}
template <class T>
inline int lb(T *v, int n, const T &x) {
  return lower_bound(v, v + n, x) - v;
}
template <class T>
inline int ub(T *v, int n, const T &x) {
  return upper_bound(v, v + n, x) - v;
}
template <class A, class B>
ostream &operator<<(ostream &f, const pair<A, B> &x) {
  return f << '(' << x.first << ", " << x.second << ')';
}
template <class T>
ostream &operator<<(ostream &f, const vector<T> &x) {
  int b = 0;
  f << '[';
  for (auto &y : x) {
    if (b++) f << ", ";
    f << y;
  }
  return f << ']';
}
template <class T, class C>
ostream &operator<<(ostream &f, const set<T, C> &x) {
  int b = 0;
  f << '[';
  for (auto &y : x) {
    if (b++) f << ", ";
    f << y;
  }
  return f << ']';
}
template <class T, class C>
ostream &operator<<(ostream &f, const multiset<T, C> &x) {
  int b = 0;
  f << '[';
  for (auto &y : x) {
    if (b++) f << ", ";
    f << y;
  }
  return f << ']';
}
template <class K, class T, class C>
ostream &operator<<(ostream &f, const map<K, T, C> &x) {
  int b = 0;
  f << '[';
  for (auto &y : x) {
    if (b++) f << ", ";
    f << y;
  }
  return f << ']';
}
template <class K, class T, class C>
ostream &operator<<(ostream &f, const multimap<K, T, C> &x) {
  int b = 0;
  f << '[';
  for (auto &y : x) {
    if (b++) f << ", ";
    f << y;
  }
  return f << ']';
}
template <class T>
ostream &operator<<(ostream &f, queue<T> x) {
  int b = 0;
  f << '[';
  while (x.size()) {
    if (b++) f << ", ";
    f << x.front();
    x.pop();
  }
  return f << ']';
}
template <class T>
ostream &operator<<(ostream &f, stack<T> x) {
  int b = 0;
  f << '[';
  while (x.size()) {
    if (b++) f << ", ";
    f << x.top();
    x.pop();
  }
  return f << ']';
}
template <class T, class V, class C>
ostream &operator<<(ostream &f, priority_queue<T, V, C> x) {
  int b = 0;
  f << '[';
  while (x.size()) {
    if (b++) f << ", ";
    f << x.top();
    x.pop();
  }
  return f << ']';
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
uniform_int_distribution<int> uid(0, numeric_limits<int>::max());
const int inf = 0x3f3f3f3f;
const long long infl = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1003;
int n, m, k;
int ans[maxn][maxn];
char mat[maxn][maxn];
int find(int x, int y) {
  if (mat[x][y] == '*') return 1;
  if (mat[x][y] != '.') return 0;
  mat[x][y] = '#';
  static const int dx[] = {-1, 1, 0, 0};
  static const int dy[] = {0, 0, -1, 1};
  int r = 0;
  for (int i = 0; i < 4; ++i) {
    r += find(x + dx[i], y + dy[i]);
  }
  return r;
}
void color(int x, int y, int c) {
  if (mat[x][y] == '*') return;
  if (mat[x][y] != '#') return;
  mat[x][y] = '$';
  ans[x][y] = c;
  static const int dx[] = {-1, 1, 0, 0};
  static const int dy[] = {0, 0, -1, 1};
  for (int i = 0; i < 4; ++i) {
    color(x + dx[i], y + dy[i], c);
  }
}
int solve(int x, int y) {
  if (mat[x][y] == '.') {
    color(x, y, find(x, y));
  }
  return ans[x][y];
}
int main() {
  void(0);
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> mat[i][j];
    }
  }
  while (k--) {
    int x, y;
    cin >> x >> y, --x, --y;
    cout << solve(x, y) << '\n';
  }
  return 0;
}
