#include <bits/stdc++.h>
using namespace std;
int N;
const int INF = 1e9;
pair<int, int> sum(pair<int, int> a, pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
bool inside(int i, int j) { return (0 <= i && i < N && 0 <= j && j < N); }
int main() {
  int i, j, k, i2, j2, k2;
  cin >> N;
  int A[10][10];
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  pair<int, int> dist[300][300];
  for (i = 0; i < 300; i++) {
    for (j = 0; j < 300; j++) {
      if (i % 100 == j % 100) {
        dist[i][j] = (i == j) ? make_pair(0, 0) : make_pair(1, 1);
      } else {
        dist[i][j] = {INF, 0};
      }
    }
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      int a = A[i][j];
      for (k = 0; k < N; k++) {
        if (i != k) dist[a][A[k][j]] = {1, 0};
        if (j != k) dist[a][A[i][k]] = {1, 0};
      }
      for (k = -N + 1; k < N; k++) {
        if (k == 0) continue;
        if (inside(i + k, j + k)) dist[a + 100][A[i + k][j + k] + 100] = {1, 0};
        if (inside(i + k, j - k)) dist[a + 100][A[i + k][j - k] + 100] = {1, 0};
      }
      const int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
      const int dy[] = {1, -1, 2, -2, 2, -2, 1, -1};
      for (k = 0; k < 8; k++) {
        i2 = i + dx[k];
        j2 = j + dy[k];
        if (inside(i2, j2)) dist[a + 200][A[i2][j2] + 200] = {1, 0};
      }
    }
  }
  for (k = 0; k < 300; k++) {
    for (i = 0; i < 300; i++) {
      for (j = 0; j < 300; j++) {
        dist[i][j] = min(dist[i][j], sum(dist[i][k], dist[k][j]));
      }
    }
  }
  pair<int, int> dp[100][3];
  for (k = 0; k < 3; k++) dp[0][k] = {0, 0};
  for (i = 0; i < N * N - 1; i++) {
    for (j = 0; j < 3; j++) {
      dp[i + 1][j] = {INF, 0};
      for (k = 0; k < 3; k++) {
        dp[i + 1][j] = min(dp[i + 1][j],
                           sum(dp[i][k], dist[i + k * 100][i + 1 + j * 100]));
      }
    }
  }
  pair<int, int> ans =
      min({dp[N * N - 1][0], dp[N * N - 1][1], dp[N * N - 1][2]});
  cout << ans.first << " " << ans.second << endl;
  return 0;
}
