#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#define REP(i, x, y) for(int i = x, _ = y; i <= _; i ++)
#define rep(i, x, y) for(int i = x, _ = y; i >= _; i --)
int min(int x, int y) { return x < y? x : y; }
int max(int x, int y) { return x > y? x : y; }
bool Chkmin(int &x, int y) { return y < x? x = y, true : false; }
bool Chkmax(int &x, int y) { return y > x? x = y, true : false; }
const int MAXN = 4000, oo = 0x3f3f3f3f;
bool c[MAXN][MAXN];
int Up[MAXN][MAXN], Down[MAXN][MAXN], Ans[MAXN * 4];
int n, m, k, X;

struct Sta{
	int x, pos;
	Sta(){}
	Sta(int x, int pos):
		x(x), pos(pos){}
	bool operator < (const Sta &a) const {
		if(x != a.x)
			return x < a.x;
		return pos;
	}
};

struct SpecialQueue{
	int head, tail;
	Sta q[MAXN];
	inline void Init()
	{
		head = tail = 0;
	}
	inline void push(Sta a)
	{
		while(head <= tail) {
			if(a < q[tail])
				tail --;
			else break;
		}
		q[++ tail] = a;
	}
	inline Sta top()
	{
		if(head > tail)
			return Sta(0, 10000);
		return q[head];
	}
	inline void pop() { head ++; }
}UpQueue, DownQueue;

void Readin(int &x)
{
	x = 0;
	char c = getchar();
	while(!('0' <= c && c <= '9'))
		c = getchar();
	while('0' <= c && c <= '9') {
		(x *= 10) += c - '0';
		c = getchar();
	}
}

void Update(int x, int y)
{
	if(c[x][y])
		return ;

	for(int i = x; i > 0 && !c[i][y]; i --)
		Down[i][y] = x;

	for(int i = x; i <= n && !c[i][y]; i ++)
		Up[i][y] = x;

	c[x][y] = true;
}

void Maintain(int o)
{
	Chkmax(Ans[o], Ans[o << 1]);
	Chkmax(Ans[o], Ans[o << 1|1]);
}

void Work(int o, int l, int r)
{
	if(X && (X < l || X > r))
		return ;

	int mid = (l + r) >> 1, L = 1, R = 1, UpTmp, DownTmp, ans = 0;

	UpQueue.Init();
	DownQueue.Init();

	do{
		UpQueue.push(Sta(mid - Up[mid][R], R));
		DownQueue.push(Sta(Down[mid][R] - mid, R));
		if(c[mid][R])
			continue;

		do{
			UpTmp = min(UpQueue.top().x, mid - l + 1);
			DownTmp = min(DownQueue.top().x, r - mid + 1);

			while(UpTmp + DownTmp - 1 < R - L + 1) {
				L = min(UpQueue.top().pos, DownQueue.top().pos) + 1;
				if(UpQueue.top().pos < L)
					UpQueue.pop();
				if(DownQueue.top().pos < L)
					DownQueue.pop();

				UpTmp = min(UpQueue.top().x, mid - l + 1);
				DownTmp = min(DownQueue.top().x, r - mid + 1);

				if(L > R)
					break;
			}

			Chkmax(ans, min(UpTmp + DownTmp - 1, R - L + 1));
		} while(R - L + 1 > UpTmp + DownTmp - 1);
	} while(++ R <= m);

	Ans[o] = ans;
	if(l == r)
		return;

	Work(o << 1, l, mid);
	Work(o << 1|1, mid + 1, r);
	Maintain(o);
}

char s[MAXN];
void Init()
{
	Readin(n);
	Readin(m);
	Readin(k);
	REP(i, 1, n)
		REP(j, 1, m) {
			Up[i][j] = 0;
			Down[i][j] = n + 1;
		}

	REP(i, 1, n) {
		scanf("%s", s + 1);
		REP(j, 1, m)
			if(s[j] == 'X')
				Update(i, j);
	}
}

void Solve()
{
	int x, y;

	X = 0;
	Work(1, 1, n);
	REP(i, 1, k) {
		Readin(x);
		Readin(y);
		X = x;
		Update(x, y);
		Work(1, 1, n);
		printf("%d\n", Ans[1]);
	}
}

int main()
{
	Init();
	Solve();
}


#include<bits/stdc++.h>
#define MAXN 2005
using namespace std;
struct CMD{int x,y,ans;}C[MAXN];
bool graph[MAXN][MAXN];
int up[MAXN][MAXN],down[MAXN][MAXN];
int N,M,K,ANS;
void update(int j){
	for(int i=1;i<=N;i++)
		up[i][j]=graph[i][j]?up[i-1][j]+1:0;
	for(int i=N;i>=1;i--)
		down[i][j]=graph[i][j]?down[i+1][j]+1:0;
}
void prework(){
	static int dp[MAXN][MAXN];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++){
			if(graph[i][j]==0) dp[i][j]=0;
			else dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
			ANS=max(ANS,dp[i][j]);
		}
	for(int j=1;j<=M;j++) update(j);
}
int main(){
	char ch;
	scanf("%d%d%d",&N,&M,&K);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			scanf(" %c",&ch),graph[i][j]=ch=='.'?1:0;
	for(int i=1;i<=K;i++)
		scanf("%d%d",&C[i].x,&C[i].y),graph[C[i].x][C[i].y]=0;
	prework(); C[K].ans=ANS;
	static int ql[MAXN],qr[MAXN],qll,qlr,qrl,qrr;
	for(int i=K,ret,x,l,r,h;i>=1;i--){
		ret=0; x=C[i].x;
		graph[C[i].x][C[i].y]=1;
		update(C[i].y);
		qll=qrl=l=1; qlr=qrr=r=0;
		while(l<=M){
			h=-233;
			if(l<=r){
				h=up[x][ql[qll]]+down[x][qr[qrl]]-1;
				ret=max(ret,min(h,r-l+1));
			}
			if(r<M&&(h==-233||h>=r-l+1)){
				r++;
				while(qll<=qlr&&up[x][ql[qlr]]>=up[x][r]) qlr--; ql[++qlr]=r;
				while(qrl<=qrr&&down[x][qr[qrr]]>=down[x][r]) qrr--;qr[++qrr]=r;
			}
			else{
				l++;
				while(qll<=qlr&&ql[qll]<l) qll++;
				while(qrl<=qrr&&qr[qrl]<l) qrl++;
			}
		}
		ANS=max(ret,ANS);
		C[i-1].ans=ANS;
	}
	for(int i=1;i<=K;i++) printf("%d\n",C[i].ans);
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
const int N = 2020;
int n,m,k,ans[N],f[N][N],A[N],B[N];char s[N][N];
int l[N][N],r[N][N];
inline void init(int i){
	for(int j=1,k=0;j<=m;j++){
		k=s[i][j]=='X'?j:k;l[i][j]=k;
	}
	for(int j=m,k=m+1;j>=1;j--){
		k=s[i][j]=='X'?j:k;r[i][j]=k;
	}
}
inline bool ck(int x, int y, int k){
	static int a[N],b[N],mx[N],mn[N];
	rep(i,1,n)a[i]=l[i][y],b[i]=r[i][y];
	rep(i,x+1,n)umin(b[i],b[i-1]),umax(a[i],a[i-1]);
	per(i,x-1,1)umin(b[i],b[i+1]),umax(a[i],a[i+1]);
	rep(i,1,n-k+1)if(x>=i&&x<=i+k-1&&min(b[i],b[i+k-1])-max(a[i],a[i+k-1])>=k+1){
		return 1;
	}
	return 0;
}
int main() {
	read(n);read(m);read(k);
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,k)read(A[i]),read(B[i]),s[A[i]][B[i]]='X';
	per(i,n,1)per(j,m,1)if(s[i][j]=='.'){
		f[i][j]=min(f[i][j+1],f[i+1][j]);
		if(i+f[i][j]<=n&&j+f[i][j]<=m&&s[i+f[i][j]][j+f[i][j]]=='.')f[i][j]++;
		umax(ans[k],f[i][j]);
	}
	rep(i,1,n)init(i);
	per(t,k,1){//recover t-->ans[t-1]
		ans[t-1]=ans[t];s[A[t]][B[t]]='.';init(A[t]);
		while(ck(A[t],B[t],ans[t-1]+1))ans[t-1]++;
	}
	rep(i,1,k)printf("%d\n",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
const int N = 2020;
int n,m,k,ans[N],f[N][N],A[N],B[N];char s[N][N];
int l[N][N],r[N][N];
inline void init(int i){
	for(int j=1,k=0;j<=m;j++){
		k=s[i][j]=='X'?j:k;l[i][j]=k;
	}
	for(int j=m,k=m+1;j>=1;j--){
		k=s[i][j]=='X'?j:k;r[i][j]=k;
	}
}
int q[N];int F,R;
inline bool ck(int x, int y, int k){
	static int a[N],b[N],mx[N],mn[N];
	rep(i,1,n)a[i]=l[i][y],b[i]=r[i][y];
	F=1;R=1;rep(i,1,k){while(F!=R&&b[q[R-1]]>=b[i])R--;q[R++]=i;}
	rep(i,1,n-k+1){
		mx[i]=b[q[F]];while(F!=R&&b[q[R-1]]>=b[i+k])R--;q[R++]=i+k;
		if(F!=R&&q[F]==i)F++;
	}
	F=1;R=1;rep(i,1,k){while(F!=R&&a[q[R-1]]<=a[i])R--;q[R++]=i;}
	rep(i,1,n-k+1){
		mn[i]=a[q[F]];while(F!=R&&a[q[R-1]]<=a[i+k])R--;q[R++]=i+k;
		if(F!=R&&q[F]==i)F++;
		if(mx[i]-mn[i]>=k+1&&x>=i&&x<=i+k-1)return 1;
	}
	return 0;
}
int main() {
	read(n);read(m);read(k);
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,k)read(A[i]),read(B[i]),s[A[i]][B[i]]='X';
	per(i,n,1)per(j,m,1)if(s[i][j]=='.'){
		f[i][j]=min(f[i][j+1],f[i+1][j]);
		if(i+f[i][j]<=n&&j+f[i][j]<=m&&s[i+f[i][j]][j+f[i][j]]=='.')f[i][j]++;
		umax(ans[k],f[i][j]);
	}
	rep(i,1,n)init(i);
	per(t,k,1){//recover t-->ans[t-1]
		ans[t-1]=ans[t];s[A[t]][B[t]]='.';init(A[t]);
		while(ck(A[t],B[t],ans[t-1]+1))ans[t-1]++;
	}
	rep(i,1,k)printf("%d\n",ans[i]);
	return 0;
}


#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 2005;

struct Node {
	int x, y;
} p[MAXN];

char s[MAXN][MAXN];
int n, m, k, l[MAXN][MAXN], r[MAXN][MAXN], f[MAXN][MAXN], pr[MAXN], d1[MAXN], d2[MAXN];

int getl(int x, int y) {
	return (l[x][y] == y) ? y : l[x][y] = getl(x, l[x][y]);
}

int getr(int x, int y) {
	return (r[x][y] == y) ? y : r[x][y] = getr(x, r[x][y]);
}

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i ++) scanf("%s", s[i] + 1);
	for (int i = 1; i <= k; i ++) scanf("%d%d", &p[i].x, &p[i].y), s[p[i].x][p[i].y] = 'X';
	for (int i = 1; i <= n; i ++) {
		l[i][m + 1] = r[i][m + 1] = m + 1;
		for (int j = 1; j <= m; j ++) {
			if (s[i][j] == 'X') l[i][j] = r[i][j] = j; else
				l[i][j] = j - 1, r[i][j] = j + 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++) {
			if (s[i][j] == 'X') continue;
			f[i][j] = min(min(f[i - 1][j], f[i][j - 1]), f[i - 1][j - 1]) + 1;
			ans = max(ans, f[i][j]);
		}
	pr[k] = ans;
	for (int i = k; i; i --) {
		int x = p[i].x, y = p[i].y;
		l[x][y] = y - 1, r[x][y] = y + 1;
		bool ok = 0;
		while (!ok) {
			ok = 1;
			int ll = 1, lr = 0, rl = 1, rr = 0;
			for (int j = 1; j <= n; j ++) {
				while (ll <= lr && d1[ll] < j - ans) ll ++;
				while (ll <= lr && getl(j, y) > getl(d1[lr], y)) lr --;
				d1[++ lr] = j;
				while (rl <= rr && d2[rl] < j - ans) rl ++;
				while (rl <= rr && getr(j, y) < getr(d2[rr], y)) rr --;
				d2[++ rr] = j;
				if (j > ans && getr(d2[rl], y) - getl(d1[ll], y) - 1 > ans) {ok = 0; break;}
			}
			if (!ok) ans ++;
		}
		pr[i - 1] = ans;
	}
	for (int i = 1; i <= k; i ++) printf("%d\n", pr[i]);
}


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

#define Int register int
#define int long long
#define MAXN 2005

int n,m,k,Ans;

int l1[MAXN],r1[MAXN],put[MAXN],dp[MAXN][MAXN];

char Map[MAXN][MAXN];

struct node
{
	int fa[MAXN];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[MAXN],r[MAXN];

void Delete (int x,int y)
{
	l[x].fa[y] = l[x].findSet (y - 1);
	r[x].fa[y] = r[x].findSet (y + 1);
}

pair <int,int> ques[MAXN];

void Print()
{
	for (Int i = 1;i <= n;++ i)
	{
		for (Int j = 1;j <= m;++ j)
			cout << Map[i][j];
		cout << endl;
	}
}

void read (int &x)
{
	x = 0;char c = getchar ();int f = 1;
	while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}
	while (c >= '0' && c <= '9'){x = (x << 3) + (x << 1) + c - '0';c = getchar();}
	x *= f;return ;
}

void write (int x)
{
	if (x < 0){x = -x;putchar ('-');}
	if (x > 9) write (x / 10);
	putchar (x % 10 + '0');
}

