#include <bits/stdc++.h>
using namespace std;
const int NM_MAX = 2002;
const int K_MAX = 2002;
struct Event {
  int a, b;
  int time;
};
int n, m, k;
bool occupied[NM_MAX][NM_MAX];
int maxL[NM_MAX][NM_MAX];
int maxR[NM_MAX][NM_MAX];
int maxU[NM_MAX][NM_MAX];
int maxD[NM_MAX][NM_MAX];
int answer[K_MAX];
void pushDeque(deque<int> &dq, int histo[], int curr) {
  while (dq.empty() == false && histo[dq.back()] >= histo[curr]) dq.pop_back();
  dq.push_back(curr);
}
int maxSquare(int cnt, int histo1[], int histo2[]) {
  deque<int> dq1, dq2;
  int maxLen = 0;
  int j = 1;
  for (int i = 1; i <= cnt; i++) {
    if (histo1[i] == 0) {
      dq1.clear();
      dq2.clear();
      j = i + 1;
      continue;
    }
    pushDeque(dq1, histo1, i);
    pushDeque(dq2, histo2, i);
    while (histo1[dq1.front()] + histo2[dq2.front()] - 1 < i - j + 1) {
      j++;
      if (dq1.front() < j) dq1.pop_front();
      if (dq2.front() < j) dq2.pop_front();
    }
    maxLen = max(maxLen, i - j + 1);
  }
  return maxLen;
}
int histo1[NM_MAX], histo2[NM_MAX];
void update(int time1, int time2, int len) {
  for (int time = time1; time < time2; time++)
    answer[time] = max(answer[time], len);
}
void solve(int a1, int b1, int a2, int b2, vector<Event> events) {
  vector<Event> in;
  for (Event &e : events)
    if (a1 <= e.a && e.a <= a2 && b1 <= e.b && e.b <= b2) in.push_back(e);
  events = in;
  if (b2 - b1 + 1 <= a2 - a1 + 1) {
    int amid = ((a1 + a2) >> 1);
    if (a1 < amid) solve(a1, b1, amid - 1, b2, events);
    if (amid < a2) solve(amid + 1, b1, a2, b2, events);
    for (int b = b1; b <= b2; b++) {
      histo1[b] = min(maxU[amid][b], amid - a1 + 1);
      histo2[b] = min(maxD[amid][b], a2 - amid + 1);
    }
    int firstTime;
    if (events.empty() == true)
      firstTime = k + 1;
    else
      firstTime = events.front().time;
    update(1, firstTime,
           maxSquare(b2 - b1 + 1, histo1 + b1 - 1, histo2 + b1 - 1));
    for (int i = 0; i < (int)events.size(); i++) {
      Event e = events[i];
      if (e.a <= amid) histo1[e.b] = min(histo1[e.b], amid - e.a);
      if (amid <= e.a) histo2[e.b] = min(histo2[e.b], e.a - amid);
      int time1 = e.time;
      int time2;
      if (i < (int)events.size() - 1)
        time2 = events[i + 1].time;
      else
        time2 = k + 1;
      update(time1, time2,
             maxSquare(b2 - b1 + 1, histo1 + b1 - 1, histo2 + b1 - 1));
    }
  } else {
    int bmid = ((b1 + b2) >> 1);
    if (b1 < bmid) solve(a1, b1, a2, bmid - 1, events);
    if (bmid < b2) solve(a1, bmid + 1, a2, b2, events);
    for (int a = a1; a <= a2; a++) {
      histo1[a] = min(maxL[a][bmid], bmid - b1 + 1);
      histo2[a] = min(maxR[a][bmid], b2 - bmid + 1);
    }
    int firstTime;
    if (events.empty() == true)
      firstTime = k + 1;
    else
      firstTime = events.front().time;
    update(1, firstTime,
           maxSquare(a2 - a1 + 1, histo1 + a1 - 1, histo2 + a1 - 1));
    for (int i = 0; i < (int)events.size(); i++) {
      Event e = events[i];
      if (e.b <= bmid) histo1[e.a] = min(histo1[e.a], bmid - e.b);
      if (bmid <= e.b) histo2[e.a] = min(histo2[e.a], e.b - bmid);
      int time1 = e.time;
      int time2;
      if (i < (int)events.size() - 1)
        time2 = events[i + 1].time;
      else
        time2 = k + 1;
      update(time1, time2,
             maxSquare(a2 - a1 + 1, histo1 + a1 - 1, histo2 + a1 - 1));
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) occupied[i][j] = (s[j - 1] == 'X');
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (occupied[i][j] == true)
        maxL[i][j] = 0;
      else
        maxL[i][j] = maxL[i][j - 1] + 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (occupied[i][j] == true)
        maxU[i][j] = 0;
      else
        maxU[i][j] = maxU[i - 1][j] + 1;
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      if (occupied[i][j] == true)
        maxR[i][j] = 0;
      else
        maxR[i][j] = maxR[i][j + 1] + 1;
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      if (occupied[i][j] == true)
        maxD[i][j] = 0;
      else
        maxD[i][j] = maxD[i + 1][j] + 1;
  vector<Event> events;
  for (int i = 1; i <= k; i++) {
    Event e;
    cin >> e.a >> e.b;
    e.time = i;
    events.push_back(e);
  }
  solve(1, 1, n, m, events);
  for (int i = 1; i <= k; i++) cout << answer[i] << "\n";
  return 0;
}
