void bfs(int x,int y)
{
queue<node> q;
node h,t;
t.x = x; t.y=y; t.step=0; vis[t.x][t.y]=1;
q.push(t);
while(!q.empty())
{
h=q.front();q.pop();
if(h.x==1&&h.y==1){cout<<h.step<<endl;return;}
for(int i=0;i<12;i++)
{
int tx = h.x+nex[i][0];
int ty = h.y+nex[i][1];
if(tx<1||tx>n||ty<1||ty>n||vis[tx][ty]==1){continue;}
else
{
vis[tx][ty]=1;
t.x = tx,t.y = ty;
t.step = h.step+1;
q.push(t);
}
}
}
}