signed main()
{
	read (n),read (m),read (k);
	for (Int i = 1;i <= n;++ i)
	 	scanf ("%s",Map[i] + 1);
	for (Int i = 1;i <= k;++ i)
	{
		pair <int,int> &x = ques[i];
		read (x.first),read (x.second);
		Map[x.first][x.second] = 'X';
	}
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m + 1;++ j)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	/*
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m;++ j)
			cout << i << " " << j << "'s father  is" << l[i].findSet (j) << "->" << r[i].findSet (j) << endl;
	*/
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m;++ j)
			if (Map[i][j] == '.')
				Delete (i,j);
	for (Int i = 1;i <= n;++ i)
	{
		for (Int j = 1;j <= m;++ j)
		{
			if (Map[i][j] == '.')
			{
				dp[i][j] = min (dp[i][j - 1],min (dp[i - 1][j],dp[i - 1][j - 1])) + 1;
				Ans = max (Ans,dp[i][j]);
			}
		}
	}
	for (Int i = k;i >= 1;-- i)
	{
		put[i] = Ans;
		pair <int,int> &x = ques[i];
		Delete (x.first,x.second);
		for (Int i = 1;i <= n;++ i)
		{
			l1[i] = x.second - l[i].findSet (x.second);
			r1[i] = r[i].findSet(x.second) - x.second;
		}
		for (Int i = x.first + 1;i <= n;++ i)
		{
			l1[i] = min (l1[i],l1[i - 1]);
			r1[i] = min (r1[i],r1[i - 1]);
		}
		for (Int i = x.first - 1;i >= 1;-- i)
		{
			l1[i] = min (l1[i],l1[i + 1]);
			r1[i] = min (r1[i],r1[i + 1]);
		}
		for (Int i = 1;i <= x.first;++ i)
			while (min (l1[i],l1[i + Ans]) + min (r1[i],r1[i + Ans]) > Ans + 1)
				Ans ++;
	}
	for (Int i = 1;i <= k;++ i)
		write (put[i]),putchar ('\n');
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-')
		{
			f = -1;
		}
		c = getchar();
	}
	while (isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int f[4001][4001], lefta[4001][4001], righta[4001][4001];
int b[4001], dl[4001], ask[4001][2];
int a[4001][4001];
int n, m, q, now, x, y;
bool check(int ans)
{
	int head = 1, tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && lefta[dl[tail]][y] >= lefta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] = lefta[dl[head]][y];
	}
	head = 1;
	tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && righta[dl[tail]][y] >= righta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] += righta[dl[head]][y] - 1;
	}
	for (int i = 1;i <= n;i++)
	{
		if (i >= ans && b[i] >= ans)
		{
			return 1;
		}
	}
	return 0;
}
int ans[2001];
signed main()
{
	n = read(), m = read(), q = read();
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			char xx;
			cin >> xx;
			if (xx == 'X')
			{
				a[i][j]++;
			}
		}
	}
	for (int i = 1;i <= q;i++)
	{
		ask[i][0] = read();
		ask[i][1] = read();
		a[ask[i][0]][ask[i][1]]++;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				continue;
			}
			if (i == 1 || j == m)
			{
				f[i][j] = 1;
				now = max(now, f[i][j]);
				continue;
			}
			f[i][j] = min(f[i - 1][j], f[i][j + 1]);
			if (!a[i - f[i][j]][j + f[i][j]])
			{
				f[i][j]++;
			}
			now = max(now, f[i][j]);
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			if (a[i][j])
			{
				lefta[i][j] = 0;
			}
			else
			{
				lefta[i][j] = lefta[i][j - 1] + 1;
			}
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				righta[i][j] = 0;
			}
			else
			{
				righta[i][j] = righta[i][j + 1] + 1;
			}
		}
	}
	for (int i = q - 1;i >= 1;i--)
	{
		ans[i + 1] = now;
		x = ask[i + 1][0];
		y = ask[i + 1][1];
		a[x][y]--;
		for (int j = 1;j <= m;j++)
		{
			if (a[x][j])
			{
				lefta[x][j] = 0;
			}
			else
			{
				lefta[x][j] = lefta[x][j - 1] + 1;
			}
		}
		for (int j = m;j >= 1;j--)
		{
			if (a[x][j])
			{
				righta[x][j] = 0;
			}
			else
			{
				righta[x][j] = righta[x][j + 1] + 1;
			}
		}
		while (check(now + 1))
		{
			now++;
		}
	}
	ans[1] = now;
	for (int i = 1;i <= q;i++)
	{
		printf("%lld\n", ans[i]);
	}
	system("pause");
	return 0;
}#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-')
		{
			f = -1;
		}
		c = getchar();
	}
	while (isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int f[3001][3001], lefta[3001][3001], righta[3001][3001];
int b[3001], dl[3001], ask[3001][2];
int a[3001][3001];
int n, m, q, now, x, y;
bool check(int ans)
{
	int head = 1, tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && lefta[dl[tail]][y] >= lefta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] = lefta[dl[head]][y];
	}
	head = 1;
	tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && righta[dl[tail]][y] >= righta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] += righta[dl[head]][y] - 1;
	}
	for (int i = 1;i <= n;i++)
	{
		if (i >= ans && b[i] >= ans)
		{
			return 1;
		}
	}
	return 0;
}
int ans[3001];
signed main()
{
	n = read(), m = read(), q = read();
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			char xx;
			cin >> xx;
			if (xx == 'X')
			{
				a[i][j]++;
			}
		}
	}
	for (int i = 1;i <= q;i++)
	{
		ask[i][0] = read();
		ask[i][1] = read();
		a[ask[i][0]][ask[i][1]]++;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				continue;
			}
			if (i == 1 || j == m)
			{
				f[i][j] = 1;
				now = max(now, f[i][j]);
				continue;
			}
			f[i][j] = min(f[i - 1][j], f[i][j + 1]);
			if (!a[i - f[i][j]][j + f[i][j]])
			{
				f[i][j]++;
			}
			now = max(now, f[i][j]);
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			if (a[i][j])
			{
				lefta[i][j] = 0;
			}
			else
			{
				lefta[i][j] = lefta[i][j - 1] + 1;
			}
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				righta[i][j] = 0;
			}
			else
			{
				righta[i][j] = righta[i][j + 1] + 1;
			}
		}
	}
	for (int i = q - 1;i >= 1;i--)
	{
		ans[i + 1] = now;
		x = ask[i + 1][0];
		y = ask[i + 1][1];
		a[x][y]--;
		for (int j = 1;j <= m;j++)
		{
			if (a[x][j])
			{
				lefta[x][j] = 0;
			}
			else
			{
				lefta[x][j] = lefta[x][j - 1] + 1;
			}
		}
		for (int j = m;j >= 1;j--)
		{
			if (a[x][j])
			{
				righta[x][j] = 0;
			}
			else
			{
				righta[x][j] = righta[x][j + 1] + 1;
			}
		}
		while (check(now + 1))
		{
			now++;
		}
	}
	ans[1] = now;
	for (int i = 1;i <= q;i++)
	{
		printf("%lld\n", ans[i]);
	}
	system("pause");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0;
	char ch=getchar();
	for(; ch<'0'||ch>'9'; ch=getchar());
	for(; ch>='0'&&ch<='9'; ch=getchar())
		x=(x<<1)+(x<<3)+(ch^48);
	return x;
}
const int maxn=2010;
int c[maxn][maxn],n,m;
char a[maxn][maxn];
inline void add(int x,int y)
{
	for(int i=x;i<=n;i+=i&-i)
		for(int j=y;j<=m;j+=j&-j)
			c[i][j]++;
}
inline int sum(int x,int y)
{
	int ans=0;
	for(int i=x;i;i-=i&-i)
		for(int j=y;j;j-=j&-j)
			ans+=c[i][j];
	return ans;
}
int check(int x)
{
	for(int i=x;i<=n;i++)
		for(int j=x;j<=m;j++)
		{
			int t=sum(i,j)-sum(i-x,j)-sum(i,j-x)+sum(i-x,j-x);
			if(!t)return 1;
		}
	return 0;
}
int main()
{
//	freopen("f.in","r",stdin);
//	freopen("f.out","w",stdin);
	n=read(),m=read();
	int q=read();
	for(int i=1;i<=n;i++)
	{
		scanf("%s",a[i]+1);
		for(int j=1;j<=m;j++)
			if(a[i][j]=='X')
				add(i,j);
	}
	for(int i=1;i<=q;i++)
	{
		int x=read(),y=read();
		if(a[x][y]=='.')
		{
			a[x][y]='X';
			add(x,y);
		}
		int l=1,r=min(m,n);
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(check(mid))l=mid+1;
			else r=mid-1;
		}
		printf("%d\n",l-1);
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define In inline
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-8;
const int maxn = 2e3 + 5;
inline ll read()
{
  ll ans = 0;
  char ch = getchar(), last = ' ';
  while(!isdigit(ch)) last = ch, ch = getchar();
  while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  if(last == '-') ans = -ans;
  return ans;
}
inline void write(ll x)
{
  if(x < 0) x = -x, putchar('-');
  if(x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}

char s[maxn];
int n, m, K;
int a[maxn][maxn], sum[maxn][maxn];

int c[maxn][maxn];
In int lowbit(int x) {return x & -x;}
In void update(int x, int y)
{
  for(int i = x; i <= n; i += lowbit(i))
    for(int j = y; j <= m; j += lowbit(j)) ++c[i][j];
}
In int query(int x, int y)
{
  int ret = 0;
  for(int i = x; i; i -= lowbit(i))
    for(int j = y; j; j -= lowbit(j)) ret += c[i][j];
  return ret;
}

struct Node
{
  int x, y, len;
  In bool operator < (const Node& oth)const
  {
    return len < oth.len;
  }
};
priority_queue<Node> q;

In bool judge(int x, int y, int mid, int flg)
{
  if(x - mid + 1 < 1 || y - mid + 1 < 1) return 0;
  if(flg) return query(x, y) - query(x, y - mid) - query(x - mid, y) + query(x - mid, y - mid) == 0;
  return sum[x][y] - sum[x][y - mid] - sum[x - mid][y] + sum[x - mid][y - mid] == 0;
}
In int solve(int x, int y, int len, bool flg)
{
  int L = 1, R = len;
  while(L < R)
    {
      int mid = (L + R + 1) >> 1;
      if(judge(x, y, mid, flg)) L = mid;
      else R = mid - 1;
    }
  return L;
}

In bool check(Node a, int x, int y)
{
  if(a.x >= x && a.x - a.len + 1 <= x && a.y >= y && a.y - a.len + 1 <= y) return 0;
  return 1;
}

int main()
{
  n = read(), m = read(), K = read();
  for(int i = 1; i <= n; ++i)
    {
      scanf("%s", s + 1);
      for(int j =  1; j <= m; ++j)
	{
	  a[i][j] = s[j] == 'X';
	  if(a[i][j]) update(i, j);
	  sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
	}
    }
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= m; ++j) // 以(i, j)为右下角
      if(!a[i][j]) q.push((Node){i, j, solve(i, j, n, 0)});
  for(int i = 1; i <= K; ++i)
    {
      int x = read(), y = read();
      a[x][y] = 1;
      update(x, y);
      while(1)
	{
	  Node tp = q.top();
	  if(check(tp, x, y)) break;
	  q.pop();
	  if(!a[tp.x][tp.y]) q.push((Node){tp.x, tp.y, solve(tp.x, tp.y, tp.len, 1)});
	}
      Node tp = q.top();
      write(tp.len), enter;
    }
  return 0;
}


#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#define LL long long
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define dwn(i,x,y) for(int i=(x);i>=(y);--i)
#define view(u,k) for(int k=fir[u];~k;k=nxt[k])
#define maxn 2007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return x*f;
}
void write(int x)
{
	char ch[20];int f=0;
	if(!x){putchar('0'),putchar('\n');return;}
	if(x<0)putchar('-'),x=-x;
	while(x)ch[++f]=x%10+'0',x/=10;
	while(f)putchar(ch[f--]);
	putchar('\n');
}
int qx[maxn],qy[maxn],q[maxn],hd,tl;
int col[maxn][maxn],ans,lmx[maxn][maxn],rmx[maxn][maxn],n,m,k,res[maxn],tmp[maxn],dp[maxn][maxn];
char s[maxn];
int jud(int yy)
{
	hd=1,tl=0;
	rep(i,1,n)
	{
		while(hd<=tl&&q[hd]<i-(ans+1)+1)hd++;
		while(hd<=tl&&lmx[q[tl]][yy]<=lmx[i][yy])tl--;
		q[++tl]=i;
		tmp[i]=yy-lmx[q[hd]][yy]+1;
	}
	hd=1,tl=0;
	rep(i,1,n)
	{
		while(hd<=tl&&q[hd]<i-(ans+1)+1)hd++;
		while(hd<=tl&&rmx[q[tl]][yy]>=rmx[i][yy])tl--;
		q[++tl]=i;
		tmp[i]+=rmx[q[hd]][yy]-yy;
	}
	rep(i,1,n)if(tmp[i]>=ans+1)return 1;
	return 0;
}
int main()
{
	n=read(),m=read(),k=read();
	rep(i,1,n)
	{
		scanf("%s",s+1);
		rep(j,1,m)if(s[j]!='.')col[i][j]=1;
	}
	rep(i,1,k)qx[i]=read(),qy[i]=read(),col[qx[i]][qy[i]]=1;
	rep(i,1,n)
	{
		rep(j,1,m)
		{
			if(col[i][j])continue;
			dp[i][j]=min(min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
			ans=max(dp[i][j],ans);
			if(j==1||col[i][j-1])lmx[i][j]=j;
			else lmx[i][j]=lmx[i][j-1];
		}
		dwn(j,m,1)
		{
			if(col[i][j])continue;
			if(j==m||col[i][j+1])rmx[i][j]=j;
			else rmx[i][j]=rmx[i][j+1];
		}
	}/*
	rep(i,1,n)
	{
		rep(j,1,n)cout<<col[i][j]<<" ";cout<<endl;
	}
	rep(i,1,n)
	{
		rep(j,1,n)cout<<dp[i][j]<<" ";cout<<endl;
	} */
	dwn(i,k,1)
	{
		res[i]=ans;
		col[qx[i]][qy[i]]=0;
		int nl=qy[i],nr=qy[i];
		while(nl-1>=1&&!col[qx[i]][nl-1])nl--;
		while(nr+1<=m&&!col[qx[i]][nr+1])nr++;
		rep(j,nl,nr)lmx[qx[i]][j]=nl,rmx[qx[i]][j]=nr;
		/*cout<<"lmx:"<<endl;
		rep(x1,1,n)
		{
			rep(x2,1,n)cout<<lmx[x1][x2]<<" ";cout<<endl;
		}
		cout<<"rmx:"<<endl;
		rep(x1,1,n)
		{
			rep(x2,1,n)cout<<rmx[x1][x2]<<" ";cout<<endl;
		} */
		while(jud(qy[i]))ans++;
	}
	rep(i,1,k)write(res[i]);
	return (0-0);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define MAXN 2005

using namespace std;

int n, m, q, sz, dp[MAXN][MAXN], up[MAXN][MAXN], ll[MAXN], rl[MAXN], qx[MAXN], qy[MAXN], ans[MAXN];
char map[MAXN][MAXN];

struct line{
	int fa[MAXN];
	int find(int x)
	{
		if(fa[x] == x) return x;
		return fa[x] = find(fa[x]);
	}
}l[MAXN], r[MAXN];

inline void del(int x, int y)
{
	l[x].fa[y] = l[x].find(y-1);
	r[x].fa[y] = r[x].find(y+1);
}

int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1; i <= n; i++)
		scanf("%s", map[i]+1);
	for(int i = 1; i <= q; i++)
		scanf("%d%d", &qx[i], &qy[i]), map[qx[i]][qy[i]] = 'X';
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m+1; j++)
			up[i][j] = i, l[i].fa[j] = j, r[i].fa[j] = j;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(map[i][j] == '.')
				up[i][j] = up[i-1][j], del(i, j);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(map[i][j] == '.')
			{
				dp[i][j] = min(dp[i-1][j-1]+1, min(i - up[i][j], j - l[i].find(j)));
				if(dp[i][j] > sz) sz = dp[i][j];
			}
	for(int v = q; v; v--)
	{
		ans[v] = sz;
		del(qx[v], qy[v]);
		for(int i = 1; i <= n; i++)
		{
			ll[i] = qy[v] - l[i].find(qy[v]);
			rl[i] = r[i].find(qy[v]) - qy[v];
		}
		for(int i = qx[v] + 1; i <= n; i++)
			ll[i] = min(ll[i], ll[i-1]), rl[i] = min(rl[i], rl[i-1]);
		for(int i = qx[v] - 1; i; i--)
			ll[i] = min(ll[i], ll[i+1]), rl[i] = min(rl[i], rl[i+1]);
		for(int i = 1; i <= qx[v]; i++)
			while(min(rl[i], rl[i+sz]) + min(ll[i], ll[i+sz]) - 1 > sz)
				sz++;
	}
	for(int i = 1; i <= q; i++)
		printf("%d\n", ans[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
int n,m,k,Ans;
int l1[maxn],r1[maxn],qx[maxn],qy[maxn],ans[maxn],dp[maxn][maxn];
char Map[maxn][maxn];

struct node
{
	int fa[maxn];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[maxn],r[maxn];

void Delete(int x,int y)
{
	l[x].fa[y] = l[x].findSet(y - 1);
	r[x].fa[y] = r[x].findSet(y + 1);
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 1; i <= n; i++)
		scanf("%s", Map[i]+1);
	for(int i = 1; i <= k; i++)
	{
		scanf("%d%d",&qx[i],&qy[i]);
		Map[qx[i]][qy[i]] = 'X';
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m+1; j++)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(Map[i][j] == '.')
				Delete(i, j);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(Map[i][j] == '.')
			{
				dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j],dp[i][j-1]))+1;
				Ans = max (Ans,dp[i][j]);
			}
	for (int j = k;j >= 1;-- j)
	{
		ans[j] = Ans;
		Delete (qx[j],qy[j]);
		for(int i = 1; i <= n; i++)
		{
			l1[i] = qy[j] - l[i].findSet(qy[j]);
			r1[i] = r[i].findSet(qy[j]) - qy[j];
		}
		for(int i = qx[j] + 1; i <= n; i++)
		{
			l1[i] = min(l1[i], l1[i - 1]);
			r1[i] = min(r1[i], r1[i - 1]);
		}
		for(int i = qx[j] - 1; i; i--)
		{
			l1[i] = min(l1[i], l1[i + 1]);
			r1[i] = min(r1[i], r1[i + 1]);
		}
		for(int i = 1; i <= qx[j]; i++)
			while(min(r1[i], r1[i + Ans]) + min(l1[i], l1[i + Ans]) - 1 > Ans)
				Ans++;
	}
	for(int i = 1; i <= k; i ++)
		printf("%d\n",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
#define cs const
using namespace std;
cs int N = 2e3 + 50, M = N * N;
int n, m, k;
char mp[N][N];
int up[N][N], dn[N][N], l[N][N], r[N][N];
int mx[M], v[M];
int A, B;
int subwork(int *a, int *b, int n){
	static int qa[N], qb[N]; int ha=1, ta=0, hb=1, tb=0;
	int ans = 0, l = 1, r = 0;
	for(int i=1; i<=n; i++){
		while(ha<=ta && a[qa[ta]]>=a[i]) --ta;
		while(hb<=tb && b[qb[tb]]>=b[i]) --tb;
		qa[++ta] = i; qb[++tb] = i;
		++r; int x=a[qa[ha]]+b[qb[hb]], y=r-l+1;
		if(a[qa[ha]]>0 && b[qb[hb]]>0) ans = max(ans, min(x,y));
		while(y>x){
			while(qa[ha]==l) ++ha;
			while(qb[hb]==l) ++hb; ++l;
			x=a[qa[ha]]+b[qb[hb]], y=r-l+1;
			if(a[qa[ha]]>0 && b[qb[hb]]>0) ans = max(ans, min(x,y));
		}
	} return ans;
}
void work(int x, int lx, int rx, int ly, int ry){
	if(lx==rx && ly==ry) return v[x]=mx[x]=(mp[lx][ly]=='.'),void();
	if(A && B && (!(lx<=A&&A<=rx) || !(ly<=B&&B<=ry))) return;
	if(rx-lx > ry-ly){
		int mid = (lx+rx) >> 1;
		work(x<<1, lx, mid, ly, ry);
		work(x<<1|1, mid+1, rx, ly, ry);
		static int a[N], b[N]; int nd = 0;
		for(int i=ly; i<=ry; i++) a[++nd]=mid-max(up[mid][i],lx-1), b[nd]=min(rx+1,dn[mid+1][i])-mid-1;
		v[x] = subwork(a, b, nd);
		mx[x] = max(v[x], max(mx[x<<1], mx[x<<1|1]));
//		cout<<"mdf "<<x<<" "<<lx<<" "<<rx<<" "<<ly<<" "<<ry<<" "<<mid<<" "<<v[x]<<" "<<mx[x]<<" "<<mx[x<<1]<<" "<<mx[x<<1|1]<<endl;
//		for(int i=1; i<=nd; i++) cout<<a[i]<<" "; cout<<endl;
//		for(int i=1; i<=nd; i++) cout<<b[i]<<" "; cout<<endl;
	} else{
		int mid = (ly+ry) >> 1;
		work(x<<1, lx, rx, ly, mid);
		work(x<<1|1, lx, rx, mid+1, ry);
		static int a[N], b[N]; int nd = 0;
		for(int i=lx; i<=rx; i++) a[++nd]=mid-max(ly-1,l[i][mid]), b[nd]=min(ry+1,r[i][mid+1])-mid-1;
		v[x] = subwork(a, b, nd);
		mx[x] = max(v[x], max(mx[x<<1], mx[x<<1|1]));
	}
}
void Ban(int x, int y){
	mp[x][y]='X';
	for(int j=y; j<=m; j++)
	if(mp[x][j]=='X') l[x][j]=j; else l[x][j]=l[x][j-1];
	for(int j=y; j>=1; j--)
	if(mp[x][j]=='X') r[x][j]=j; else r[x][j]=r[x][j+1];
	for(int i=x; i<=n; i++)
	if(mp[i][y]=='X') up[i][y]=i; else up[i][y]=up[i-1][y];
	for(int i=x; i>=1; i--)
	if(mp[i][y]=='X') dn[i][y]=i; else dn[i][y]=dn[i+1][y];
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1; i<=n; i++) scanf("%s",mp[i]+1);
	for(int i=1; i<=n; i++)
	for(int j=1; j<=m; j++)
	if(mp[i][j]=='X') l[i][j]=j; else l[i][j]=l[i][j-1];
	for(int i=1; i<=n; i++){
		r[i][m+1]=m+1;
		for(int j=m; j>=1; j--)
		if(mp[i][j]=='X') r[i][j]=j; else r[i][j]=r[i][j+1];
	}
	for(int j=1; j<=m; j++)
	for(int i=1; i<=n; i++)
	if(mp[i][j]=='X') up[i][j]=i; else up[i][j]=up[i-1][j];
	for(int j=1; j<=m; j++){
		dn[n+1][j]=n+1;
		for(int i=n; i>=1; i--)
		if(mp[i][j]=='X') dn[i][j]=i; else dn[i][j]=dn[i+1][j];
	}
	work(1,1,n,1,m);
	while(k--){
		scanf("%d%d",&A,&B); Ban(A,B);
		work(1,1,n,1,m); cout<<mx[1]<<'\n';
	} return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=2010,inf=2147483647;
int n,m,q,nn,x[N],y[N],ans[N],up[N][N<<2],dn[N][N<<2];char s[N][N];
void upu(int r,int x){up[r][x]=max(up[r][x<<1],up[r][x<<1|1]);}
void upd(int r,int x){dn[r][x]=min(dn[r][x<<1],dn[r][x<<1|1]);}
void updu(int r,int x,int v){x+=nn;up[r][x]=v;while(x>>=1)upu(r,x);}
void updd(int r,int x,int v){x+=nn;dn[r][x]=v;while(x>>=1)upd(r,x);}
int qryu(int r,int s,int t)
{
	int c=-inf;s+=nn-1;t+=nn+1;
	for(;s^t^1;s>>=1,t>>=1)
	{
		if(~s&1)c=max(c,up[r][s^1]);
		if(t&1)c=max(c,up[r][t^1]);
	}
	return c;
}
int qryd(int r,int s,int t)
{
	int c=inf;s+=nn-1;t+=nn+1;
	for(;s^t^1;s>>=1,t>>=1)
	{
		if(~s&1)c=min(c,dn[r][s^1]);
		if(t&1)c=min(c,dn[r][t^1]);
	}
	return c;
}
int calc(int x)
{
	int l=1,r=1,mxy,mny,res=0;
	for(;l<=m;l++)
	{
		if(l>r){r++;l--;continue;}
		mxy=qryu(x,l,r);mny=qryd(x,l,r);
		while(mxy!=inf&&mny!=-inf&&mny-mxy>=r-l&&r<m)
		{
			res=max(res,r-l+1);r++;
			mxy=max(mxy,up[x][r+nn]);
			mny=min(mny,dn[x][r+nn]);
		}
		if(r==m)
		{
			if(mxy!=inf&&mny!=-inf&&mny-mxy>=r-l)res=max(res,r-l+1);
			break;
		}
	}
	return res;
}
int main()
{
	scanf("%d%d%d",&n,&m,&q);ans[q]=0;
	for(nn=1;nn<=m;nn<<=1);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=q;i++){scanf("%d%d",&x[i],&y[i]);s[x[i]][y[i]]='X';}
	for(int i=1;i<=m;i++)s[0][i]=s[n+1][i]='X';
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)up[i][j+nn]=s[i][j]=='X'?inf:(s[i-1][j]=='X'?i:up[i-1][j+nn]);
	for(int i=n;i>=1;i--)for(int j=1;j<=m;j++)dn[i][j+nn]=s[i][j]=='X'?-inf:(s[i+1][j]=='X'?i:dn[i+1][j+nn]);
	for(int i=1;i<=n;i++)for(int j=nn-1;j;j--)upu(i,j),upd(i,j);
	for(int i=1;i<=n;i++)ans[q]=max(ans[q],calc(i));
	for(int i=q;i>1;i--)
	{
		s[x[i]][y[i]]='.';
		for(int j=x[i];j<=n;j++)if(s[j][y[i]]!='X')updu(j,y[i],s[j-1][y[i]]=='X'?j:up[j-1][y[i]+nn]);else break;
		for(int j=x[i];j;j--)if(s[j][y[i]]!='X')updd(j,y[i],s[j+1][y[i]]=='X'?j:dn[j+1][y[i]+nn]);else break;
		ans[i-1]=max(ans[i],calc(x[i]));
	}
	for(int i=1;i<=q;i++)printf("%d\n",ans[i]);
	return 0;
}


