#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10, INF = 1e9;
int n, m, ans[MAXN], u[MAXN][MAXN], l[MAXN][MAXN], r[MAXN][MAXN],
    dp[MAXN][MAXN], a[MAXN][MAXN];
int mnl[MAXN], mnr[MAXN];
set<pair<int, int> > sl, sr;
char t[MAXN];
vector<pair<int, int> > q;
bool flag;
inline bool check(int x, int y, int k) {
  for (int i = x; i > -1; i--) {
    mnl[i] = y - l[i][y];
    mnr[i] = r[i][y] - y;
    if (i < x)
      mnl[i] = min(mnl[i], mnl[i + 1]), mnr[i] = min(mnr[i], mnr[i + 1]);
  }
  for (int i = x + 1; i < n; i++) {
    mnl[i] = y - l[i][y];
    mnr[i] = r[i][y] - y;
    mnl[i] = min(mnl[i], mnl[i - 1]), mnr[i] = min(mnr[i], mnr[i - 1]);
  }
  for (int j = 0; j < x + 1; j++) {
    if (x - j + 1 > k) continue;
    int mn1 = min(mnl[j], mnl[x + k - (x - j + 1)]);
    int mn2 = min(mnr[j], mnr[x + k - (x - j + 1)]);
    if (mn1 + mn2 - 1 >= k) return true;
  }
  return false;
}
inline void calc(int x, int y) {
  a[x][y] = 0;
  if (y == 0)
    l[x][y] = -1;
  else
    l[x][y] = l[x][y - 1];
  if (y == m - 1)
    r[x][y] = m;
  else
    r[x][y] = r[x][y + 1];
  for (int j = y + 1; j < m; j++) {
    if (a[x][j]) break;
    l[x][j] = l[x][y];
  }
  for (int j = y - 1; j > -1; j--) {
    if (a[x][j]) break;
    r[x][j] = r[x][y];
  }
}
int main() {
  int k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", &t);
    for (int j = 0; j < m; j++)
      if (t[j] == 'X') a[i][j] = 1;
  }
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    a[x][y] = 1;
    q.push_back({x, y});
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1)
        l[i][j] = j;
      else if (j == 0)
        l[i][j] = -1;
      else
        l[i][j] = l[i][j - 1];
    }
    for (int j = m - 1; j > -1; j--) {
      if (a[i][j] == 1)
        r[i][j] = j;
      else if (j == m - 1)
        r[i][j] = m;
      else
        r[i][j] = r[i][j + 1];
    }
  }
  for (int j = 0; j < m; j++)
    for (int i = 0; i < n; i++) {
      if (a[i][j] == 1)
        u[i][j] = i;
      else if (i == 0)
        u[i][j] = -1;
      else
        u[i][j] = u[i - 1][j];
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j]) continue;
      int val = 1e9;
      if (i > 0 and j > 0) val = dp[i - 1][j - 1];
      dp[i][j] = min(val + 1, min(j - l[i][j], i - u[i][j]));
      ans[k - 1] = max(ans[k - 1], dp[i][j]);
    }
  }
  for (int i = k - 2; i > -1; i--) {
    int ans2 = ans[i + 1] + 1;
    int x = q[i + 1].first, y = q[i + 1].second;
    calc(x, y);
    while (check(x, y, ans2)) ans2++;
    ans[i] = ans2 - 1;
  }
  for (int i = 0; i < k; i++) printf("%d \n", ans[i]);
  return 0;
}
