#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
int n, m, k, x, y, s[maxn][maxn], u[maxn][maxn], d[maxn][maxn], T[maxn << 2];
char S[maxn];
inline int get() {
  char ch = getchar();
  while (ch != '.' && ch != 'X') ch = getchar();
  return ch == '.';
}
inline int read(int x = 0) {
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x;
}
inline int calc(int l, int r, int ret = 0) {
  int *up = u[((l + r) >> 1)], *dn = d[((l + r) >> 1)];
  deque<int> Qu, Qd;
  for (int lpos = 0, rpos = 1; rpos <= m; ++rpos) {
    while ((!Qu.empty()) && (up[Qu.back()] >= up[rpos])) Qu.pop_back();
    Qu.push_back(rpos);
    while ((!Qd.empty()) && (dn[Qd.back()] >= dn[rpos])) Qd.pop_back();
    Qd.push_back(rpos);
    ret = max(ret, min((min(((l + r) >> 1) - l + 1, up[Qu.front()]) +
                        min(r - ((l + r) >> 1) + 1, dn[Qd.front()]) - 1),
                       rpos - lpos));
    while (lpos < rpos &&
           (min(((l + r) >> 1) - l + 1, up[Qu.front()]) +
            min(r - ((l + r) >> 1) + 1, dn[Qd.front()]) - 1) <= rpos - lpos) {
      ++lpos;
      if (Qu.front() == lpos) Qu.pop_front();
      if (Qd.front() == lpos) Qd.pop_front();
    }
  }
  return ret;
}
inline void build(int root, int l, int r) {
  T[root] = calc(l, r);
  if (l == r) return;
  build((root << 1), l, ((l + r) >> 1)),
      build((root << 1 | 1), ((l + r) >> 1) + 1, r);
  T[root] = max(T[root], max(T[(root << 1)], T[(root << 1 | 1)]));
}
inline int work(int root, int l, int r, int pos) {
  if (l == r) return T[root] = calc(l, r);
  if (pos <= ((l + r) >> 1))
    return T[root] =
               max(calc(l, r), max(work((root << 1), l, ((l + r) >> 1), pos),
                                   T[(root << 1 | 1)]));
  else
    return T[root] = max(calc(l, r),
                         max(T[(root << 1)], work((root << 1 | 1),
                                                  ((l + r) >> 1) + 1, r, pos)));
}
inline int getans(int x, int y) {
  s[x][y] = 0;
  for (int i = 1; i <= n; ++i) u[i][y] = s[i][y] ? u[i - 1][y] + 1 : 0;
  for (int i = n; i >= 1; --i) d[i][y] = s[i][y] ? d[i + 1][y] + 1 : 0;
  return work(1, 1, n, x);
}
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) s[i][j] = get();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) u[i][j] = s[i][j] ? u[i - 1][j] + 1 : 0;
  for (int i = n; i >= 1; --i)
    for (int j = 1; j <= m; ++j) d[i][j] = s[i][j] ? d[i + 1][j] + 1 : 0;
  build(1, 1, n);
  while (k--) x = read(), y = read(), printf("%d\n", getans(x, y));
}