#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#define LL long long
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define dwn(i,x,y) for(int i=(x);i>=(y);--i)
#define view(u,k) for(int k=fir[u];~k;k=nxt[k])
#define maxn 2007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return x*f;
}
void write(int x)
{
	char ch[20];int f=0;
	if(!x){putchar('0'),putchar('\n');return;}
	if(x<0)putchar('-'),x=-x;
	while(x)ch[++f]=x%10+'0',x/=10;
	while(f)putchar(ch[f--]);
	putchar('\n');
}
int qx[maxn],qy[maxn],q[maxn],hd,tl;
int col[maxn][maxn],ans,lmx[maxn][maxn],rmx[maxn][maxn],n,m,k,res[maxn],tmp[maxn],dp[maxn][maxn];
char s[maxn];
int jud(int yy)
{
	hd=1,tl=0;
	rep(i,1,n)
	{
		while(hd<=tl&&q[hd]<i-(ans+1)+1)hd++;
		while(hd<=tl&&lmx[q[tl]][yy]<=lmx[i][yy])tl--;
		q[++tl]=i;
		if(i<ans+1)continue;
		tmp[i]=yy-lmx[q[hd]][yy]+1;
	}
	//cout<<"tmp1:"<<endl;
	//rep(i,1,n)cout<<tmp[i]<<" ";cout<<endl;
	hd=1,tl=0;
	rep(i,1,n)
	{
		while(hd<=tl&&q[hd]<i-(ans+1)+1)hd++;
		while(hd<=tl&&rmx[q[tl]][yy]>=rmx[i][yy])tl--;
		q[++tl]=i;//cout<<i<<" "<<q[hd]<<endl;
		if(i<ans+1)continue;
		tmp[i]+=rmx[q[hd]][yy]-yy;
	}
	//cout<<"tmp2:"<<endl;
	//rep(i,1,n)cout<<tmp[i]<<" ";cout<<endl;
	rep(i,ans+1,n)if(tmp[i]>=ans+1)return 1;
	return 0;
}
int main()
{
	n=read(),m=read(),k=read();
	rep(i,1,n)
	{
		scanf("%s",s+1);
		rep(j,1,m)if(s[j]!='.')col[i][j]=1;
	}
	rep(i,1,k)qx[i]=read(),qy[i]=read(),col[qx[i]][qy[i]]=1;
	rep(i,1,n)
	{
		rep(j,1,m)
		{
			if(col[i][j]){lmx[i][j]=j+1;continue;}
			dp[i][j]=min(min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
			ans=max(dp[i][j],ans);
			if(j==1||col[i][j-1])lmx[i][j]=j;
			else lmx[i][j]=lmx[i][j-1];
		}
		dwn(j,m,1)
		{
			if(col[i][j]){rmx[i][j]=j-1;continue;}
			if(j==m||col[i][j+1])rmx[i][j]=j;
			else rmx[i][j]=rmx[i][j+1];
		}
	}/*
	rep(i,1,n)
	{
		rep(j,1,m)cout<<col[i][j]<<" ";cout<<endl;
	}
	rep(i,1,n)
	{
		rep(j,1,m)cout<<dp[i][j]<<" ";cout<<endl;
	} */
	dwn(i,k,1)
	{
		res[i]=ans;
		col[qx[i]][qy[i]]=0;
		int nl=qy[i],nr=qy[i];
		while(nl-1>=1&&!col[qx[i]][nl-1])nl--;
		while(nr+1<=m&&!col[qx[i]][nr+1])nr++;
		rep(j,nl,nr)lmx[qx[i]][j]=nl,rmx[qx[i]][j]=nr;
		/*cout<<"lmx:"<<endl;
		rep(x1,1,n)
		{
			rep(x2,1,m)cout<<lmx[x1][x2]<<" ";cout<<endl;
		}
		cout<<"rmx:"<<endl;
		rep(x1,1,n)
		{
			rep(x2,1,m)cout<<rmx[x1][x2]<<" ";cout<<endl;
		} */
		while(jud(qy[i]))ans++;
	}
	rep(i,1,k)write(res[i]);
	return (0-0);
}


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

#define Int register int
#define MAXN 2010

int n,m,k,Ans;

int l1[MAXN],r1[MAXN],qx[MAXN],qy[MAXN],put[MAXN],dp[MAXN][MAXN];

char Map[MAXN][MAXN];

struct node
{
	int fa[MAXN];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[MAXN],r[MAXN];

void Delete (int x,int y)
{
	l[x].fa[y] = l[x].findSet (y - 1);
	r[x].fa[y] = r[x].findSet (y + 1);
}

void read (int &x)
{
	x = 0;char c = getchar ();int f = 1;
	while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}
	while (c >= '0' && c <= '9'){x = (x << 3) + (x << 1) + c - '0';c = getchar();}
	x *= f;return ;
}

void write (int x)
{
	if (x < 0){x = -x;putchar ('-');}
	if (x > 9) write (x / 10);
	putchar (x % 10 + '0');
}

signed main()
{
	read (n),read (m),read (k);
	for (Int i = 1;i <= n;++ i)
	 	scanf ("%s",Map[i] + 1);
	for (Int i = 1;i <= k;++ i)
	{
		read (qx[i]),read (qy[i]);
		Map[qx[i]][qy[i]] = 'X';
	}
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m + 1;++ j)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m;++ j)
			if (Map[i][j] == '.')
				Delete (i,j);
	for (Int i = 1;i <= n;++ i)
	{
		for (Int j = 1;j <= m;++ j)
		{
			if (Map[i][j] == '.')
			{
				dp[i][j] = min (dp[i][j - 1],min (dp[i - 1][j],dp[i - 1][j - 1])) + 1;
				Ans = max (Ans,dp[i][j]);
			}
		}
	}
	for (Int j = k;j >= 1;-- j)
	{
		put[j] = Ans;
		Delete (qx[j],qy[j]);
		for (Int i = 1;i <= n;++ i)
		{
			l1[i] = qy[j] - l[i].findSet (qy[j]);
			r1[i] = r[i].findSet(qy[j]) - qy[j];
		}
		for (Int i = qx[j] + 1;i <= n;++ i)
		{
			l1[i] = min (l1[i],l1[i - 1]);
			r1[i] = min (r1[i],r1[i - 1]);
		}
		for (Int i = qx[j] - 1;i >= 1;-- i)
		{
			l1[i] = min (l1[i],l1[i + 1]);
			r1[i] = min (r1[i],r1[i + 1]);
		}
		for (Int i = 1;i <= qx[i];++ i)
			while (min (l1[i],l1[i + Ans]) + min (r1[i],r1[i + Ans]) > Ans + 1)
				Ans ++;
	}
	for (Int i = 1;i <= k;++ i)
		write (put[i]),putchar ('\n');
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-')
		{
			f = -1;
		}
		c = getchar();
	}
	while (isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int f[4001][4001], lefta[4001][4001], righta[4001][4001];
int b[4001], dl[4001], ask[4001][2];
int a[4001][4001];
int n, m, q, now, x, y;
bool check(int ans)
{
	int head = 1, tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && lefta[dl[tail]][y] >= lefta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] = lefta[dl[head]][y];
	}
	head = 1;
	tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && righta[dl[tail]][y] >= righta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] += righta[dl[head]][y] - 1;
	}
	for (int i = 1;i <= n;i++)
	{
		if (i >= ans && b[i] >= ans)
		{
			return 1;
		}
	}
	return 0;
}
int ans[2001];
signed main()
{
	n = read(), m = read(), q = read();
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			char xx;
			cin >> xx;
			if (xx == 'X')
			{
				a[i][j]++;
			}
		}
	}
	for (int i = 1;i <= q;i++)
	{
		ask[i][0] = read();
		ask[i][1] = read();
		a[ask[i][0]][ask[i][1]]++;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				continue;
			}
			if (i == 1 || j == m)
			{
				f[i][j] = 1;
				now = max(now, f[i][j]);
				continue;
			}
			f[i][j] = min(f[i - 1][j], f[i][j + 1]);
			if (!a[i - f[i][j]][j + f[i][j]])
			{
				f[i][j]++;
			}
			now = max(now, f[i][j]);
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			if (a[i][j])
			{
				lefta[i][j] = 0;
			}
			else
			{
				lefta[i][j] = lefta[i][j - 1] + 1;
			}
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				righta[i][j] = 0;
			}
			else
			{
				righta[i][j] = righta[i][j + 1] + 1;
			}
		}
	}
	for (int i = q - 1;i >= 1;i--)
	{
		ans[i + 1] = now;
		x = ask[i + 1][0];
		y = ask[i + 1][1];
		a[x][y]--;
		for (int j = 1;j <= m;j++)
		{
			if (a[x][j])
			{
				lefta[x][j] = 0;
			}
			else
			{
				lefta[x][j] = lefta[x][j - 1] + 1;
			}
		}
		for (int j = m;j >= 1;j--)
		{
			if (a[x][j])
			{
				righta[x][j] = 0;
			}
			else
			{
				righta[x][j] = righta[x][j + 1] + 1;
			}
		}
		while (check(now + 1))
		{
			now++;
		}
	}
	ans[1] = now;
	for (int i = 1;i <= q;i++)
	{
		printf("%lld\n", ans[i]);
	}
	system("pause");
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define In inline
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-8;
const int maxn = 2e3 + 5;
inline ll read()
{
  ll ans = 0;
  char ch = getchar(), last = ' ';
  while(!isdigit(ch)) last = ch, ch = getchar();
  while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  if(last == '-') ans = -ans;
  return ans;
}
inline void write(ll x)
{
  if(x < 0) x = -x, putchar('-');
  if(x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}

char s[maxn];
int n, m, K;
int a[maxn][maxn], sum[maxn][maxn];

int c[maxn][maxn];
In int lowbit(int x) {return x & -x;}
In void update(int x, int y)
{
  for(int i = x; i <= n; i += lowbit(i))
    for(int j = y; j <= m; j += lowbit(j)) ++c[i][j];
}
In int query(int x, int y)
{
  int ret = 0;
  for(int i = x; i; i -= lowbit(i))
    for(int j = y; j; j -= lowbit(j)) ret += c[i][j];
  return ret;
}

struct Node
{
  int x, y, len;
  In bool operator < (const Node& oth)const
  {
    return len < oth.len;
  }
};
priority_queue<Node> q;

In bool judge(int x, int y, int mid, int flg)
{
  if(x - mid + 1 < 1 || y - mid + 1 < 1) return 0;
  if(flg) return query(x, y) - query(x, y - mid) - query(x - mid, y) + query(x - mid, y - mid) == 0;
  return sum[x][y] - sum[x][y - mid] - sum[x - mid][y] + sum[x - mid][y - mid] == 0;
}
In int solve(int x, int y, int len, bool flg)
{
  int L = 1, R = len;
  while(L < R)
    {
      int mid = (L + R + 1) >> 1;
      if(judge(x, y, mid, flg)) L = mid;
      else R = mid - 1;
    }
  return L;
}

In bool check(Node a, int x, int y)
{
  if(a.x >= x && a.x - a.len + 1 <= x && a.y >= y && a.y - a.len + 1 <= y) return 0;
  return 1;
}

int main()
{
  n = read(), m = read(), K = read();
  for(int i = 1; i <= n; ++i)
    {
      scanf("%s", s + 1);
      for(int j =  1; j <= m; ++j)
	{
	  a[i][j] = s[j] == 'X';
	  if(a[i][j]) update(i, j);
	  sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
	}
    }
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= m; ++j) // 以(i, j)为右下角
      if(!a[i][j]) q.push((Node){i, j, solve(i, j, n, 0)});
  for(int i = 1; i <= K; ++i)
    {
      int x = read(), y = read();
      if(!a[x][y])
	{
	  a[x][y] = 1;
	  update(x, y);
	  while(1)
	    {
	      Node tp = q.top();
	      if(check(tp, x, y)) break;
	      q.pop();
	      if(!a[tp.x][tp.y]) q.push((Node){tp.x, tp.y, solve(tp.x, tp.y, tp.len, 1)});
	    }
	}
      Node tp = q.top();
      write(tp.len), enter;
    }
  return 0;
}


