#include <stdio.h>
#define MAXN 250
int hmax = 1;
struct punct{
int x,y;};
void add(int x,int y,int tata[MAXN],int h[MAXN]){
//printf("%d %d %d\n",x,y,hmax);
while(tata[x] != 0)
x = tata[x];
while(tata[y] != 0)
y = tata[y];
if(h[x] < h[y]){
tata[x] = y;
h[y] = h[y] + h[x];
if(h[y] > hmax)
hmax = h[y];
}
else{
tata[y] = x;
h[x] = h[x] + h[y];
if(h[x] > hmax)
hmax = h[x];
}
}
int query(int x,int y,int tata[MAXN],int h[MAXN]){
int i = x, j = y, aux;
while(tata[x] != 0)
x = tata[x];
while(tata[y] != 0)
y = tata[y];
while(tata[i] != 0){
aux = i;
i = tata[i];
tata[aux] = x;
}
while(tata[j] != 0){
aux = j;
j = tata[j];
tata[aux] = y;
}
if(x == y)
return 1;
return 0;
}
int main(){
int n, i, x, y, j, a[MAXN][MAXN],tata[MAXN * MAXN], h[MAXN * MAXN];
struct punct v[MAXN * MAXN];
int r[MAXN * MAXN];
FILE *f, *g;
f = fopen("bile.in","r");
g = fopen("bile.out","w");
fscanf(f,"%d",&n);
for(i = 0;i <= n + 1; ++i)
for(j = 0;j <= n + 1; ++j){
a[i][j] = 0;
tata[n * i + j] = 0;
h[n * i + j] = 1;
}
for(i = 1;i <= n * n; ++i)
fscanf(f,"%d %d",&v[i].x,&v[i].y);
for(i = n * n;i >= 1; --i){
a[v[i].x][v[i].y] = 1;
if(a[v[i].x - 1][v[i].y] == 1 && query((v[i].x - 1) * n +v[i].y,(v[i].x - 2) * n + v[i].y,tata,h) == 0)
add((v[i].x - 1) * n +v[i].y,(v[i].x - 2) * n + v[i].y,tata,h);
if(a[v[i].x + 1][v[i].y] == 1 && query((v[i].x - 1) * n +v[i].y,v[i].x * n + v[i].y,tata,h) == 0)
add((v[i].x - 1) * n +v[i].y,v[i].x * n + v[i].y,tata,h);
if(a[v[i].x][v[i].y + 1] == 1 && query((v[i].x - 1) * n +v[i].y,(v[i].x - 1) * n + v[i].y + 1,tata,h) == 0)
add((v[i].x - 1) * n +v[i].y,(v[i].x - 1) * n + v[i].y + 1,tata,h);
if(a[v[i].x][v[i].y - 1] == 1 && query((v[i].x - 1) * n +v[i].y,(v[i].x - 1) * n + v[i].y - 1,tata,h) == 0)
{add((v[i].x - 1) * n +v[i].y,(v[i].x - 1) * n + v[i].y - 1,tata,h);}
r[i] = hmax;
}
for(i = 2;i <= n * n; ++i)
fprintf(g,"%d\n",r[i]);
fprintf(g,"0");
return 0;
}