#include <bits/stdc++.h>
using namespace std;
int d[111][3][3];
int dd[111][3][3];
int f[111][3];
int ff[111][3];
int line[110], cro[110];
int n, m[11][11];
int Sx, Sy, Num, Tx, Ty, Ss, St;
int xx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int yy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int xx1[4] = {1, 1, -1, -1};
int yy1[4] = {1, -1, -1, 1};
inline bool check(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= n; }
int cnt;
void dfs(int x, int y, int sta, int left) {
  if (x == Tx && y == Ty) {
    int &ttt = d[Num][Ss][St], &tttt = dd[Num][Ss][St];
    int tmp = 4 - left + (sta == St ? 0 : 1);
    if (ttt > tmp) {
      ttt = tmp;
      tttt = cnt + (sta != St);
    } else if (ttt == tmp && tttt > cnt) {
      tttt = cnt + (sta != St);
    }
    return;
  }
  if (left <= 0) return;
  for (int i = 0; i <= 2; i++)
    if (i != sta) {
      cnt++;
      dfs(x, y, i, left - 1);
      cnt--;
    }
  if (sta == 0) {
    for (int i = 0; i < 8; i++) {
      int nx = x + xx[i], ny = y + yy[i];
      if (!check(nx, ny)) continue;
      dfs(nx, ny, sta, left - 1);
    }
  } else if (sta == 1) {
    for (int i = 0; i < 4; i++) {
      for (int j = 1;; j++) {
        int nx = x + j * xx1[i], ny = y + j * yy1[i];
        if (!check(nx, ny)) break;
        dfs(nx, ny, sta, left - 1);
      }
    }
  } else {
    if (x == Tx || y == Ty)
      dfs(Tx, Ty, sta, left - 1);
    else
      dfs(Tx, Ty, sta, left - 2);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> m[i][j];
      cro[m[i][j]] = i;
      line[m[i][j]] = j;
    }
  memset(f, 127 / 3, sizeof(f));
  memset(ff, 127 / 3, sizeof(ff));
  for (int i = 1; i < n * n; i++) {
    Tx = cro[i + 1];
    Ty = line[i + 1];
    Sx = cro[i];
    Sy = line[i];
    Num = i;
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) {
        d[i][j][k] = 4;
        dd[i][j][k] = 2;
        Ss = j;
        St = k;
        dfs(Sx, Sy, j, 4);
      }
  }
  f[1][0] = f[1][1] = f[1][2] = 0;
  ff[1][0] = ff[1][1] = ff[1][2] = 0;
  for (int i = 2; i <= n * n; i++)
    for (int j = 0; j <= 2; j++)
      for (int k = 0; k <= 2; k++) {
        if (f[i][j] > f[i - 1][k] + d[i - 1][k][j]) {
          f[i][j] = f[i - 1][k] + d[i - 1][k][j];
          ff[i][j] = ff[i - 1][k] + dd[i - 1][k][j];
        } else if (f[i][j] == f[i - 1][k] + d[i - 1][k][j])
          ff[i][j] = min(ff[i][j], ff[i - 1][k] + dd[i - 1][k][j]);
      }
  int ansl = 1000000, ansr = ansl;
  n = n * n;
  for (int i = 0; i < 3; i++)
    if (ansl > f[n][i]) {
      ansl = f[n][i];
      ansr = ff[n][i];
    } else if (ansl == f[n][i])
      ansr = min(ansr, ff[n][i]);
  cout << ansl << ' ' << ansr << endl;
  return 0;
}