//                             In the name of God
//                     😳😳😄😄😝😝😁😁😎😎😛😛😄😄😮😮
#include <bits/stdc++.h>
#define For(i,x,y) for(__typeof(y)i=(x)-((x)>(y));i!=(y)-((x)>(y));i+=1-2*((x)>(y)))
#define rep(i , n) for(int (i) = (1); (i) <= (n); ++(i))
inline int in() { int x; scanf("%d", &x); return x; }
#define _ ios::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin() , x.end()
#define REP(i , c) for(auto i : c)
#define sz(x) (((int)x.size()))
#define mp make_pair
#define pb push_back
#define pp pop_back
#define S second
#define F first

//#define cerr if(0)cerr
//#define int long long

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OS;
*/
constexpr int inf = 1e9 + 7, base = 541;
constexpr int mod = 1e9+7, N = 2222 + 7;

typedef pair<int,int> pii;
typedef long double dd;
typedef long long ll;

int b[N][N];
vector<pii> v;
int dp[N][N], n, m, q, r[N][N], l[N][N];

int DP() {
    int mx = 0;
    rep(i, n) rep(j, m){
        if(b[i][j]) continue;
        dp[i][j] = min(min(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]) + 1;
        mx = max(mx, dp[i][j]);
    }
    return mx;
}

void mkl(int x) {
    rep(i, m)
        if(b[x][i])
            l[x][i] = 0;
        else
            l[x][i] = l[x][i-1]+1;
}
void mkr(int x) {
    for(int i = m; i >= 1; i--)
    if(b[x][i])
        r[x][i] = 0;
    else
        r[x][i] = r[x][i+1]+1;
}

int an[N], ans;

deque< pii > o[2];

void add(int x, int y, int z){
    while (o[z].size() && o[z].back().F > y)
        o[z].pop_back();
    while (o[z].size() && (x-o[z].front().S > ans))
        o[z].pop_front();
    o[z].push_back({y, x});
}

int32_t main(){
    cin >> n >> m >> q;
    rep(i, n) rep(j, m){
        char c; cin >> c;
        if( c == 'X')
            b[i][j] = 1;
    }
    rep(i, q){
        int x = in(), y = in();
        //cerr << x << y << endl;
        v.pb({x, y});
        b[x][y] = 1;
    }
    ans = DP();
    rep(i, n) mkr(i), mkl(i);

    an[q] = ans;

    for(int k = q-1; k >= 1; k--) {
        int x = v.back().F, y = v.back().S; v.pp();
        b[x][y] = 0;
        mkl(x), mkr(x);
        while (true) {
            bool b = 1;
            rep(i, n) {
                add(i,l[i][y],0);
                add(i,r[i][y],1);
                if(i > ans){
                    if (o[0].front().F + o[1].front().F - 1 > ans){
                    //    cerr << x << ' ' << y << ' ' << o[1].front().S << ' ' << o[0].front().S <<' '<< o[1].front().F << ' ' << o[0].front().F  << endl;
                        ans++;
                        b = 0;
                        break;
                    }
                }
            }
            o[0].clear();
            o[1].clear();
            if(b)
                break;
        }
        an[k] = ans;

    }
    rep(i, q) cout << an[i] << endl;
}


//                             In the name of God
//                     😳😳😄😄😝😝😁😁😎😎😛😛😄😄😮😮
#include <bits/stdc++.h>
#define For(i,x,y) for(__typeof(y)i=(x)-((x)>(y));i!=(y)-((x)>(y));i+=1-2*((x)>(y)))
#define rep(i , n) for(int (i) = (1); (i) <= (n); ++(i))
inline int in() { int x; scanf("%d", &x); return x; }
#define _ ios::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin() , x.end()
#define REP(i , c) for(auto i : c)
#define sz(x) (((int)x.size()))
#define mp make_pair
#define pb push_back
#define pp pop_back
#define S second
#define F first

//#define cerr if(0)cerr
//#define int long long

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OS;
*/
constexpr int inf = 1e9 + 7, base = 541;
constexpr int mod = 1e9+7, N = 2222 + 7;

typedef pair<int,int> pii;
typedef long double dd;
typedef long long ll;

int b[N][N];
vector<pii> v;
int dp[N][N], n, m, q, r[N][N], l[N][N];

int DP() {
    int mx = 0;
    rep(i, n) rep(j, m){
        if(b[i][j]) continue;
        dp[i][j] = min(min(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]) + 1;
        mx = max(mx, dp[i][j]);
    }
    return mx;
}

void mkl(int x) {
    rep(i, n)
        if(b[x][i])
            l[x][i] = 0;
        else
            l[x][i] = l[x][i-1]+1;
}
void mkr(int x) {
    for(int i = n; i >= 1; i--)
    if(b[x][i])
        r[x][i] = 0;
    else
        r[x][i] = r[x][i+1]+1;
}

int an[N], ans;

deque< pii > o[2];

void add(int x, int y, int z){
    while (o[z].size() && o[z].back().F >= y)
        o[z].pop_back();
    while (o[z].size() && (x-o[z].front().S > ans))
        o[z].pop_back();
    o[z].push_back({y, x});
}

