#include <bits/stdc++.h>
using namespace std;
int inf = numeric_limits<int>::max() / 2, n;
pair<int, int> MIN(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  pair<int, int> arr[] = {a, b, c};
  sort(arr, arr + 3, [](pair<int, int> x, pair<int, int> y) {
    return (x.first == y.first ? (x.second < y.second) : x.first < y.first);
  });
  return arr[0];
}
void swap(pair<int, int> &a, pair<int, int> &b) {
  pair<int, int> tmp = a;
  a = b;
  b = tmp;
}
void swap(int &a, int &b) {
  int tmp = a;
  a = b;
  b = tmp;
}
bool OK(int a, int b) { return a >= 0 && a < n && b >= 0 && b < n; }
int knight(pair<int, int> a, pair<int, int> b) {
  int dist = inf;
  bool vis[n][n];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) vis[i][j] = false;
  queue<pair<pair<int, int>, int>> q;
  q.push({a, 0});
  vis[a.first][a.second] = true;
  while (!q.empty()) {
    int x = q.front().first.first, y = q.front().first.second,
        d = q.front().second;
    for (int var = 0; var < 8; ++var) {
      int addX = ((var & 2) ? 1 : -1) * 1, addY = ((var & 4) ? 1 : -1) * 2, X,
          Y;
      if ((var & 1)) swap(addX, addY);
      X = x + addX;
      Y = y + addY;
      if (b.first == X && b.second == Y) {
        dist = d + 1;
        goto DONE;
      }
      if (!vis[X][Y] && OK(X, Y)) {
        q.push({{X, Y}, d + 1});
        vis[X][Y] = true;
      }
    }
    q.pop();
  }
DONE:
  return dist;
}
int bishop(pair<int, int> a, pair<int, int> b) {
  return (((a.first + b.first) & 1) == ((a.second + b.second) & 1)
              ? (abs(a.first - b.first) == abs(a.second - b.second) ? 1 : 2)
              : inf);
}
int rook(pair<int, int> a, pair<int, int> b) {
  return (a.first == b.first || a.second == b.second ? 1 : 2);
}
int bishopknight(pair<int, int> a, pair<int, int> b, bool sw) {
  if (sw) swap(a, b);
  int dist = inf;
  for (int var = 0; var < 8; ++var) {
    int addX = ((var & 2) ? 1 : -1) * 1, addY = ((var & 4) ? 1 : -1) * 2, X, Y;
    if ((var & 1)) swap(addX, addY);
    X = a.first + addX;
    Y = a.second + addY;
    if (OK(X, Y) && abs(b.first - X) == abs(b.second - Y)) {
      dist = 3;
      break;
    }
  }
  return dist;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  pair<int, int> sq[n * n];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int x;
      cin >> x;
      sq[x - 1] = {i, j};
    }
  }
  pair<int, int> dp[n * n][3];
  for (int i = 0; i < 3; ++i) dp[0][i] = {0, 0};
  for (int i = 1; i < n * n; ++i) {
    int k = knight(sq[i - 1], sq[i]), b = bishop(sq[i - 1], sq[i]),
        r = rook(sq[i - 1], sq[i]), bk = bishopknight(sq[i - 1], sq[i], true),
        kb = bishopknight(sq[i - 1], sq[i], false);
    for (int j = 0; j < 3; ++j) {
      dp[i][j] = MIN(
          {dp[i - 1][0].first + k + (j != 0), dp[i - 1][0].second + (j != 0)},
          {dp[i - 1][1].first + b + (j != 1), dp[i - 1][1].second + (j != 1)},
          {dp[i - 1][2].first + r + (j != 2), dp[i - 1][2].second + (j != 2)});
    }
    if (dp[i - 1][0].first + kb < dp[i][1].first ||
        dp[i - 1][0].first + kb == dp[i][1].first &&
            dp[i - 1][0].second + 1 < dp[i][1].second)
      dp[i][1] = {dp[i - 1][0].first + kb, dp[i - 1][0].second + 1};
    if (dp[i - 1][1].first + bk < dp[i][0].first ||
        dp[i - 1][1].first + bk == dp[i][0].first &&
            dp[i - 1][1].second + 1 < dp[i][0].second)
      dp[i][0] = {dp[i - 1][1].first + bk, dp[i - 1][1].second + 1};
  }
  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 << "\n";
}
