#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int vis[25][25]; int mod[2] = {1, -1}; int mov[8][2]; int ans[25][25]; struct Position { int x, y; }; int main(){ int n; cin >> n; for (int i=1; i q; q.push(cur); while (!q.empty()) { cur = q.front(); q.pop(); for (int i=0; i<8; ++i) { tmp.x = cur.x + mov[i][0]; tmp.y = cur.y + mov[i][1]; if (tmp.x < 0 || tmp.x >= n || tmp.y < 0 || tmp.y >= n || vis[cur.x][cur.y] + 1 >= vis[tmp.x][tmp.y]) { continue; } vis[tmp.x][tmp.y] = vis[cur.x][cur.y] + 1; q.push(tmp); } } ans[i][j] = ans[j][i] = vis[n-1][n-1] > 100 ? -1 : vis[n-1][n-1]; } } for (int i=1; i