int32_t main(){
    cin >> n >> m >> q;
    rep(i, n) rep(j, m){
        char c; cin >> c;
        if( c == 'X')
            b[i][j] = 1;
    }
    rep(i, q){
        int x = in(), y = in();
        //cerr << x << y << endl;
        v.pb({x, y});
        b[x][y] = 1;
    }
    ans = DP();
    rep(i, n) mkr(i), mkl(i);

    an[q] = ans;

    for(int k = q-1; k >= 1; k--) {
        int x = v.back().F, y = v.back().S; v.pp();
        b[x][y] = 0;
        mkl(x), mkr(x);
        while (true) {
            bool b = 1;
            rep(i, n) {
                add(i,l[i][y],0);
                add(i,r[i][y],1);
                if(i > ans){
                    if (o[0].front().F + o[1].front().F - 1 > ans){
                        cerr << x << ' ' << y << ' ' << o[1].front().S << ' ' << o[0].front().S <<' '<< o[1].front().F << ' ' << o[0].front().F  << endl;
                        ans++;
                        b = 0;
                        break;
                    }
                }
            }
            o[0].clear();
            o[1].clear();
            if(b)
                break;
        }
        an[k] = ans;

    }
    rep(i, q) cout << an[i] << endl;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n,m,kk,a[N][N],qx[N],qy[N],up[N][N],dn[N][N],dp[N][N],ans[N];
char s[N][N];
bool check(int x,int mid)
{
	deque<int> q1,q2;
	for (int i = 1;i < mid;i++)
	{
		while (!q1.empty() && up[x][q1.back()] >= up[x][i]) q1.pop_back();
		while (!q2.empty() && dn[x][q2.back()] >= dn[x][i]) q2.pop_back();
		q1.push_back(i);q2.push_back(i);
	}
	for (int i = mid;i <= m;i++)
	{
		while (!q1.empty() && q1.front() <= i - mid) q1.pop_front();
		while (!q2.empty() && q2.front() <= i - mid) q2.pop_front();
		while (!q1.empty() && up[x][q1.back()] >= up[x][i]) q1.pop_back();
		while (!q2.empty() && dn[x][q2.back()] >= dn[x][i]) q2.pop_back();
		q1.push_back(i);q2.push_back(i);
		if (up[x][q1.front()] + dn[x][q2.front()] - 1 >= mid) return 1;
	}
	return 0;
}
int main ()
{
	ios::sync_with_stdio(false);
	cin >> n >> m >> kk;
	for (int i = 1;i <= n;i++)
	{
		cin >> (s[i] + 1);
		for (int j = 1;j <= m;j++) a[i][j] = (s[i][j] == 'X');
	}
	for (int i = 1;i <= kk;i++) { cin >> qx[i] >> qy[i];a[qx[i]][qy[i]] = 1; }
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			up[i][j] = a[i][j] ? 0 : up[i - 1][j] + 1;
	for (int i = n;i > 0;--i)
		for (int j = 1;j <= m;j++)
			dn[i][j] = a[i][j] ? 0 : dn[i + 1][j] + 1;
	int mx = 0;
	for (int i = 1;i <= n;i++) mx = max(mx,dp[i][1] = !a[i][1]);
	for (int i = 1;i <= m;i++) mx = max(mx,dp[1][i] = !a[1][i]);
	for (int i = 2;i <= n;i++)
		for (int j = 2;j <= m;j++)
			dp[i][j] = a[i][j] ? 0 :
				min({dp[i - 1][j - 1],dp[i - 1][j],dp[i][j - 1]}) + 1,
			mx = max(mx,dp[i][j]);
	ans[kk] = mx;
	for (int k = kk;k > 0;--k)
	{
		a[qx[k]][qy[k]] = 0;
		for (int i = 1;i <= n;i++) up[i][qy[k]] = a[i][qy[k]] ? 0 : up[i - 1][qy[k]] + 1;
		for (int i = n;i > 0;--i) dn[i][qy[k]] = a[i][qy[k]] ? 0 : dn[i + 1][qy[k]] + 1;
		int l = 1,r = min(n,m),aa = 0;
		while (l <= r)
		{
			int mid = (l + r) >> 1;
			if (check(qx[k],mid)) aa = mid,l = mid + 1;
			else r = mid - 1;
		}
		ans[k - 1] = mx = max(aa,mx);
	}
	for (int i = 1;i <= kk;i++) cout << ans[i] << endl;
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<set>
#include<queue>
#include<vector>
#include<map>
#define rep(i,a,n) for(int i = a;i <= n;i++)
#define per(i,n,a) for(int i = n;i >= a;i--)
#define enter putchar('\n')
#define fr friend inline
#define y1 poj
#define mp make_pair
#define pr pair<int,int>
#define fi first
#define sc second
#define pb push_back
#define lowbit(x) x & (-x)

using namespace std;
typedef long long ll;
const int M = 2005;
const int INF = 1000000009;
const double eps = 1e-7;

int read()
{
    int ans = 0,op = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
	if(ch == '-') op = -1;
	ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
	ans *= 10;
	ans += ch - '0';
	ch = getchar();
    }
    return ans * op;
}

struct node
{
   int x,y;
}a[M];

int n,m,k,le[M][M],ri[M][M],q[M],dp[M][M],cur,ans[M],kx,ky,head,tail,tmp[M];
bool pd[M][M];
char s[M];

void init()
{
   rep(i,1,n)
   rep(j,1,m)
   {
      if(pd[i][j]) dp[i][j] = 0;
      else dp[i][j] = min(dp[i-1][j-1],min(dp[i][j-1],dp[i-1][j])) + 1;
      cur = max(cur,dp[i][j]);
   }
   rep(i,1,n)
   rep(j,1,m) pd[i][j] ? le[i][j] = 0 : le[i][j] = le[i][j-1] + 1;
   rep(i,1,n)
   per(j,m,1) pd[i][j] ? ri[i][j] = 0 : ri[i][j] = ri[i][j+1] + 1;
}

bool check(int d)
{
   head = 1,tail = 0;
   rep(i,1,n)
   {
      while(head <= tail && le[q[tail]][ky] >= le[i][ky]) tail--;
      q[++tail] = i;
      while(head <= tail && q[head] <= i - d) head++;
      tmp[i] = le[q[head]][ky];
   }
   head = 1,tail = 0;
   rep(i,1,n)
   {
      while(head <= tail && ri[q[tail]][ky] >= ri[i][ky]) tail--;
      q[++tail] = i;
      while(head <= tail && q[head] <= i - d) head++;
      tmp[i] += ri[q[head]][ky] - 1;
   }
   rep(i,d,n) if(tmp[i] >= d) return 1;
   return 0;
}

int main()
{
   n = read(),m = read(),k = read();
   rep(i,1,n)
   {
      scanf("%s",s+1);
      rep(j,1,m) if(s[j] == 'X') pd[i][j] = 1;
   }
   rep(i,1,k) a[i].x = read(),a[i].y = read(),pd[a[i].x][a[i].y] = 1;
   init();
   per(i,k-1,1)
   {
      ans[i+1] = cur;
      kx = a[i+1].x,ky = a[i+1].y,pd[kx][ky] = 0;
      rep(j,1,m) pd[kx][j] ? le[kx][j] = 0 : le[kx][j] = le[kx][j-1] + 1;
      per(j,m,1) pd[kx][j] ? ri[kx][j] = 0 : ri[kx][j] = ri[kx][j+1] + 1;
      while(check(cur+1)) cur++;
   }
   ans[1] = cur;
   rep(i,1,k) printf("%d\n",ans[i]);
   return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<deque>
#include<set>
#include<utility>

using namespace std;

const int MAXN = 2e3 + 4;
int n, m, q;
set<pair<int, int>>	st;
multiset<int>	ss, tt;
char c[MAXN][MAXN];
int d[MAXN][MAXN], dn[MAXN][MAXN], ri[MAXN][MAXN], ans[MAXN];
pair<int, int>	query[MAXN];

pair<int, int>	get(int x, int y){
	auto it = st.lower_bound({x, y});
	int l, r;

	if (it != st.end() && it->first == x)
		r = it->second;
	else
		r = m;

	it = st.upper_bound({x, y});
	if (it != st.begin()){
		it--;
		if (it->first == x)	l = it->second + 1;
		else	l = 0;
	}
	else	l = 0;
	return	{l, r};
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++){
		string temp;	cin >> temp;
		for (int j = 0; j < m; j++){
			c[i][j] = temp[j];
			if (c[i][j] == 'X')	st.insert({i, j});
		}
	}
	for (int i = 0; i < q; i++){
		cin >> query[i].first >> query[i].second;
		query[i].first--, query[i].second--;
		st.insert(query[i]);
		c[query[i].first][query[i].second] = 'X';
	}

	int cur = 0;
	for (int i = n - 1; i >= 0; i--)
		for (int j = m - 1; j >= 0; j--)
			if (c[i][j] != 'X'){
				dn[i][j] = 1 + dn[i + 1][j];
				ri[i][j] = 1 + ri[i][j + 1];

				d[i][j] = d[i][j + 1] + 1;
				while (d[i][j]){
					if (dn[i][j] >= d[i][j] && ri[i + d[i][j] - 1][j] >= d[i][j])	break;
					d[i][j]--;
				}
				cur = max(cur, d[i][j]);
			}

	for (int i = q - 1; i >= 0; i--){
		pair<int, int>	v = query[i];
		st.erase(v);
		c[v.first][v.second] = '.';
		ans[i] = cur;

		bool fl = 1;
		while (cur < min(n, m) && fl){
			fl = 0;
			ss.clear();
			tt.clear();
			cur++;

			for (int j = max(0, v.first - cur + 1); j < v.first + cur && j < n; j++){
				pair<int, int>	temp = get(j, v.second);
				ss.insert(temp.first);
				tt.insert(temp.second);
				if (ss.size() > cur)
					ss.erase(ss.find(get(j - cur, v.second).first)), tt.erase(tt.find(get(j - cur, v.second).second));

				if (ss.size() == cur){
					auto it = ss.end();	it--;	int maxi = *it;
					it = tt.begin();	int mini = *it;
					if (mini - maxi >= cur){
						fl = 1;
						cout << j << " " << mini << " " << maxi << "\n";
						break;
					}
				}
			}

			if (!fl)	cur--;
		}
	}

	for (int i = 0; i < q; i++)
		cout << ans[i] << "\n";
	return	0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<deque>
#include<set>
#include<utility>

using namespace std;

const int MAXN = 2e3 + 4;
int n, m, q;
set<pair<int, int>>	st;
multiset<int>	ss, tt;
char c[MAXN][MAXN];
int d[MAXN][MAXN], dn[MAXN][MAXN], ri[MAXN][MAXN], ans[MAXN];
pair<int, int>	query[MAXN];

pair<int, int>	get(int x, int y){
	auto it = st.lower_bound({x, y});
	int l, r;

	if (it != st.end() && it->first == x)
		r = it->second;
	else
		r = m;

	it = st.upper_bound({x, y});
	if (it != st.begin()){
		it--;
		if (it->first == x)	l = it->second + 1;
		else	l = 0;
	}
	else	l = 0;
	return	{l, r};
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++){
		string temp;	cin >> temp;
		for (int j = 0; j < m; j++){
			c[i][j] = temp[j];
			if (c[i][j] == 'X')	st.insert({i, j});
		}
	}
	for (int i = 0; i < q; i++){
		cin >> query[i].first >> query[i].second;
		query[i].first--, query[i].second--;
		st.insert(query[i]);
		c[query[i].first][query[i].second] = 'X';
	}

	int cur = 0;
	for (int i = n - 1; i >= 0; i--)
		for (int j = m - 1; j >= 0; j--)
			if (c[i][j] != 'X'){
				dn[i][j] = 1 + dn[i + 1][j];
				ri[i][j] = 1 + ri[i][j + 1];

				d[i][j] = d[i][j + 1] + 1;
				while (d[i][j]){
					if (dn[i][j] >= d[i][j] && ri[i + d[i][j] - 1][j] >= d[i][j])	break;
					d[i][j]--;
				}
				cur = max(cur, d[i][j]);
			}

	for (int i = q - 1; i >= 0; i--){
		pair<int, int>	v = query[i];
		st.erase(v);
		c[v.first][v.second] = '.';
		ans[i] = cur;

		bool fl = 1;
		while (cur < min(n, m) && fl){
			fl = 0;
			ss.clear();
			tt.clear();
			cur++;

			for (int j = max(0, v.first - cur + 1); j < v.first + cur && j < n; j++){
				pair<int, int>	temp = get(j, v.second);
				ss.insert(temp.first);
				tt.insert(temp.second);
				if (ss.size() > cur)
					ss.erase(ss.find(get(j - cur, v.second).first)), tt.erase(tt.find(get(j - cur, v.second).second));

				if (ss.size() == cur){
					auto it = ss.end();	it--;	int maxi = *it;
					it = tt.begin();	int mini = *it;
					if (mini - maxi >= cur){
						fl = 1;
						break;
					}
				}
			}

			if (!fl)	cur--;
		}
	}

	for (int i = 0; i < q; i++)
		cout << ans[i] << "\n";
	return	0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 2010
int n,m,k,Ans;
int l1[MAXN],r1[MAXN],qx[MAXN],qy[MAXN],ans[MAXN],dp[MAXN][MAXN];
char Map[MAXN][MAXN];

struct node
{
	int fa[MAXN];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[MAXN],r[MAXN];

void Delete(int x,int y)
{
	l[x].fa[y] = l[x].findSet(y - 1);
	r[x].fa[y] = r[x].findSet(y + 1);
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 1; i <= n; i++)
		scanf("%s", Map[i]+1);
	for(int i = 1; i <= k; i++)
	{
		scanf("%d%d",&qx[i],&qy[i]);
		Map[qx[i]][qy[i]] = 'X';
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m+1; j++)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(Map[i][j] == '.')
				Delete(i, j);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(Map[i][j] == '.')
			{
				dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j],dp[i][j-1]))+1;
				Ans = max (Ans,dp[i][j]);
			}
	for (int j = k;j >= 1;-- j)
	{
		ans[j] = Ans;
		Delete (qx[j],qy[j]);
		for(int i = 1; i <= n; i++)
		{
			l1[i] = qy[j] - l[i].findSet(qy[j]);
			r1[i] = r[i].findSet(qy[j]) - qy[j];
		}
		for(int i = qx[j] + 1; i <= n; i++)
		{
			l1[i] = min(l1[i], l1[i - 1]);
			r1[i] = min(r1[i], r1[i - 1]);
		}
		for(int i = qx[j] - 1; i; i--)
		{
			l1[i] = min(l1[i], l1[i + 1]);
			r1[i] = min(r1[i], r1[i + 1]);
		}
		for(int i = 1; i <= qx[j]; i++)
			while(min(r1[i], r1[i + Ans]) + min(l1[i], l1[i + Ans]) - 1 > Ans)
				Ans++;
	}
	for(int i = 1; i <= k; i ++)
		printf("%d\n",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-')
		{
			f = -1;
		}
		c = getchar();
	}
	while (isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int f[2001][2001], lefta[2001][2001], righta[2001][2001];
int b[2001], dl[2001], ask[2001][2];
int a[2001][2001];
int n, m, q, now, x, y;
bool check(int ans)
{
	int head = 1, tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && lefta[dl[tail]][y] >= lefta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] = lefta[dl[head]][y];
	}
	head = 1;
	tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && righta[dl[tail]][y] >= righta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] += righta[dl[head]][y] - 1;
	}
	for (int i = 1;i <= n;i++)
	{
		if (i >= ans && b[i] >= ans)
		{
			return 1;
		}
	}
	return 0;
}
int ans[2001];
signed main()
{
	n = read(), m = read(), q = read();
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			char xx;
			cin >> xx;
			if (xx == 'X')
			{
				a[i][j]++;
			}
		}
	}
	for (int i = 1;i <= q;i++)
	{
		ask[i][0] = read();
		ask[i][1] = read();
		a[ask[i][0]][ask[i][1]]++;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				continue;
			}
			if (i == 1 || j == m)
			{
				f[i][j] = 1;
				now = max(now, f[i][j]);
				continue;
			}
			f[i][j] = min(f[i - 1][j], f[i][j + 1]);
			if (!a[i - f[i][j]][j + f[i][j]])
			{
				f[i][j]++;
			}
			now = max(now, f[i][j]);
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			if (a[i][j])
			{
				lefta[i][j] = 0;
			}
			else
			{
				lefta[i][j] = lefta[i][j - 1] + 1;
			}
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				righta[i][j] = 0;
			}
			else
			{
				righta[i][j] = righta[i][j + 1] + 1;
			}
		}
	}
	for (int i = q - 1;i >= 1;i--)
	{
		ans[i + 1] = now;
		x = ask[i + 1][0];
		y = ask[i + 1][1];
		a[x][y]--;
		for (int j = 1;j <= m;j++)
		{
			if (a[x][j])
			{
				lefta[x][j] = 0;
			}
			else
			{
				lefta[x][j] = lefta[x][j - 1] + 1;
			}
		}
		for (int j = m;j >= 1;j--)
		{
			if (a[x][j])
			{
				righta[x][j] = 0;
			}
			else
			{
				righta[x][j] = righta[x][j + 1] + 1;
			}
		}
		while (check(now + 1))
		{
			now++;
		}
	}
	ans[1] = now;
	for (int i = 1;i <= q;i++)
	{
		printf("%lld\n", ans[i]);
	}
	system("pause");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
int n,m,q;
int sz;
int dp[maxn][maxn];
int up[maxn][maxn];
int ll[maxn];
int rl[maxn];
int qx[maxn];
int qy[maxn];
int ans[maxn];
char mp[maxn][maxn];

struct node{
	int fa[maxn];
	int find(int x)
	{
		if(fa[x] == x)return x;
		else return fa[x] = find(fa[x]);
	}
}l[maxn],r[maxn];

void del(int x,int y)
{
	l[x].fa[y] = l[x].find(y - 1);
	r[x].fa[y] = r[x].find(y + 1);
}

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i = 1; i <= n; i++)
		scanf("%s", mp[i]+1);
	for(int i = 1; i <= q; i++)
	{
		scanf("%d%d",&qx[i],&qy[i]);
		mp[qx[i]][qy[i]] = 'X';
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m+1; j++)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(mp[i][j] == '.')
				del(i, j);
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(mp[i][j] == '.')
			{
				dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j],dp[i][j-1]))+1;
				sz = max (sz,dp[i][j]);
			}
		}
	}
	for (int j = q;j >= 1;-- j)
	{
		ans[j] = sz;
		del (qx[j],qy[j]);
		for(int i = 1; i <= n; i++)
		{
			ll[i] = qy[j] - l[i].find(qy[j]);
			rl[i] = r[i].find(qy[j]) - qy[j];
		}
		for(int i = qx[j] + 1; i <= n; i++)
		{
			ll[i] = min(ll[i], ll[i - 1]);
			rl[i] = min(rl[i], rl[i - 1]);
		}
		for(int i = qx[j] - 1; i; i--)
		{
			ll[i] = min(ll[i], ll[i + 1]);
			rl[i] = min(rl[i], rl[i + 1]);
		}
		for(int i = 1; i <= qx[j]; i++)
			while(min(rl[i], rl[i + sz]) + min(ll[i], ll[i + sz]) - 1 > sz)
				sz++;
	}
	for(int i = 1; i <= q; i ++)printf("%d\n",ans[i]);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

#define Int register int
#define MAXN 2010

int n,m,k,Ans;

int l1[MAXN],r1[MAXN],qx[MAXN],qy[MAXN],put[MAXN],dp[MAXN][MAXN];

char Map[MAXN][MAXN];

struct node
{
	int fa[MAXN];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[MAXN],r[MAXN];

void Delete (int x,int y)
{
	l[x].fa[y] = l[x].findSet (y - 1);
	r[x].fa[y] = r[x].findSet (y + 1);
}

void read (int &x)
{
	x = 0;char c = getchar ();int f = 1;
	while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}
	while (c >= '0' && c <= '9'){x = (x << 3) + (x << 1) + c - '0';c = getchar();}
	x *= f;return ;
}

void write (int x)
{
	if (x < 0){x = -x;putchar ('-');}
	if (x > 9) write (x / 10);
	putchar (x % 10 + '0');
}

