#include <bits/stdc++.h>
using namespace std;
const int mx = 12;
const int mxv = mx * mx * 3;
const long long int oo = 1e12;
int a[mx][mx];
int pr[mx * mx], pc[mx * mx];
int n;
pair<long long int, long long int> w[mxv][mxv];
pair<long long int, long long int> f[mx * mx][3];
int idx(int r, int c, int t) { return n * n * t + r * n + c; }
pair<long long int, long long int> mad(pair<long long int, long long int> x,
                                       pair<long long int, long long int> y) {
  return pair<long long int, long long int>(x.first + y.first,
                                            x.second + y.second);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
      pr[a[i][j]] = i;
      pc[a[i][j]] = j;
    }
  }
  for (int i = 0; i < mxv; i++)
    for (int j = 0; j < mxv; j++) {
      w[i][j] = pair<long long int, long long int>(oo, oo);
      if (i == j) w[i][j] = pair<long long int, long long int>(0ll, 0ll);
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      for (int dr : {-1, -2, 1, 2})
        for (int dc : {-1, -2, 1, 2}) {
          if (abs(dr) == abs(dc)) continue;
          int nr = i + dr;
          int nc = j + dc;
          if (0 <= nr && nr < n && 0 <= nc && nc < n) {
            int u = idx(i, j, 0);
            int v = idx(nr, nc, 0);
            w[u][v] = pair<long long int, long long int>(1ll, 0ll);
            w[v][u] = pair<long long int, long long int>(1ll, 0ll);
          }
        }
      for (int k = 0; k < n; k++)
        for (int l = 0; l < n; l++) {
          if (k == i && l == j) continue;
          int u = idx(i, j, 1);
          int v = idx(k, l, 1);
          if (k == i || l == j) {
            w[u][v] = pair<long long int, long long int>(1ll, 0ll);
            w[v][u] = pair<long long int, long long int>(1ll, 0ll);
          }
          u = idx(i, j, 2);
          v = idx(k, l, 2);
          if (i + j == k + l || i - j == k - l) {
            w[u][v] = pair<long long int, long long int>(1ll, 0ll);
            w[v][u] = pair<long long int, long long int>(1ll, 0ll);
          }
        }
      for (int k = 0; k < 3; k++)
        for (int l = 0; l < 3; l++)
          if (k != l) {
            int u = idx(i, j, k);
            int v = idx(i, j, l);
            w[u][v] = pair<long long int, long long int>(1ll, 1ll);
          }
    }
  int nv = n * n * 3;
  for (int k = 0; k < nv; k++)
    for (int i = 0; i < nv; i++)
      for (int j = 0; j < nv; j++) {
        pair<long long int, long long int> bet = mad(w[i][k], w[k][j]);
        w[i][j] = min(w[i][j], bet);
      }
  for (int t = 0; t < 3; t++) f[n * n][t] = make_pair(0ll, 0ll);
  for (int val = n * n - 1; val >= 1; val--) {
    int r = pr[val], c = pc[val];
    int nr = pr[val + 1], nc = pc[val + 1];
    for (int x = 0; x < 3; x++) {
      int u = idx(r, c, x);
      f[val][x] = pair<long long int, long long int>(oo, oo);
      for (int y = 0; y < 3; y++) {
        int v = idx(nr, nc, y);
        pair<long long int, long long int> bet = mad(w[u][v], f[val + 1][y]);
        f[val][x] = min(f[val][x], bet);
      }
    }
  }
  pair<long long int, long long int> ans = f[1][0];
  for (int t = 0; t < 3; t++) ans = min(ans, f[1][t]);
  cout << ans.first << " " << ans.second << endl;
  return 0;
}
