#includeusing namespace std;#define int long long#define endl '\n'const int dx[]={0,0,1,-1};const int dy[]={1,-1,0,0};int g[5][5];vector > ans;queue > q;vector >last;void bfs(void){ for(int i=0;i for(int j=0;j{ cin>>g[i][j]; if(i==0&&j==0) g[i][j]=0; else if(g[i][j]==1) g[i][j]=0x3f3f3f3f; else g[i][j]=-1; }q.push({0, 0});while(q.size()){int x=q.front().first,y=q.front().second;q.pop(); for(int i=0;i{int nx=dx[i]+x;int ny=dy[i]+y;if(nx>=0&&ny>=0&&nx{g[nx][ny]=g[x][y]+1;q.push({nx,ny});last.push({nx,ny});}}}}signed main(){std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);bfs();for(int i=0;i for(int j=0;j cout cout}reverse(last.begin(),last.end()) for(int i=0;i{}return 0;}