signed main()
{
	read (n),read (m),read (k);
	for (Int i = 1;i <= n;++ i)
	 	scanf ("%s",Map[i] + 1);
	for (Int i = 1;i <= k;++ i)
	{
		read (qx[i]),read (qy[i]);
		Map[qx[i]][qy[i]] = 'X';
	}
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m + 1;++ j)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	for (Int i = 1;i <= n;++ i)
		for (Int j = 1;j <= m;++ j)
			if (Map[i][j] == '.')
				Delete (i,j);
	for (Int i = 1;i <= n;++ i)
	{
		for (Int j = 1;j <= m;++ j)
		{
			if (Map[i][j] == '.')
			{
				dp[i][j] = min (dp[i][j - 1],min (dp[i - 1][j],dp[i - 1][j - 1])) + 1;
				Ans = max (Ans,dp[i][j]);
			}
		}
	}
	for (int j = k;j >= 1;-- j)
	{
		put[j] = Ans;
		Delete (qx[j],qy[j]);
		for(int i = 1; i <= n; i++)
		{
			l1[i] = qy[j] - l[i].findSet(qy[j]);
			r1[i] = r[i].findSet(qy[j]) - qy[j];
		}
		for(int i = qx[j] + 1; i <= n; i++)
		{
			l1[i] = min(l1[i], l1[i - 1]);
			r1[i] = min(r1[i], r1[i - 1]);
		}
		for(int i = qx[j] - 1; i; i--)
		{
			l1[i] = min(l1[i], l1[i + 1]);
			r1[i] = min(r1[i], r1[i + 1]);
		}
		for(int i = 1; i <= qx[j]; i++)
			while(min(r1[i], r1[i + Ans]) + min(l1[i], l1[i + Ans]) - 1 > Ans)
				Ans ++;
	}
	for (Int i = 1;i <= k;++ i)
		write (put[i]),putchar ('\n');
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
int n,m,k;
int Ans;
int dp[maxn][maxn];
int l1[maxn];
int r1[maxn];
int qx[maxn];
int qy[maxn];
int ans[maxn];
char Map[maxn][maxn];

struct node
{
	int fa[maxn];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[maxn],r[maxn];

void Delete(int x,int y)
{
	l[x].fa[y] = l[x].findSet(y - 1);
	r[x].fa[y] = r[x].findSet(y + 1);
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 1; i <= n; i++)
		scanf("%s", Map[i]+1);
	for(int i = 1; i <= k; i++)
	{
		scanf("%d%d",&qx[i],&qy[i]);
		Map[qx[i]][qy[i]] = 'X';
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m+1; j++)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(Map[i][j] == '.')
				Delete(i, j);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(Map[i][j] == '.')
			{
				dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j],dp[i][j-1]))+1;
				Ans = max (Ans,dp[i][j]);
			}
	for (int j = k;j >= 1;-- j)
	{
		ans[j] = Ans;
		Delete (qx[j],qy[j]);
		for(int i = 1; i <= n; i++)
		{
			l1[i] = qy[j] - l[i].findSet(qy[j]);
			r1[i] = r[i].findSet(qy[j]) - qy[j];
		}
		for(int i = qx[j] + 1; i <= n; i++)
		{
			l1[i] = min(l1[i], l1[i - 1]);
			r1[i] = min(r1[i], r1[i - 1]);
		}
		for(int i = qx[j] - 1; i; i--)
		{
			l1[i] = min(l1[i], l1[i + 1]);
			r1[i] = min(r1[i], r1[i + 1]);
		}
		for(int i = 1; i <= qx[j]; i++)
			while(min(r1[i], r1[i + Ans]) + min(l1[i], l1[i + Ans]) - 1 > Ans)
				Ans++;
	}
	for(int i = 1; i <= k; i ++)
		printf("%d\n",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define Int register int
const int maxn = 2e3 + 10;

int n,m,k,Ans;
int l1[maxn],r1[maxn],qx[maxn],qy[maxn],ans[maxn],dp[maxn][maxn];
char Map[maxn][maxn];

struct node
{
	int fa[maxn];
	int findSet (int x)
	{
		if (x == fa[x]) return x;
		else return fa[x] = findSet (fa[x]);
	}
}l[maxn],r[maxn];

void Delete(int x,int y)
{
	l[x].fa[y] = l[x].findSet(y - 1);
	r[x].fa[y] = r[x].findSet(y + 1);
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for (Int i = 1; i <= n; i++)
		scanf("%s", Map[i]+1);
	for (Int i = 1; i <= k; i++)
	{
		scanf ("%d%d",&qx[i],&qy[i]);
		Map[qx[i]][qy[i]] = 'X';
	}
	for (Int i = 1; i <= n; i++)
	{
		for (Int j = 1; j <= m+1; j++)
		{
			l[i].fa[j] = j;
			r[i].fa[j] = j;
		}
	}
	for (Int i = 1; i <= n; i++)
		for (Int j = 1; j <= m; j++)
			if (Map[i][j] == '.')
				Delete(i, j);
	for (Int i = 1; i <= n; i++)
		for (Int j = 1; j <= m; j++)
			if (Map[i][j] == '.')
			{
				dp[i][j] = min(dp[i - 1][j - 1],min(dp[i - 1][j],dp[i][j - 1])) + 1;
				Ans = max (Ans,dp[i][j]);
			}
	for (Int j = k;j >= 1;-- j)
	{
		ans[j] = Ans;
		Delete (qx[j],qy[j]);
		for(Int i = 1; i <= n; i++)
		{
			l1[i] = qy[j] - l[i].findSet(qy[j]);
			r1[i] = r[i].findSet(qy[j]) - qy[j];
		}
		for(Int i = qx[j] + 1; i <= n; i++)
		{
			l1[i] = min(l1[i], l1[i - 1]);
			r1[i] = min(r1[i], r1[i - 1]);
		}
		for(Int i = qx[j] - 1; i; i--)
		{
			l1[i] = min(l1[i], l1[i + 1]);
			r1[i] = min(r1[i], r1[i + 1]);
		}
		for(Int i = 1; i <= qx[j]; i++)
			while (min(r1[i],r1[i + Ans]) + min(l1[i],l1[i + Ans]) > Ans + 1)
				Ans ++;
	}
	for(Int i = 1; i <= k; i ++)
		printf("%d\n",ans[i]);
	return 0;
}


//#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<iomanip>
#include<cctype>
#include<cstdio>
#include<deque>
#include<utility>
#include<cmath>
#include<ctime>
#include<cstring>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define INF 1000000000
#define ll long long
#define db double
#define mod 1000000007
#define ull unsigned long long
#define un unsigned
#define P 1000000007ull
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
	int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const int MAXN=2010;
int n,m,k,cnt;
char a[MAXN][MAXN];
struct wy{int x,y;}t[MAXN];
int l[MAXN][MAXN],r[MAXN][MAXN];
int f[MAXN][MAXN],ans[MAXN];
int L,R,q[MAXN],w[MAXN];
inline int check(int d,int y)
{
	L=1;R=0;
	for(int i=1;i<=n;++i)
	{
		while(L<=R&&l[q[R]][y]>=l[i][y])--R;
		q[++R]=i;
		while(L<=R&&q[L]<=i-d)++L;
		w[i]=l[q[L]][y];
	}
	L=1;R=0;
	for(int i=1;i<=n;++i)
	{
		while(L<=R&&r[q[R]][y]>=r[i][y])--R;
		q[++R]=i;
		while(L<=R&&q[L]<=i-d)++L;
		w[i]+=r[q[L]][y]-1;
	}
	for(int i=d;i<=n;++i)if(w[i]>=d)return 1;
	return 0;
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();m=read();k=read();
	for(int i=1;i<=n;++i)scanf("%s",a[i]+1);
	for(int i=1;i<=k;++i)
	{
		int x,y;
		x=read();y=read();
		t[i]=(wy){x,y};
		a[x][y]='X';
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			if(a[i][j]=='X')
			{
				l[i][j]=0;f[i][j]=0;
				continue;
			}
			l[i][j]=l[i][j-1]+1;
			f[i][j]=min(f[i][j-1],min(f[i-1][j-1],f[i-1][j]))+1;
			cnt=max(cnt,f[i][j]);
		}
		for(int j=m;j;--j)
		{
			if(a[i][j]=='X')r[i][j]=0;
			else r[i][j]=r[i][j+1]+1;
		}
	}
	for(int i=k-1;i;--i)
	{
		ans[i+1]=cnt;
		int x=t[i+1].x;
		int y=t[i+1].y;
		a[x][y]='.';
		for(int j=1;j<=m;++j)l[x][j]=a[x][j]=='X'?0:l[x][j-1]+1;
		for(int j=m;j;--j)r[x][j]=a[x][j]=='X'?0:r[x][j+1]+1;
		while(check(cnt+1,y))++cnt;
	}
	ans[1]=cnt;
	for(int i=1;i<=k;++i)printf("%d\n",ans[i]);
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a), i##ed = (b); i <= i##ed; i++)
#define per(i, a, b) for(int i = (a), i##ed = (b); i >= i##ed; i--)
using namespace std;
const int N = 2010;
int n, m, k, mx = 0;
bool g[N][N];
struct T {
	int lx[N], rx[N], sz;
}; T tr[N * 4];
struct P { int x, y; }; P q[N]; int ans[N];

inline int Min(const int &x, const int &y) { return x < y ? x : y; }
struct MN {
	int mn[N], pre[N], suf[N];
	void build(int len) {
		for(int i = 1; i <= m; i += len) { // i -> i + len - 1
			pre[i] = mn[i];
			rep(j, i + 1, Min(i + len - 1, m))
				pre[j] = Min(pre[j - 1], mn[j]);
			suf[Min(i + len - 1, m)] = mn[Min(i + len - 1, m)];
			per(j, Min(i + len - 1, m) - 1, i)
				suf[j] = Min(suf[j + 1], mn[j]);
		}
	}
	inline int ask(int l, int r) { return Min(suf[l], pre[r]); }
}; MN lf, rf;

bool check(int u, int len) {
	rep(i, 1, m) lf.mn[i] = tr[u * 2].rx[i], rf.mn[i] = tr[u * 2 + 1].lx[i];
	lf.build(len), rf.build(len);
	rep(i, 1, m - len + 1)
		if(lf.ask(i, i + len - 1) + rf.ask(i, i + len - 1) >= len) return 1;
	return 0;
}
void pushup(int u) {
	tr[u].sz = tr[u * 2].sz + tr[u * 2 + 1].sz;
	rep(i, 1, m) {
		tr[u].lx[i] = tr[u * 2].lx[i];
		if(tr[u * 2].lx[i] == tr[u * 2].sz)
			tr[u].lx[i] += tr[u * 2 + 1].lx[i];
		tr[u].rx[i] = tr[u * 2 + 1].rx[i];
		if(tr[u * 2 + 1].rx[i] == tr[u * 2 + 1].sz)
			tr[u].rx[i] += tr[u * 2].rx[i];
	}
	for(; mx < tr[u].sz && check(u, mx + 1); ++mx);
}
void build(int u, int l, int r) {
	if(l >= r) {
		tr[u].sz = 1;
		rep(i, 1, m) tr[u].lx[i] = tr[u].rx[i] = g[l][i];
		if(!mx) rep(i, 1, m) if(g[l][i]) { mx = 1; break; }
		return ;
	}
	int mid = (l + r) >> 1;
	build(u * 2, l, mid), build(u * 2 + 1, mid + 1, r), pushup(u);
}
void mdy(int u, int l, int r, int x) {
	if(l >= r) {
		rep(i, 1, m) tr[u].lx[i] = tr[u].rx[i] = g[l][i];
		if(!mx) rep(i, 1, m) if(g[l][i]) { mx = 1; break; }
		return ;
	}
	int mid = (l + r) >> 1;
	x <= mid ? mdy(u * 2, l, mid, x) : mdy(u * 2 + 1, mid + 1, r, x);
	pushup(u);
}
int main() {
	scanf("%d%d%d", &n, &m, &k);
	rep(i, 1, n) rep(j, 1, m) {
		char c; for(c = getchar(); c != 'X' && c != '.'; c = getchar());
		g[i][j] = (c == '.' ? 1 : 0);
	}
	rep(i, 1, k) scanf("%d%d", &q[i].x, &q[i].y), g[q[i].x][q[i].y] = 0;
	build(1, 1, n);
	per(i, k, 1) g[q[i].x][q[i].y] = 1, ans[i] = mx, mdy(1, 1, n, q[i].x);
	rep(i, 1, k) printf("%d\n", ans[i]);
	return 0;
}


//code by lba hahaha
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<set>
#include<queue>
#include<vector>
#include<map>
#define rep(i,a,n) for(int i = a;i <= n;i++)
#define per(i,n,a) for(int i = n;i >= a;i--)
#define enter putchar('\n')
#define fr friend inline
#define y1 poj
#define mp make_pair
#define pr pair<int,int>
#define fi first
#define sc second
#define pb push_back
#define lowbit(x) x & (-x)

using namespace std;
typedef long long ll;
const int M = 2005;
const int INF = 1000000009;
const double eps = 1e-7;

int read()
{
    int ans = 0,op = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
    if(ch == '-') op = -1;
    ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
    ans *= 10;
    ans += ch - '0';
    ch = getchar();
    }
    return ans * op;
}

struct node
{
   int x,y;
}a[M];

int n,m,k,le[M][M],ri[M][M],q[M],dp[M][M],cur,ans[M],kx,ky,head,tail,tmp[M];
bool pd[M][M];
char s[M];

void init()
{
   rep(i,1,n)
   rep(j,1,m)
   {
      if(pd[i][j]) dp[i][j] = 0;
      else dp[i][j] = min(dp[i-1][j-1],min(dp[i][j-1],dp[i-1][j])) + 1;
      cur = max(cur,dp[i][j]);
   }
   rep(i,1,n)
   rep(j,1,m) pd[i][j] ? le[i][j] = 0 : le[i][j] = le[i][j-1] + 1;
   rep(i,1,n)
   per(j,m,1) pd[i][j] ? ri[i][j] = 0 : ri[i][j] = ri[i][j+1] + 1;
}

bool check(int d)
{
   head = 1,tail = 0;
   rep(i,1,n)
   {
      while(head <= tail && le[q[tail]][ky] >= le[i][ky]) tail--;
      q[++tail] = i;
      while(head <= tail && q[head] <= i - d) head++;
      tmp[i] = le[q[head]][ky];
   }
   head = 1,tail = 0;
   rep(i,1,n)
   {
      while(head <= tail && ri[q[tail]][ky] >= ri[i][ky]) tail--;
      q[++tail] = i;
      while(head <= tail && q[head] <= i - d) head++;
      tmp[i] += ri[q[head]][ky] - 1;
   }
   rep(i,d,n) if(tmp[i] >= d) return 1;
   return 0;
}

