#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
int pic[maxn][maxn], pre[maxn][maxn];
int x[maxn], y[maxn], ans[maxn];
int L[maxn][maxn], R[maxn][maxn];
int ll[maxn], rr[maxn];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char ch = getchar();
      while (ch != 'X' && ch != '.') ch = getchar();
      if (ch == 'X')
        pic[i][j] = 1;
      else
        pic[i][j] = 0;
    }
  for (int i = 1; i <= k; i++) {
    scanf("%d%d", &x[i], &y[i]);
    pic[x[i]][y[i]] = 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      pre[i][j] = pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1] + pic[i][j];
  int nowans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      while (i + nowans <= n && j + nowans <= m &&
             pre[i + nowans][j + nowans] - pre[i - 1][j + nowans] -
                     pre[i + nowans][j - 1] + pre[i - 1][j - 1] ==
                 0)
        nowans++;
  for (int i = 0; i <= n + 1; i++) pic[i][0] = pic[i][m + 1] = 1;
  for (int j = 0; j <= m + 1; j++) pic[0][j] = pic[n + 1][j] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m + 1; j++)
      if (pic[i][j])
        L[i][j] = j;
      else
        L[i][j] = L[i][j - 1];
    for (int j = m + 1; j >= 0; j--)
      if (pic[i][j])
        R[i][j] = j;
      else
        R[i][j] = R[i][j + 1];
  }
  for (int i = k; i >= 1; i--) {
    ans[i] = nowans;
    int xx = x[i], yy = y[i];
    for (int j = yy; R[xx][j] == yy; j--) R[xx][j] = R[xx][yy + 1];
    for (int j = yy; L[xx][j] == yy; j++) L[xx][j] = L[xx][yy - 1];
    for (int j = 1; j <= n; j++) {
      ll[j] = L[j][yy];
      rr[j] = R[j][yy];
    }
    for (int j = xx - 1; j >= 1; j--) ll[j] = max(ll[j], ll[j + 1]);
    for (int j = xx + 1; j <= n; j++) ll[j] = max(ll[j], ll[j - 1]);
    for (int j = xx - 1; j >= 1; j--) rr[j] = min(rr[j], rr[j + 1]);
    for (int j = xx + 1; j <= n; j++) rr[j] = min(rr[j], rr[j - 1]);
    while (true) {
      bool update = false;
      for (int i = xx; i <= n; i++) {
        if (i - nowans < 0) continue;
        if (i - nowans > xx) break;
        if (min(rr[i], rr[i - nowans]) - max(ll[i], ll[i - nowans]) >
            nowans + 1) {
          update = true;
          break;
        }
      }
      if (update)
        nowans++;
      else
        break;
    }
  }
  for (int i = 1; i <= k; i++) printf("%d\n", ans[i]);
  return 0;
}
