#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, fu = 0;
  char ch = getchar();
  for (; ch < 48 || ch > 57; ch = getchar()) fu |= (ch == '-');
  for (; ch > 47 && ch < 58; ch = getchar()) x = x * 10 + ch - '0';
  return fu ? -x : x;
}
int n, m, Q, a[2005][2005], ret;
struct min_dis_to_X {
  int l, r;
} c[2005][2005];
struct query {
  int x, y;
} q[2005];
int ans[2005], f[2005][2005];
void init() {
  n = read(), m = read(), Q = read();
  for (int i = 1; i <= n; getchar(), i++)
    for (int j = 1; j <= m; j++) a[i][j] = (getchar() == 'X' ? 0 : 1);
  for (int i = 1; i <= Q; i++)
    q[i].x = read(), q[i].y = read(), a[q[i].x][q[i].y] = 0;
  for (int i = 1; i <= n; i++) {
    c[i][0].l = 0, c[i][m + 1].r = m + 1;
    for (int j = 1; j <= m; j++) c[i][j].l = (a[i][j] ? c[i][j - 1].l : j);
    for (int j = m; j >= 1; j--) c[i][j].r = (a[i][j] ? c[i][j + 1].r : j);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j])
        f[i][j] = min(min(f[i - 1][j], f[i][j - 1]), f[i - 1][j - 1]) + 1,
        ret = max(ret, f[i][j]);
  ans[Q] = ret, ret++;
}
int ql[2005], qr[2005], hdl, tll, hdr, tlr;
bool check(int _q) {
  int up = q[_q].x, dn = q[_q].x;
  while (up < n && a[up + 1][q[_q].y] && up - q[_q].x + 1 <= ret) up++;
  while (dn > 1 && a[dn - 1][q[_q].y] && q[_q].x - dn + 1 <= ret) dn--;
  if (up - dn + 1 < ret) return 0;
  hdl = hdr = 1, tll = tlr = 0;
  for (int i = dn, u = dn + ret - 1; i <= u; i++) {
    while (hdl <= tll && c[ql[tll]][q[_q].y].l < c[i][q[_q].y].l) tll--;
    ql[++tll] = i;
    while (hdr <= tlr && c[qr[tlr]][q[_q].y].r > c[i][q[_q].y].r) tlr--;
    qr[++tlr] = i;
  }
  if (c[qr[hdr]][q[_q].y].r - c[ql[hdl]][q[_q].y].l > ret) return 1;
  for (int i = dn + ret; i <= up; i++) {
    while (hdl <= tll && i - ql[hdl] >= ret) hdl++;
    while (hdr <= tlr && i - qr[hdr] >= ret) hdr++;
    while (hdl <= tll && c[ql[tll]][q[_q].y].l < c[i][q[_q].y].l) tll--;
    ql[++tll] = i;
    while (hdr <= tlr && c[qr[tlr]][q[_q].y].r > c[i][q[_q].y].r) tlr--;
    qr[++tlr] = i;
    if (c[qr[hdr]][q[_q].y].r - c[ql[hdl]][q[_q].y].l > ret) return 1;
  }
  return 0;
}
int main() {
  init();
  for (int _q = Q; _q > 1; ans[--_q] = ret - 1) {
    a[q[_q].x][q[_q].y] = 1;
    for (int i = q[_q].y; i <= m; i++)
      c[q[_q].x][i].l = (a[q[_q].x][i] ? c[q[_q].x][i - 1].l : i);
    for (int i = q[_q].y; i >= 1; i--)
      c[q[_q].x][i].r = (a[q[_q].x][i] ? c[q[_q].x][i + 1].r : i);
    while (check(_q)) ret++;
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
