#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const long long N = 105;
pair<long long, long long> operator+(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  return {a.first + b.first, a.second + b.second};
}
pair<long long, long long> dp[N][3];
pair<long long, long long> moves[N][3][3];
long long a[11][11];
long long x[N];
long long y[N];
long long dx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
long long dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
long long n;
long long vis[11][11][3];
bool valid(long long x, long long y, long long z) {
  if (x < 0 || y < 0 || x >= n || y >= n || vis[x][y][z]) {
    return 0;
  }
  return 1;
}
struct cmp {
  bool operator()(array<long long, 4> a, array<long long, 4> b) {
    return pair<long long, long long>{a[2], a[3]} >
           pair<long long, long long>{b[2], a[3]};
  }
};
priority_queue<array<long long, 4>, vector<array<long long, 4>>, cmp> q;
void push(long long x, long long y, long long p, long long dis, long long rp) {
  if (!valid(x, y, p)) return;
  vis[x][y][p] = 1;
  q.push({a[x][y], p, dis, rp});
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> a[i][j];
      x[a[i][j]] = i;
      y[a[i][j]] = j;
    }
  }
  for (long long i = 1; i < n * n; i++) {
    for (long long k = 0; k < 3; k++) {
      long long cnt = 0;
      while (!q.empty()) {
        q.pop();
      }
      memset(vis, 0, sizeof(vis));
      vis[x[i]][y[i]][k] = 1;
      q.push({i, k, 0, 0});
      while (1) {
        auto cur = q.top();
        if (cur[0] == i + 1) {
          moves[i][k][cur[1]] = {cur[2], cur[3]};
          cnt++;
          if (cnt == 3) {
            break;
          }
        }
        long long X = x[cur[0]];
        long long Y = y[cur[0]];
        q.pop();
        if (cur[1] == 0) {
          for (long long z = 0; z < n; z++) {
            push(X, z, 0, cur[2] + 1, cur[3]);
            push(z, Y, 0, cur[2] + 1, cur[3]);
          }
        } else if (cur[1] == 1) {
          for (long long z = 0; z < n; z++) {
            push(z, X + Y - z, 1, cur[2] + 1, cur[3]);
            push(z, z + Y - X, 1, cur[2] + 1, cur[3]);
          }
        } else {
          for (long long z = 0; z < 8; z++) {
            push(X + dx[z], Y + dy[z], 2, cur[2] + 1, cur[3]);
          }
        }
        for (long long z = 0; z < 3; z++) {
          push(X, Y, z, cur[2] + 1, cur[3] + 1);
        }
      }
    }
  }
  dp[1][0] = dp[1][1] = dp[1][2] = {0, 0};
  for (long long i = 2; i < n * n + 1; i++) {
    for (long long j = 0; j < 3; j++) {
      dp[i][j] = min({moves[i - 1][0][j] + dp[i - 1][0],
                      moves[i - 1][1][j] + dp[i - 1][1],
                      moves[i - 1][2][j] + dp[i - 1][2]});
    }
  }
  pair<long long, long long> ans =
      min({dp[n * n][0], dp[n * n][1], dp[n * n][2]});
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
