#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > pos(n * n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int id;
      cin >> id;
      pos[id - 1] = make_pair(i, j);
    }
  }
  const int N = 3 * n * n, inf = int(1e6);
  vector<vector<pair<int, int> > > dis(
      N, vector<pair<int, int> >(N, make_pair(inf, inf)));
  auto encode = [&](int x, int y, int type) {
    return 3 * x * n + 3 * y + type;
  };
  auto inside = [&](int x, int y) {
    return 0 <= x && x < n && 0 <= y && y < n;
  };
  auto add_pair = [](const pair<int, int> a, const pair<int, int> b) {
    return make_pair(a.first + b.first, a.second + b.second);
  };
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          int a = encode(x, y, i);
          int b = encode(x, y, j);
          dis[a][b] = make_pair(i != j, i != j);
        }
      }
    }
  }
  const int dx[] = {1, 1, -1, -1, 2, 2, -2, -2};
  const int dy[] = {2, -2, 2, -2, 1, -1, 1, -1};
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      for (int i = 0; i < 8; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (inside(nx, ny)) {
          dis[encode(x, y, 0)][encode(nx, ny, 0)] = make_pair(1, 0);
        }
      }
    }
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      for (int i = 1; i < n; i++) {
        if (inside(x + i, y + i)) {
          dis[encode(x, y, 1)][encode(x + i, y + i, 1)] = make_pair(1, 0);
          dis[encode(x + i, y + i, 1)][encode(x, y, 1)] = make_pair(1, 0);
        }
        if (inside(x + i, y - i)) {
          dis[encode(x, y, 1)][encode(x + i, y - i, 1)] = make_pair(1, 0);
          dis[encode(x + i, y - i, 1)][encode(x, y, 1)] = make_pair(1, 0);
        }
      }
    }
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < n; y++) {
      for (int i = 1; i < n; i++) {
        if (inside(x + i, y)) {
          dis[encode(x, y, 2)][encode(x + i, y, 2)] = make_pair(1, 0);
          dis[encode(x + i, y, 2)][encode(x, y, 2)] = make_pair(1, 0);
        }
        if (inside(x, y + i)) {
          dis[encode(x, y, 2)][encode(x, y + i, 2)] = make_pair(1, 0);
          dis[encode(x, y + i, 2)][encode(x, y, 2)] = make_pair(1, 0);
        }
      }
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dis[i][j] = min(dis[i][j], add_pair(dis[i][k], dis[k][j]));
      }
    }
  }
  vector<vector<pair<int, int> > > dp(
      n * n, vector<pair<int, int> >(3, make_pair(inf, inf)));
  dp[0][0] = dp[0][1] = dp[0][2] = make_pair(0, 0);
  for (int i = 1; i < n * n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        int a = encode(pos[i - 1].first, pos[i - 1].second, j);
        int b = encode(pos[i].first, pos[i].second, k);
        dp[i][k] = min(dp[i][k], add_pair(dp[i - 1][j], dis[a][b]));
      }
    }
  }
  auto ans = min({dp[n * n - 1][0], dp[n * n - 1][1], dp[n * n - 1][2]});
  cout << ans.first << ' ' << ans.second << '\n';
  return 0;
}