int main()
{
   n = read(),m = read(),k = read();
   rep(i,1,n)
   {
      scanf("%s",s+1);
      rep(j,1,m) if(s[j] == 'X') pd[i][j] = 1;
   }
   rep(i,1,k) a[i].x = read(),a[i].y = read(),pd[a[i].x][a[i].y] = 1;
   init();
   per(i,k-1,1)
   {
      ans[i+1] = cur;
      kx = a[i+1].x,ky = a[i+1].y,pd[kx][ky] = 0;
      rep(j,1,m) pd[kx][j] ? le[kx][j] = 0 : le[kx][j] = le[kx][j-1] + 1;
      per(j,m,1) pd[kx][j] ? ri[kx][j] = 0 : ri[kx][j] = ri[kx][j+1] + 1;
      while(check(cur+1)) cur++;
   }
   ans[1] = cur;
   rep(i,1,k) printf("%d\n",ans[i]);
   return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 2010;
int n, m, k;
int tmp[N];
int q[N];
int map[N][N];
int dp[N][N];
int leftNum[N][N];
int rightNum[N][N];

// 各个点的解
struct node
{
    int x, y, res;
}ans[N];

/*判断解是否可行*/
bool check(int x, int y)
{
    memset(tmp,0,sizeof(tmp));

    int head = 1, tail = 0;
    for(int i = 1;i <= n; i++){
        while(head<=tail && leftNum[q[tail]][y] >= leftNum[i][y])
            tail--;
        q[++tail]=i;
        while(q[head]<=i-x)
            head++;
        tmp[i]+=leftNum[q[head]][y];
    }

    head=1; tail=0;
    for(int i = 1; i <= n; i++){
        while(head <= tail && rightNum[q[tail]][y] >= rightNum[i][y])
            tail--;
        q[++tail]=i;
        while(q[head]<=i-x)
            head++;
        tmp[i]+= rightNum[q[head]][y] - 1;
    }

    for(int i = x; i <= n; i++){
        if(tmp[i] >= x)
            return true;
    }

    return false;
}

int main()
{
    /* 输入及初始化 */
    scanf("%d%d%d",&n, &m, &k);
    char s[N];
    for(int i = 1; i <= n; i++){
        scanf("%s", s+1);
        // 为空则为1，反之为0
        for(int j = 1; j <= m; j++){
            map[i][j] = (s[j] == '.');
        }
    }
    // 得到停车完成的状态
    for(int i = 1; i <= k; i++){
        scanf("%d%d", &ans[i].x, &ans[i].y);
        map[ans[i].x][ans[i].y] = 0;
    }

    /* DP */
    for(int i = 1; i <= n; i++){
        for(int j = m; j >= 1; j--){
            // 只看空车位状态
            if(!map[i][j]) continue;

            if(i == 1 || j == m){
                dp[i][j] = 1;
                ans[k].res = max(ans[k].res,1);
                continue;
            }

            dp[i][j] = min(dp[i - 1][j], dp[i][j + 1]);
            if(map[i - dp[i][j]][j + dp[i][j]]){
                dp[i][j]++;
            }
            ans[k].res=max(ans[k].res, dp[i][j]);
        }
    }
    // 能向左扩展的宽度
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            leftNum[i][j] = map[i][j] * (leftNum[i][j - 1] + 1);
        }
    }
    // 能向右扩展的宽度
    for(int i = 1; i <= n; i++){
        for(int j = m; j >= 1; j--){
            rightNum[i][j] = map[i][j] * (rightNum[i][j + 1] + 1);
        }
    }

    // 向上出车求解
    int times = ans[k].res;
    for(int i = k; i >= 2; i--){
        ans[i].res = times;
        int x = ans[i].x;
        int y = ans[i].y;

        map[x][y]=1;
        for(int j = 1; j <= m; j++){
            leftNum[x][j] = map[x][j] * (leftNum[x][j - 1] + 1);
        }
        for(int j = m; j >= 1; j--){
            rightNum[x][j] = map[x][j] * (rightNum[x][j + 1] + 1);
        }
        while(check(times + 1, y)){
            // 如果可行则更新
            times++;
        }
    }
    ans[1].res = times;
    for(int i = 1; i <= k; i++){
        printf("%d\n", ans[i].res);
    }

    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-')
		{
			f = -1;
		}
		c = getchar();
	}
	while (isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int f[2001][2001], lefta[2001][2001], righta[2001][2001];
int b[2001], dl[2001], ask[2001][2];
int a[2001][2001];
int n, m, q, now, x, y;
bool check(int ans)
{
	int head = 1, tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && lefta[dl[tail]][y] >= lefta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] = lefta[dl[head]][y];
	}
	head = 1;
	tail = 0;
	for (int i = 1;i <= n;i++)
	{
		while (head <= tail && righta[dl[tail]][y] >= righta[i][y])
		{
			tail--;
		}
		tail++;
		dl[tail] = i;
		while (dl[head] <= i - ans)
		{
			head++;
		}
		b[i] += righta[dl[head]][y] - 1;
	}
	for (int i = 1;i <= n;i++)
	{
		if (i >= ans && b[i] >= ans)
		{
			return 1;
		}
	}
	return 0;
}
int ans[2001];
signed main()
{
	n = read(), m = read(), q = read();
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			char xx;
			cin >> xx;
			if (xx == 'X')
			{
				a[i][j]++;
			}
		}
	}
	for (int i = 1;i <= q;i++)
	{
		ask[i][0] = read();
		ask[i][1] = read();
		a[ask[i][0]][ask[i][1]]++;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				continue;
			}
			if (i == 1 || j == m)
			{
				f[i][j] = 1;
				now = max(now, f[i][j]);
				continue;
			}
			f[i][j] = min(f[i - 1][j], f[i][j + 1]);
			if (!a[i - f[i][j]][j + f[i][j]])
			{
				f[i][j]++;
			}
			now = max(now, f[i][j]);
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= m;j++)
		{
			if (a[i][j])
			{
				lefta[i][j] = 0;
			}
			else
			{
				lefta[i][j] = lefta[i][j - 1] + 1;
			}
		}
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= 1;j--)
		{
			if (a[i][j])
			{
				righta[i][j] = 0;
			}
			else
			{
				righta[i][j] = righta[i][j + 1] + 1;
			}
		}
	}
	for (int i = q;i >= 1;i--)
	{
		ans[i + 1] = now;
		x = ask[i + 1][0];y = ask[i + 1][1];
		a[x][y]--;
		for (int j = 1;j <= m;j++)
		{
			if (a[x][j])
			{
				lefta[x][j] = 0;
			}
			else
			{
				lefta[x][j] = lefta[x][j - 1] + 1;
			}
		}
		for (int j = m;j >= 1;j--)
		{
			if (a[x][j])
			{
				righta[x][j] = 0;
			}
			else
			{
				righta[x][j] = righta[x][j + 1] + 1;
			}
		}
		while (check(now + 1))
		{
			now++;
		}
	}
	ans[1] = now;
	for (int i = 1;i <= q;i++)
	{
		printf("%lld\n", ans[i]);
	}
	system("pause");
	return 0;
}


#include <cstdio>
#include <cstring>

#define Int register int

const int MAX = 2000;
int n, m, k, x[MAX + 5], y[MAX + 5] = {}, Ans[MAX + 5] = {};
int UpL[MAX + 5][MAX + 5] = {}, DnL[MAX + 5][MAX + 5] = {};
int Head, Tail, Q[MAX + 5] = {}, MaxL[MAX + 5] = {};
int F[MAX + 5][MAX + 5] = {};
bool mp[MAX + 5][MAX + 5] = {};

inline int Min ( const int a, const int b ) { return a < b ? a : b; }

inline int Max ( const int a, const int b ) { return a > b ? a : b; }

inline void Prepare () {
	for ( Int i = 1; i <= n; ++ i ) {
		for ( Int j = 1; j <= m; ++ j ) {
			Ans[k] |= ! mp[i][j];
			UpL[i][j] = mp[i][j] ? 0 : UpL[i - 1][j] + 1;
			DnL[n - i + 1][j] = mp[n - i + 1][j] ? 0 : DnL[n - i + 2][j] + 1;
		}
	}
	for ( Int i = 1; i <= n; ++ i ) {
		for ( Int j = 1; j <= m; ++ j ) {
			F[i][j] = mp[i][j] ? 0 : Min ( F[i - 1][j - 1], Min ( F[i - 1][j], F[i][j - 1] ) ) + 1;
			Ans[k] = Max ( Ans[k], F[i][j] );
		}
	}
}

inline bool Check ( const int L, const int x ) {
	Head = 1, Tail = 0, memset ( MaxL, 0, sizeof MaxL );
	for ( Int i = 1; i <= m; ++ i ) {
		while ( Head <= Tail && UpL[x][Q[Tail]] >= UpL[x][i] ) -- Tail;
		Q[++ Tail] = i;
		while ( Q[Head] <= i - L ) ++ Head;
		MaxL[i] += UpL[x][Q[Head]];
	}
	Head = 1, Tail = 0;
	for ( Int i = 1; i <= m; ++ i ) {
		while ( Head <= Tail && DnL[x][Q[Tail]] >= DnL[x][i] ) -- Tail;
		Q[++ Tail] = i;
		while ( Q[Head] <= i - L ) ++ Head;
		MaxL[i] += DnL[x][Q[Head]];
	}
	for ( Int i = L; i <= m; ++ i ) {
		if ( MaxL[i] > L ) {
			return true;
		}
	}
	return false;
}

inline int BS ( const int K ) {
	int l = Ans[K], r = Min ( n, m ), mid;
	while ( l + 1 < r ) {
		mid = l + r >> 1;
		if ( Check ( mid, x[K] ) ) l = mid;
		else r = mid - 1;
	}
	return Check ( r, x[K] ) ? r : l;
}

inline void Work () {
	scanf ( "%d %d %d", &n, &m, &k );
	for ( Int i = 1; i <= n; ++ i ) {
		for ( Int j = 1; j <= m; ++ j ) {
			char s = getchar ();
			if ( s ^ '.' && s ^ 'X' ) { -- j; continue; }
			mp[i][j] = s == 'X';
		}
	}
	for ( Int i = 1; i <= k; ++ i ) scanf ( "%d %d", &x[i], &y[i] ), mp[x[i]][y[i]] = true;
	Prepare ();
	for ( Int t = k, l, r, mid; t; -- t ) {
		mp[x[t]][y[t]] = false;
		for ( Int i = 1; i <= n; ++ i ) {
			UpL[i][y[t]] = mp[i][y[t]] ? 0 : UpL[i - 1][y[t]] + 1;
			DnL[n - i + 1][y[t]] = mp[n - i + 1][y[t]] ? 0 : DnL[n - i + 2][y[t]] + 1;
		}
		Ans[t - 1] = BS ( t );
	}
	for ( Int i = 1; i <= k; ++ i ) printf ( "%d\n", Ans[i] );
}

int main () {
	Work ();
	return 0;
}


#include<bits/stdc++.h>
#define cs const
using namespace std;
cs int N = 2e3 + 50, M = N * N;
int n, m, k;
char mp[N][N];
int up[N][N], dn[N][N], l[N][N], r[N][N];
int mx[M], v[M];
int A, B;
int subwork(int *a, int *b, int n){
	static int qa[N], qb[N]; int ha=1, ta=0, hb=1, tb=0;
	int ans = 0, l = 1, r = 0;
//	for(int i=1; i<=n; i++) cout<<a[i]<<" "; cout<<endl;
//	for(int i=1; i<=n; i++) cout<<b[i]<<" "; cout<<endl;
	for(int i=1; i<=n; i++){
		while(ha<=ta && a[qa[ta]]>=a[i]) --ta;
		while(hb<=tb && b[qb[tb]]>=b[i]) --tb;
		qa[++ta] = i; qb[++tb] = i;
		++r; int x=a[qa[ha]]+b[qb[hb]]-1, y=r-l+1;
//		cout<<l<<" "<<r<<" "<<x<<" "<<y<<" "<<a[qa[ha]]<<" "<<b[qb[hb]]<<endl;
		ans = max(ans, min(x,y));
		while(y>x){
			while(qa[ha]==l) ++ha;
			while(qb[hb]==l) ++hb; ++l;
			x=a[qa[ha]]+b[qb[hb]], y=r-l+1;
			ans = max(ans, min(x,y));
		}
	} return ans;
}
void work(int x, int lx, int rx, int ly, int ry){
	if(lx>rx || ly>ry) return;
	if(A && B && (!(lx<=A&&A<=rx) || !(ly<=B&&B<=ry))) return;
	if(rx-lx > ry-ly){
		int mid = (lx+rx) >> 1;
		work(x<<1, lx, mid-1, ly, ry);
		work(x<<1|1, mid+1, rx, ly, ry);
		static int a[N], b[N]; int nd = 0;
		for(int i=ly; i<=ry; i++) a[++nd]=mid-up[mid][i], b[nd]=dn[mid][i]-mid;
		v[x] = subwork(a, b, nd);
		mx[x] = max(v[x], max(mx[x<<1], mx[x<<1|1]));
	} else{
		int mid = (ly+ry) >> 1;
		work(x<<1, lx, rx, ly, mid-1);
		work(x<<1|1, lx, rx, mid+1, ry);
		static int a[N], b[N]; int nd = 0;
		for(int i=lx; i<=rx; i++) a[++nd]=mid-l[i][mid], b[nd]=r[i][mid]-mid;
		v[x] = subwork(a, b, nd);
		mx[x] = max(v[x], max(mx[x<<1], mx[x<<1|1]));
	}
}
void Ban(int x, int y){
	mp[x][y]='X';
	for(int j=y; j<=m; j++)
	if(mp[x][j]=='X') l[x][j]=j; else l[x][j]=l[x][j-1];
	for(int j=y; j>=1; j--)
	if(mp[x][j]=='X') r[x][j]=j; else r[x][j]=r[x][j+1];
	for(int i=x; i<=n; i++)
	if(mp[i][y]=='X') up[i][y]=i; else up[i][y]=up[i-1][y];
	for(int i=x; i>=1; i--)
	if(mp[i][y]=='X') dn[i][y]=i; else dn[i][y]=dn[i+1][y];
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1; i<=n; i++) scanf("%s",mp[i]+1);
	for(int i=1; i<=n; i++)
	for(int j=1; j<=m; j++)
	if(mp[i][j]=='X') l[i][j]=j; else l[i][j]=l[i][j-1];
	for(int i=1; i<=n; i++){
		r[i][m+1]=m+1;
		for(int j=m; j>=1; j--)
		if(mp[i][j]=='X') r[i][j]=j; else r[i][j]=r[i][j+1];
	}
	for(int j=1; j<=m; j++)
	for(int i=1; i<=n; i++)
	if(mp[i][j]=='X') up[i][j]=i; else up[i][j]=up[i-1][j];
	for(int j=1; j<=m; j++){
		dn[n+1][j]=n+1;
		for(int i=n; i>=1; i--)
		if(mp[i][j]=='X') dn[i][j]=i; else dn[i][j]=dn[i+1][j];
	}
	work(1,1,n,1,m);
	while(k--){
		scanf("%d%d",&A,&B); Ban(A,B);
		work(1,1,n,1,m); cout<<mx[1]<<'\n';
	} return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N=2005;
