#include <bits/stdc++.h>
const int N = 10 * 10 * 3 + 10;
const int MV[][2] = {{1, 2},   {2, 1},   {2, -1}, {1, -2},
                     {-1, -2}, {-2, -1}, {-2, 1}, {-1, 2}};
const int INF = 0x3f3f;
std::pair<int, int> dis[N][N], f[N][3];
int n;
std::pair<int, int> a[N];
std::pair<int, int> operator+(const std::pair<int, int>& a,
                              const std::pair<int, int>& b) {
  return std::make_pair(a.first + b.first, a.second + b.second);
}
inline int h(int x, int y, int z) { return x * 3 * n + y * 3 + z; }
inline int h(const std::pair<int, int>& x, int z) {
  return x.first * 3 * n + x.second * 3 + z;
}
int main() {
  scanf("%d", &n);
  for (int i = 0, x; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &x);
      a[x - 1] = std::pair<int, int>(i, j);
    }
  }
  for (int i = 0; i < n * n * 3; ++i)
    for (int j = 0; j < n * n * 3; ++j)
      dis[i][j] =
          i == j ? std::pair<int, int>(0, 0) : std::pair<int, int>(INF, INF);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int s = 0; s < 3; ++s)
        for (int t = 0; t < 3; ++t)
          if (s != t) dis[h(i, j, s)][h(i, j, t)] = std::pair<int, int>(1, 1);
      for (int t = 0; t < i; ++t)
        dis[h(i, j, 0)][h(t, j, 0)] = std::pair<int, int>(1, 0);
      for (int t = i + 1; t < n; ++t)
        dis[h(i, j, 0)][h(t, j, 0)] = std::pair<int, int>(1, 0);
      for (int t = 0; t < j; ++t)
        dis[h(i, j, 0)][h(i, t, 0)] = std::pair<int, int>(1, 0);
      for (int t = j + 1; t < n; ++t)
        dis[h(i, j, 0)][h(i, t, 0)] = std::pair<int, int>(1, 0);
      for (int t = std::min(i, j); t; --t)
        dis[h(i, j, 1)][h(i - t, j - t, 1)] = std::pair<int, int>(1, 0);
      for (int t = std::min(i, n - j - 1); t; --t)
        dis[h(i, j, 1)][h(i - t, j + t, 1)] = std::pair<int, int>(1, 0);
      for (int t = std::min(j, n - i - 1); t; --t)
        dis[h(i, j, 1)][h(i + t, j - t, 1)] = std::pair<int, int>(1, 0);
      for (int t = std::min(n - i - 1, n - j - 1); t; --t)
        dis[h(i, j, 1)][h(i + t, j + t, 1)] = std::pair<int, int>(1, 0);
      for (int t = 0; t < 8; ++t)
        if (i + MV[t][0] < n && i + MV[t][0] >= 0 && j + MV[t][1] < n &&
            j + MV[t][1] >= 0)
          dis[h(i, j, 2)][h(i + MV[t][0], j + MV[t][1], 2)] =
              std::pair<int, int>(1, 0);
    }
  }
  for (int i = 0; i < n * n * 3; ++i)
    for (int j = 0; j < n * n * 3; ++j)
      for (int k = 0; k < n * n * 3; ++k) {
        if (dis[j][k] > dis[j][i] + dis[i][k]) {
          dis[j][k] = dis[j][i] + dis[i][k];
        }
      }
  f[0][0] = f[0][1] = f[0][2] = std::pair<int, int>(0, 0);
  for (int i = 0; i < n * n - 1; ++i) {
    f[i + 1][0] = std::min(f[i][0] + dis[h(a[i], 0)][h(a[i + 1], 0)],
                           std::min(f[i][1] + dis[h(a[i], 1)][h(a[i + 1], 0)],
                                    f[i][2] + dis[h(a[i], 2)][h(a[i + 1], 0)]));
    f[i + 1][1] = std::min(f[i][0] + dis[h(a[i], 0)][h(a[i + 1], 1)],
                           std::min(f[i][1] + dis[h(a[i], 1)][h(a[i + 1], 1)],
                                    f[i][2] + dis[h(a[i], 2)][h(a[i + 1], 1)]));
    f[i + 1][2] = std::min(f[i][0] + dis[h(a[i], 0)][h(a[i + 1], 2)],
                           std::min(f[i][1] + dis[h(a[i], 1)][h(a[i + 1], 2)],
                                    f[i][2] + dis[h(a[i], 2)][h(a[i + 1], 2)]));
  }
  std::pair<int, int> ans =
      std::min(f[n * n - 1][0], std::min(f[n * n - 1][1], f[n * n - 1][2]));
  printf("%d %d\n", ans.first, ans.second);
  return 0;
}
