#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int dp[11][11][3][200][105];
int n;
int mapl[11][11];
int dx1[10] = {-1, -2, -2, -1, 1, 2, 2, 1};
int dy1[10] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dx2[5] = {-1, -1, 1, 1};
int dy2[5] = {-1, 1, -1, 1};
int dx3[5] = {0, -1, 0, 1};
int dy3[5] = {-1, 0, 1, 0};
struct node {
  int x;
  int y;
  int z;
  int k;
  int m;
};
int main() {
  cin >> n;
  memset(dp, -1, sizeof(dp));
  int sx, sy;
  int tx, ty;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &mapl[i][j]);
      if (mapl[i][j] == 1) {
        sx = i;
        sy = j;
      } else if (mapl[i][j] == n * n) {
        tx = i;
        ty = j;
      }
    }
  }
  queue<node> Q;
  node a, b, c;
  a = node{sx, sy, 0, 0, 1};
  b = node{sx, sy, 1, 0, 1};
  c = node{sx, sy, 2, 0, 1};
  dp[sx][sy][0][0][1] = dp[sx][sy][1][0][1] = dp[sx][sy][2][0][1] = 0;
  Q.push(a);
  Q.push(b);
  Q.push(c);
  while (!Q.empty()) {
    node pre = Q.front();
    Q.pop();
    int x = pre.x;
    int y = pre.y;
    int z = pre.z;
    int k = pre.k;
    int m = pre.m;
    for (int i = 0; i < 3; i++) {
      if (i == z) continue;
      if (dp[x][y][i][k + 1][m] >= 0) continue;
      dp[x][y][i][k + 1][m] = dp[x][y][z][k][m] + 1;
      Q.push(node{x, y, i, k + 1, m});
    }
    if (z == 0) {
      for (int i = 0; i < 8; i++) {
        int xx = x + dx1[i];
        int yy = y + dy1[i];
        int mm = m;
        if (xx <= 0 || xx >= n + 1 || yy <= 0 || yy >= n + 1) continue;
        if (mapl[xx][yy] == m + 1) mm++;
        if (dp[xx][yy][z][k][mm] >= 0) continue;
        dp[xx][yy][z][k][mm] = dp[x][y][z][k][m] + 1;
        Q.push(node{xx, yy, z, k, mm});
      }
    } else if (z == 1) {
      for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 10; j++) {
          int xx = x + j * dx2[i];
          int yy = y + j * dy2[i];
          int mm = m;
          if (xx <= 0 || xx >= n + 1 || yy <= 0 || yy >= n + 1) continue;
          if (mapl[xx][yy] == m + 1) mm++;
          if (dp[xx][yy][z][k][mm] >= 0) continue;
          dp[xx][yy][z][k][mm] = dp[x][y][z][k][m] + 1;
          Q.push(node{xx, yy, z, k, mm});
        }
      }
    } else if (z == 2) {
      for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 10; j++) {
          int xx = x + j * dx3[i];
          int yy = y + j * dy3[i];
          int mm = m;
          if (xx <= 0 || xx >= n + 1 || yy <= 0 || yy >= n + 1) continue;
          if (mapl[xx][yy] == m + 1) mm++;
          if (dp[xx][yy][z][k][mm] >= 0) continue;
          dp[xx][yy][z][k][mm] = dp[x][y][z][k][m] + 1;
          Q.push(node{xx, yy, z, k, mm});
        }
      }
    }
  }
  int ans = INF;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 200; j++) {
      if (dp[tx][ty][i][j][n * n] >= 0) {
        ans = min(ans, dp[tx][ty][i][j][n * n]);
      }
    }
  }
  int res = INF;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 200; j++) {
      if (dp[tx][ty][i][j][n * n] == ans) {
        res = min(res, j);
        break;
      }
    }
  }
  cout << ans << " " << res << endl;
  return 0;
}