int n,m,kk,a[N][N],qx[N],qy[N],up[N][N],dn[N][N],dp[N][N],ans[N];
char s[N][N];
bool check(int x,int mid)
{
    deque<int >q1,q2;
    for(int i=1; i<mid; i++)
    {
        while(!q1.empty() && up[x][q1.back()]>=up[x][i])
        {
            q1.pop_back();
        }
        while(!q2.empty() && dn[x][q2.back()]>=dn[x][i])
        {
            q2.pop_back();
        }
        q1.push_back(i);
        q2.push_back(i);
    }
    for(int i=mid; i<=m; i++)
    {
        while(!q1.empty() && q1.front()<=i-mid)
        {
            q1.pop_front();
        }
        while(!q2.empty() && q2.front()<=i-mid)
        {
            q2.pop_front();
        }
        while(!q1.empty() && up[x][q1.back()]>=up[x][i])
        {
            q1.pop_back();
        }
        while(!q2.empty() && dn[x][q2.back()]>=dn[x][i])
        {
            q2.pop_back();
        }
        q1.push_back(i);
        q2.push_back(i);
        if(up[x][q1.front()]+dn[x][q2.front()]-1>=mid)return 1;
    }
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>kk;
    for(int i=1; i<=n; i++)
    {
        cin>>(s[i]+1);
        for(int j=1; j<=m; j++)
        {
            a[i][j]=(s[i][j]=='X');
        }
    }
    for(int i=1; i<=kk; i++)
    {
        cin>>qx[i]>>qy[i];
        a[qx[i]][qy[i]]=1;
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            up[i][j]=a[i][j]?0:up[i-1][j]+1;
        }
    }
    for(int i=n; i>0; --i)
    {
        for(int j=1; j<=m; j++)
        {
            dn[i][j]=a[i][j]?0:dn[i+1][j]+1;
        }
    }
    int mx=0;
    for(int i=1; i<=n; i++)mx=max(mx,dp[i][1]=!a[i][1]);
    for(int i=1; i<=m; i++)mx=max(mx,dp[1][i]=!a[1][i]);
    for(int i=2; i<=n; i++)
    {
        for(int j=2; j<=m; j++)
        {
            dp[i][j]=a[i][j]?0:min({dp[i-1][j-1],dp[i-1][j],dp[i][j-1]})+1;
            mx=max(mx,dp[i][j]);
        }
    }
    ans[kk]=mx;
    for(int k=kk; k>0; --k)
    {
        a[qx[k]][qy[k]]=0;
        for(int i=1; i<=n; i++)
        {
            up[i][qy[k]]=a[i][qy[k]]?0:up[i-1][qy[k]]+1;
        }
        for(int i=n; i>0; --i)
        {
            dn[i][qy[k]]=a[i][qy[k]]?0:dn[i+1][qy[k]]+1;
        }
        int l=1,r=min(n,m),aa=0;
        while(l<=r)
        {
            int mid=(l+r)>>1;
            if(check(qx[k],mid))aa=mid,l=mid+1;
            elser=mid-1;
        }
        ans[k-1]=mx=max(aa,mx);
    }
    for(int i=1; i<=kk; i++)
    {
        cout<<ans[i]<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int N=2005;
int n,m,kk,a[N][N],qx[N],qy[N],up[N][N],dn[N][N],dp[N][N],ans[N];
char s[N][N];
bool check(int x,int mid)
{
    deque<int >q1,q2;
    for(int i=1; i<mid; i++)
    {
        while(!q1.empty() && up[x][q1.back()]>=up[x][i])
        {
            q1.pop_back();
        }
        while(!q2.empty() && dn[x][q2.back()]>=dn[x][i])
        {
            q2.pop_back();
        }
        q1.push_back(i);
        q2.push_back(i);
    }
    for(int i=mid; i<=m; i++)
    {
        while(!q1.empty() && q1.front()<=i-mid)
        {
            q1.pop_front();
        }
        while(!q2.empty() && q2.front()<=i-mid)
        {
            q2.pop_front();
        }
        while(!q1.empty() && up[x][q1.back()]>=up[x][i])
        {
            q1.pop_back();
        }
        while(!q2.empty() && dn[x][q2.back()]>=dn[x][i])
        {
            q2.pop_back();
        }
        q1.push_back(i);
        q2.push_back(i);
        if(up[x][q1.front()]+dn[x][q2.front()]-1>=mid)return 1;
    }
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>kk;
    for(int i=1; i<=n; i++)
    {
        cin>>(s[i]+1);
        for(int j=1; j<=m; j++)
        {
            a[i][j]=(s[i][j]=='X');
        }
    }
    for(int i=1; i<=kk; i++)
    {
        cin>>qx[i]>>qy[i];
        a[qx[i]][qy[i]]=1;
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            up[i][j]=a[i][j]?0:up[i-1][j]+1;
        }
    }
    for(int i=n; i>0; --i)
    {
        for(int j=1; j<=m; j++)
        {
            dn[i][j]=a[i][j]?0:dn[i+1][j]+1;
        }
    }
    int mx=0;
    for(int i=1; i<=n; i++)mx=max(mx,dp[i][1]=!a[i][1]);
    for(int i=1; i<=m; i++)mx=max(mx,dp[1][i]=!a[1][i]);
    for(int i=2; i<=n; i++)
    {
        for(int j=2; j<=m; j++)
        {
            dp[i][j]=a[i][j]?0:min({dp[i-1][j-1],dp[i-1][j],dp[i][j-1]})+1;
            mx=max(mx,dp[i][j]);
        }
    }
    ans[kk]=mx;
    for(int k=kk; k>0; --k)
    {
        a[qx[k]][qy[k]]=0;
        for(int i=1; i<=n; i++)
        {
            up[i][qy[k]]=a[i][qy[k]]?0:up[i-1][qy[k]]+1;
        }
        for(int i=n; i>0; --i)
        {
            dn[i][qy[k]]=a[i][qy[k]]?0:dn[i+1][qy[k]]+1;
        }
        int l=1,r=min(n,m),aa=0;
        while(l<=r)
        {
            int mid=(l+r)>>1;
            if(check(qx[k],mid))aa=mid,l=mid+1;
            else r=mid-1;
        }
        ans[k-1]=mx=max(aa,mx);
    }
    for(int i=1; i<=kk; i++)
    {
        cout<<ans[i]<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX=2e3+9;
int n,m,k,a[MAX][MAX],ans[MAX],L[MAX],R[MAX];
char ch[MAX][MAX];
multiset<int> st[MAX];
multiset<int,greater<int> > sl;
multiset<int,less<int> > sr;
struct P{int x,y;}p[MAX];
bool check(int x,int y,int k)
{
    int up=max(0,x-k+1),dn=min(n-1,x+k-1);
    for(int i=up;i<=dn;i++)
    {
        auto it=st[i].lower_bound(y) ;
        if(*it==y){L[i]=y+1;R[i]=y;continue;}
        R[i]=*it-1,it--,L[i]=*it+1 ;
    }
    sl.clear(),sr.clear();
    for(int i=up;i<=dn;i++)
    {
        if(i>=up+k) sl.erase(sl.find(L[i-k])),sr.erase(sr.find(R[i-k])) ;
        sl.insert(L[i]),sr.insert(R[i]);
        if(i>=up+k-1 && *sr.begin()-*sl.begin()>=k-1) return true;
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++) for (int j=0;j<m;j++) cin>>ch[i][j];
    for(int i=1;i<=k;i++)cin>>p[i].x>>p[i].y,p[i].x--,p[i].y--,ch[p[i].x][p[i].y]='X';
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if (ch[i][j]!='X')
            {
                if(!i || !j) a[i][j]=1; else a[i][j]=min(min(a[i-1][j],a[i][j-1]),a[i-1][j-1])+1 ;
                ans[k]=max(ans[k],a[i][j]);
            }
            else st[i].insert(j);
    for(int i=0;i<n;i++) st[i].insert(-1),st[i].insert(m);
    for(int i=k-1;i>=1;i--)
    {
        int x=p[i+1].x,y=p[i+1].y;
        st[x].erase(y),ans[i]=ans[i+1];
        while(check(x,y,ans[i]+1)) ans[i]++;
    }
    for(int i=1;i<=k;i++) cout<<ans[i]<<'\n';
}


#include<bits/stdc++.h>
using namespace std;
const int MAX=2e3+9;
int n,m,k,a[MAX][MAX],ans[MAX],L[MAX],R[MAX];
char ch[MAX][MAX];
multiset<int> st[MAX];
multiset<int,greater<int> > sl;
multiset<int,less<int> > sr;
sruct P{int x,y;}p[MAX];
bool check(int x,int y,int k)
{
    int up=max(0,x-k+1),dn=min(n-1,x+k-1);
    for(int i=up;i<=dn;i++)
    {
        auto it=st[i].lower_bound(y) ;
        if(*it==y){L[i]=y+1;R[i]=y;continue;}
        R[i]=*it-1,it--,L[i]=*it+1 ;
    }
    sl.clear(),sr.clear();
    for(int i=up;i<=dn;i++)
    {
        if(i>=up+k) sl.erase(sl.find(L[i-k])),sr.erase(sr.find(R[i-k])) ;
        sl.insert(L[i]),sr.insert(R[i]);
        if(i>=up+k-1 && *sr.begin()-*sl.begin()>=k-1) return true;
    }
    return false;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
   	cin>>n>>m>>k;
    for(int i=0;i<n;i++) for (int j=0;j<m;j++) cin>>ch[i][j];
    for(int i=1;i<=k;i++)cin>>p[i].x>>p[i].y,p[i].x--,p[i].y--,ch[p[i].x][p[i].y]='X';
    for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if (ch[i][j]!='X')
			{
    	    	if(!i || !j) a[i][j]=1; else a[i][j]=min(min(a[i-1][j],a[i][j-1]),a[i-1][j-1])+1 ;
    	    	ans[k]=max(ans[k],a[i][j]);
    		}
			else st[i].insert(j);
    for(int i=0;i<n;i++) st[i].insert(-1),st[i].insert(m);
    for(int i=k-1;i>=1;i--)
    {
        int x=p[i+1].x,y=p[i+1].y;
        st[x].erase(y),ans[i]=ans[i+1];
        while(check(x,y,ans[i]+1)) ans[i]++;
    }
    for(int i=1;i<=k;i++) cout<<ans[i]<<'\n';
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<set>
#include<queue>
#include<vector>
#include<map>
#define rep(i,a,n) for(int i = a;i <= n;i++)
#define per(i,n,a) for(int i = n;i >= a;i--)
#define enter putchar('\n')
#define fr friend inline
#define y1 poj
#define mp make_pair
#define pr pair<int,int>
#define fi first
#define sc second
#define pb push_back
#define lowbit(x) x & (-x)

using namespace std;
typedef long long ll;
const int M = 2005;
const int INF = 1000000009;
const double eps = 1e-7;

int read()
{
    int ans = 0,op = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
	if(ch == '-') op = -1;
	ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
	ans *= 10;
	ans += ch - '0';
	ch = getchar();
    }
    return ans * op;
}

struct node
{
   int x,y;
}a[M];

int n,m,k,le[M][M],ri[M][M],q[M],dp[M][M],cur,ans[M],kx,ky,head,tail,tmp[M];
bool pd[M][M];
char s[M];

void init()
{
   rep(i,1,n)
   rep(j,1,m)
   {
      if(pd[i][j]) dp[i][j] = 0;
      else dp[i][j] = min(dp[i-1][j-1],min(dp[i][j-1],dp[i-1][j])) + 1;
      cur = max(cur,dp[i][j]);
   }
   rep(i,1,n)
   rep(j,1,m) pd[i][j] ? le[i][j] = 0 : le[i][j] = le[i][j-1] + 1;
   rep(i,1,n)
   per(j,m,1) pd[i][j] ? ri[i][j] = 0 : ri[i][j] = ri[i][j+1] + 1;
}

bool check(int d)
{
   head = 1,tail = 0;
   rep(i,1,n)
   {
      while(head <= tail && le[q[tail]][ky] >= le[i][ky]) tail--;
      q[++tail] = i;
      while(head <= tail && q[head] <= i - d) head++;
      tmp[i] = le[q[head]][ky];
   }
   head = 1,tail = 0;
   rep(i,1,n)
   {
      while(head <= tail && ri[q[tail]][ky] >= ri[i][ky]) tail--;
      q[++tail] = i;
      while(head <= tail && q[head] <= i - d) head++;
      tmp[i] += ri[q[head]][ky] - 1;
   }
   rep(i,d,n) if(tmp[i] >= d) return 1;
   return 0;
}

int main()
{
   n = read(),m = read(),k = read();
   rep(i,1,n)
   {
      scanf("%s",s+1);
      rep(j,1,m) if(s[j] == 'X') pd[i][j] = 1;
   }
   rep(i,1,k) a[i].x = read(),a[i].y = read(),pd[a[i].x][a[i].y] = 1;
   init();
   per(i,k-1,1)
   {
      ans[i+1] = cur;
      kx = a[i+1].x,ky = a[i+1].y,pd[kx][ky] = 0;
      rep(j,1,m) pd[kx][j] ? le[kx][j] = 0 : le[kx][j] = le[kx][j-1] + 1;
      per(j,m,1) pd[kx][j] ? ri[kx][j] = 0 : ri[kx][j] = ri[kx][j+1] + 1;
      while(check(cur+1)) cur++;
   }
   ans[1] = cur;
   rep(i,1,k) printf("%d\n",ans[i]);
   return 0;
}


#include<bits/stdc++.h>
#define cs const
using namespace std;
cs int N = 2e3 + 50, M = N * N;
int n, m, k;
char mp[N][N];
int up[N][N], dn[N][N], l[N][N], r[N][N];
int mx[M], v[M];
int A, B;
int subwork(int *a, int *b, int n){
	static int qa[N], qb[N]; int ha=1, ta=0, hb=1, tb=0;
	int ans = 0, l = 1, r = 0;
//	for(int i=1; i<=n; i++) cout<<a[i]<<" "; cout<<endl;
//	for(int i=1; i<=n; i++) cout<<b[i]<<" "; cout<<endl;
	for(int i=1; i<=n; i++){
		while(ha<=ta && a[qa[ta]]>=a[i]) --ta;
		while(hb<=tb && b[qb[tb]]>=b[i]) --tb;
		qa[++ta] = i; qb[++tb] = i;
		++r; int x=a[qa[ha]]+b[qb[hb]], y=r-l+1;
//		cout<<l<<" "<<r<<" "<<x<<" "<<y<<" "<<a[qa[ha]]<<" "<<b[qb[hb]]<<endl;
		ans = max(ans, min(x,y));
		while(y>x){
			while(qa[ha]==l) ++ha;
			while(qb[hb]==l) ++hb; ++l;
			x=a[qa[ha]]+b[qb[hb]], y=r-l+1;
			ans = max(ans, min(x,y));
		}
	} return ans;
}
void work(int x, int lx, int rx, int ly, int ry){
	if(lx==rx && ly==ry) return v[x]=mx[x]=(mp[lx][ly]=='.'),void();
	if(A && B && (!(lx<=A&&A<=rx) || !(ly<=B&&B<=ry))) return;
	if(rx-lx > ry-ly){
		int mid = (lx+rx) >> 1;
		work(x<<1, lx, mid, ly, ry);
		work(x<<1|1, mid+1, rx, ly, ry);
		static int a[N], b[N]; int nd = 0;
		for(int i=ly; i<=ry; i++) a[++nd]=mid-max(up[mid][i],lx-1), b[nd]=min(rx+1,dn[mid+1][i])-mid-1;
		v[x] = subwork(a, b, nd);
		mx[x] = max(v[x], max(mx[x<<1], mx[x<<1|1]));
//		cout<<"mdf "<<x<<" "<<lx<<" "<<rx<<" "<<ly<<" "<<ry<<" "<<mid<<" "<<v[x]<<" "<<mx[x]<<" "<<mx[x<<1]<<" "<<mx[x<<1|1]<<endl;
//		for(int i=1; i<=nd; i++) cout<<a[i]<<" "; cout<<endl;
//		for(int i=1; i<=nd; i++) cout<<b[i]<<" "; cout<<endl;
	} else{
		int mid = (ly+ry) >> 1;
		work(x<<1, lx, rx, ly, mid);
		work(x<<1|1, lx, rx, mid+1, ry);
		static int a[N], b[N]; int nd = 0;
		for(int i=lx; i<=rx; i++) a[++nd]=mid-max(ly-1,l[i][mid]), b[nd]=min(ry+1,r[i][mid+1])-mid-1;
		v[x] = subwork(a, b, nd);
		mx[x] = max(v[x], max(mx[x<<1], mx[x<<1|1]));
	}
}
void Ban(int x, int y){
	mp[x][y]='X';
	for(int j=y; j<=m; j++)
	if(mp[x][j]=='X') l[x][j]=j; else l[x][j]=l[x][j-1];
	for(int j=y; j>=1; j--)
	if(mp[x][j]=='X') r[x][j]=j; else r[x][j]=r[x][j+1];
	for(int i=x; i<=n; i++)
	if(mp[i][y]=='X') up[i][y]=i; else up[i][y]=up[i-1][y];
	for(int i=x; i>=1; i--)
	if(mp[i][y]=='X') dn[i][y]=i; else dn[i][y]=dn[i+1][y];
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1; i<=n; i++) scanf("%s",mp[i]+1);
	for(int i=1; i<=n; i++)
	for(int j=1; j<=m; j++)
	if(mp[i][j]=='X') l[i][j]=j; else l[i][j]=l[i][j-1];
	for(int i=1; i<=n; i++){
		r[i][m+1]=m+1;
		for(int j=m; j>=1; j--)
		if(mp[i][j]=='X') r[i][j]=j; else r[i][j]=r[i][j+1];
	}
	for(int j=1; j<=m; j++)
	for(int i=1; i<=n; i++)
	if(mp[i][j]=='X') up[i][j]=i; else up[i][j]=up[i-1][j];
	for(int j=1; j<=m; j++){
		dn[n+1][j]=n+1;
		for(int i=n; i>=1; i--)
		if(mp[i][j]=='X') dn[i][j]=i; else dn[i][j]=dn[i+1][j];
	}
	work(1,1,n,1,m);
	while(k--){
		scanf("%d%d",&A,&B); Ban(A,B);
		work(1,1,n,1,m); cout<<mx[1]<<'\n';
	} return 0;
}