#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define maxn 2000
int nt[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int n,f[maxn][maxn];
int vis[maxn][maxn];
struct qe
{
int x,y;
};
queue<qe> q;
void bfs(int x,int y)
{
qe start,next;
start.x=x;
start.y=y;
q.push(start);
while(!q.empty())
{
start=q.front();
q.pop();
for(int i=0;i<4;i++)
{
next.x=start.x+nt[i][0];
next.y=start.y+nt[i][1];
if(next.x<1||next.x>n||next.y<1||next.y>n)
continue;
if(vis[x][y]==1||f[next.x][next.y]==1)
continue;
f[next.x][next.y]=2;
vis[next.x][next.y]=1;
q.push(next);
}
}
}