#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> mymin(pair<long long, long long> a,
                                 pair<long long, long long> b) {
  if (a.first + a.second < b.first + b.second)
    return a;
  else if (a.first + a.second == b.first + b.second) {
    if (a.second < b.second) return a;
    return b;
  } else
    return b;
}
int n;
int a[11][11];
pair<long long, long long> b[121];
pair<long long, long long> dist[363][363];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      b[a[i][j] - 1] = make_pair(i, j);
    }
  }
  for (int i = 0; i < 3 * n * n; i++) {
    for (int j = 0; j < 3 * n * n; j++) {
      dist[i][j] = make_pair((long long)(1e9 + 7), (long long)(1e9 + 7));
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        dist[3 * i * n + 3 * j + 0][3 * i * n + 3 * k + 0] = make_pair(1, 0);
        dist[3 * i * n + 3 * j + 0][3 * k * n + 3 * j + 0] = make_pair(1, 0);
      }
      for (int k = -n; k <= n; k++) {
        if (i + k >= 0 and i + k < n and j + k >= 0 and j + k < n)
          dist[3 * i * n + 3 * j + 1][3 * (i + k) * n + 3 * (j + k) + 1] =
              make_pair(1, 0);
        if (i + k >= 0 and i + k < n and j - k >= 0 and j - k < n)
          dist[3 * i * n + 3 * j + 1][3 * (i + k) * n + 3 * (j - k) + 1] =
              make_pair(1, 0);
      }
      int dx[] = {1, 1, -1, -1, 2, 2, -2, -2};
      int dy[] = {2, -2, -2, 2, 1, -1, 1, -1};
      for (int k = 0; k < 8; k++) {
        int nx = i + dx[k];
        int ny = j + dy[k];
        if (nx < 0 or nx >= n) continue;
        if (ny < 0 or ny >= n) continue;
        dist[3 * i * n + 3 * j + 2][3 * nx * n + 3 * ny + 2] = make_pair(1, 0);
      }
      for (int k = 0; k < 3; k++) {
        for (int m = 0; m < 3; m++) {
          dist[3 * i * n + 3 * j + k][3 * i * n + 3 * j + m] = make_pair(0, 1);
        }
      }
      for (int k = 0; k < 3; k++) {
        dist[3 * i * n + 3 * j + k][3 * i * n + 3 * j + k] = make_pair(0, 0);
      }
    }
  }
  for (int w = 0; w < n; w++)
    for (int i = 0; i < 3 * n * n; i++) {
      for (int j = 0; j < 3 * n * n; j++) {
        for (int k = 0; k < 3 * n * n; k++) {
          dist[i][j] = mymin(dist[i][j],
                             make_pair(dist[i][k].first + dist[k][j].first,
                                       dist[i][k].second + dist[k][j].second));
        }
      }
    }
  pair<long long, long long> dp[363];
  for (int k = 0; k < 3; k++) dp[k] = make_pair(0, 0);
  for (int i = 3; i < 3 * n * n; i += 3) {
    for (int k = 0; k < 3; k++) {
      dp[i + k] = make_pair((long long)(1e9 + 7), (long long)(1e9 + 7));
      for (int j = 0; j < 3; j++) {
        pair<long long, long long> rool = make_pair(
            dp[i - 3 + j].first +
                dist[3 * (b[i / 3 - 1].first) * n + 3 * (b[i / 3 - 1].second) +
                     j][3 * (b[i / 3].first) * n + 3 * (b[i / 3].second) + k]
                    .first,
            dp[i - 3 + j].second +
                dist[3 * (b[i / 3 - 1].first) * n + 3 * (b[i / 3 - 1].second) +
                     j][3 * (b[i / 3].first) * n + 3 * (b[i / 3].second) + k]
                    .second);
        dp[i + k] = mymin(rool, dp[i + k]);
      }
    }
  }
  pair<long long, long long> ans =
      mymin(dp[3 * (n * n - 1)],
            mymin(dp[3 * (n * n - 1) + 1], dp[3 * (n * n - 1) + 2]));
  cout << ans.first + ans.second << " " << ans.second;
}
