#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
const int N = 10;
const int M = 3 * (N * N) + 5;
const int INF = 1e9;
pi pos[N * N];
pi cost[M][M];
pi cost2[M][M];
pi dp[N * N][3];
int n, f, dx, dy;
pi ans;
int kx[] = {2, 2, 1, -1, -2, -2, 1, -1};
int ky[] = {1, -1, 2, 2, 1, -1, -2, -2};
pi operator+(const pi& a, const pi& b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
int id(int x, int y, int f) { return 3 * (n * x + y) + f; }
bool in(int x, int y) { return x >= 0 && x < n && y >= 0 && y < n; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int x = 0; x < n; x++)
    for (int y = 0; y < n; y++) {
      cin >> f;
      pos[--f] = make_pair(x, y);
    }
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) cost[i][j] = make_pair(INF, INF);
  for (int i = 0; i < M; i++) cost[i][i] = make_pair(0, 0);
  for (int x = 0; x < n; x++)
    for (int y = 0; y < n; y++) {
      for (int i = 0; i < 8; i++) {
        dx = x + kx[i];
        dy = y + ky[i];
        if (in(dx, dy)) cost[id(x, y, 0)][id(dx, dy, 0)] = make_pair(1, 0);
      }
      for (int i = -n + 1; i < n; i++) {
        dx = x + i;
        dy = y + i;
        if (in(dx, dy)) cost[id(x, y, 1)][id(dx, dy, 1)] = make_pair(1, 0);
        dy = y - i;
        if (in(dx, dy)) cost[id(x, y, 1)][id(dx, dy, 1)] = make_pair(1, 0);
      }
      for (int i = 0; i < n; i++) {
        cost[id(x, y, 2)][id(x, i, 2)] = make_pair(1, 0);
        cost[id(x, y, 2)][id(i, y, 2)] = make_pair(1, 0);
      }
      for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
          if (i != j) cost[id(x, y, i)][id(x, y, j)] = make_pair(1, 1);
    }
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) cost2[i][j] = cost[i][j];
  for (int k = 0; k < M; k++)
    for (int i = 0; i < M; i++)
      for (int j = 0; j < M; j++) {
        cost2[i][j] = min(cost2[i][j], cost[i][k] + cost[k][j]);
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        if (i == id(1, 0, 0) && j == id(4, 4, 0)) {
        }
      }
  for (int i = 0; i < n * n; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = make_pair(INF, INF);
  for (int i = 0; i < 3; i++) dp[0][i] = make_pair(0, 0);
  for (int i = 0; i < n * n - 1; i++)
    for (int a = 0; a < 3; a++)
      for (int b = 0; b < 3; b++) {
        dp[i + 1][a] =
            min(dp[i + 1][a],
                dp[i][b] + cost2[id(pos[i].first, pos[i].second, b)]
                                [id(pos[i + 1].first, pos[i + 1].second, a)]);
      }
  ans = make_pair(INF, INF);
  for (int i = 0; i < 3; i++) ans = min(ans, dp[n * n - 1][i]);
  cout << ans.first << ' ' << ans.second;
}
