#include <bits/stdc++.h>
using namespace std;
const int N = 12;
int n, A[N][N];
int dp[N][N][3][200 + 5][200 + 5];
const int d0[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},
                      {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};
const int d1[4][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
const int d2[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
struct Node {
  int nx, ny, tp, change, tot;
  Node(int _nx, int _ny, int _tp, int _change, int _tot) {
    nx = _nx;
    ny = _ny;
    tp = _tp;
    change = _change;
    tot = _tot;
  }
};
void bfs(int x, int y) {
  memset(dp, -1, sizeof(dp));
  queue<Node> q;
  dp[x][y][0][0][1] = dp[x][y][1][0][1] = dp[x][y][2][0][1] = 0;
  q.push(Node(x, y, 0, 0, 1));
  q.push(Node(x, y, 1, 0, 1));
  q.push(Node(x, y, 2, 0, 1));
  while (!q.empty()) {
    Node t = q.front();
    q.pop();
    int nx = t.nx, ny = t.ny, tp = t.tp, change = t.change, tot = t.tot;
    if (tp == 0) {
      for (int i = 0; i < 8; i++) {
        int tx = nx + d0[i][0], ty = ny + d0[i][1], now = tot;
        if (tx < 1 || tx > n || ty < 1 || ty > n) continue;
        if (A[tx][ty] == now + 1) ++now;
        if (dp[tx][ty][tp][change][now] != -1) continue;
        dp[tx][ty][tp][change][now] = dp[nx][ny][tp][change][tot] + 1;
        q.push(Node(tx, ty, tp, change, now));
      }
    } else if (tp == 1) {
      for (int j = 1; j <= 10; j++)
        for (int i = 0; i < 4; i++) {
          int tx = nx + j * d1[i][0], ty = ny + j * d1[i][1], now = tot;
          if (tx < 1 || tx > n || ty < 1 || ty > n) continue;
          if (A[tx][ty] == now + 1) ++now;
          if (dp[tx][ty][tp][change][now] != -1) continue;
          dp[tx][ty][tp][change][now] = dp[nx][ny][tp][change][tot] + 1;
          q.push(Node(tx, ty, tp, change, now));
        }
    } else if (tp == 2) {
      for (int j = 1; j <= 10; j++) {
        for (int i = 0; i < 4; i++) {
          int tx = nx + j * d2[i][0], ty = ny + j * d2[i][1], now = tot;
          if (tx < 1 || tx > n || ty < 1 || ty > n) continue;
          if (A[tx][ty] == now + 1) ++now;
          if (dp[tx][ty][tp][change][now] != -1) continue;
          dp[tx][ty][tp][change][now] = dp[nx][ny][tp][change][tot] + 1;
          q.push(Node(tx, ty, tp, change, now));
        }
      }
    }
    for (int i = 0; i < 3; i++) {
      if (i == tp) continue;
      if (change + 1 > 200) continue;
      if (dp[nx][ny][i][change + 1][tot] != -1) continue;
      dp[nx][ny][i][change + 1][tot] = dp[nx][ny][tp][change][tot] + 1;
      q.push(Node(nx, ny, i, change + 1, tot));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= (n); i++)
    for (int j = 1; j <= (n); j++) scanf("%d", &A[i][j]);
  int sx, sy, ex, ey;
  for (int i = 1; i <= (n); i++)
    for (int j = 1; j <= (n); j++) {
      if (A[i][j] == 1)
        sx = i, sy = j;
      else if (A[i][j] == n * n)
        ex = i, ey = j;
    }
  bfs(sx, sy);
  int ans = 0x3f3f3f3f;
  for (int k = 0; k < 3; k++)
    for (int l = 0; l <= 200; l++)
      if (dp[ex][ey][k][l][n * n] != -1) {
        ans = min(ans, dp[ex][ey][k][l][n * n]);
      }
  cout << ans << " ";
  for (int l = 0; l <= 200; l++)
    for (int k = 0; k < 3; k++) {
      if (dp[ex][ey][k][l][n * n] == ans) return cout << l, 0;
    }
  return 0;
}
