#include <bits/stdc++.h>
using namespace std;
pair<int, int> cost[15][15][3][3], dp[15][15][3];
const int inf = 1 << 25;
void fill_dp(int n) {
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < 3; ++k) dp[i][j][k] = {inf, inf};
}
struct state {
  int x, y, t;
  pair<int, int> c;
  bool operator<(const state &a) const { return c > a.c; }
};
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return {a.first + b.first, a.second + b.second};
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> m(n, vector<int>(n));
  for (auto &i : m)
    for (auto &j : i) cin >> j;
  vector<vector<pair<int, int>>> mov(3);
  for (int i = -2; i <= 2; ++i)
    if (i != 0)
      for (int j = (abs(i) > 1) ? -1 : -2; j <= ((abs(i) > 1) ? 1 : 2);
           j += 2 * (2 - abs(i) + 1))
        mov[0].push_back({i, j});
  for (int i = -1; i <= 1; i += 2)
    for (int j = -1; j <= 1; j += 2)
      for (int k = 1; k <= 9; ++k) mov[1].push_back({i * k, j * k});
  for (int i = 0; i <= 9; ++i)
    for (int j = 0; j <= 9; ++j)
      if (i + j > 0 && min(i, j) == 0)
        for (int k = -1; k <= 1; k += 2) mov[2].push_back({i * k, j * k});
  for (int k = 0; k < 3; ++k) mov[k].push_back({0, 0});
  function<pair<int, int>(int, int, int, int, int)> calc = [&](int x, int y,
                                                               int t1, int d,
                                                               int t2) {
    fill_dp(n);
    priority_queue<state> pq;
    pq.push({x, y, t1, {0, 0}});
    dp[x][y][t1] = {0, 0};
    while (true) {
      auto u = pq.top();
      pq.pop();
      if (m[u.x][u.y] == d && u.t == t2) return u.c;
      if (u.c == dp[u.x][u.y][u.t])
        for (int nt = 0; nt < 3; ++nt)
          for (auto z : mov[nt]) {
            int nx = u.x + z.first, ny = u.y + z.second;
            pair<int, int> nc =
                u.c +
                make_pair((z != make_pair(0, 0)) + (u.t != nt), (u.t != nt));
            if (nx >= 0 && ny >= 0 && nx < n && ny < n && nc < dp[nx][ny][nt]) {
              dp[nx][ny][nt] = nc;
              pq.push({nx, ny, nt, nc});
            }
          }
    }
  };
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < 3; ++k)
        for (int l = 0; l < 3; ++l)
          cost[i][j][k][l] = calc(i, j, k, min(n * n, m[i][j] + 1), l);
  fill_dp(n);
  vector<pair<int, int>> pos(n * n + 1);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      pos[m[i][j]] = {i, j};
      if (m[i][j] == 1) {
        for (int k = 0; k < 3; ++k) dp[i][j][k] = {0, 0};
      }
    }
  for (int p = 1; p < n * n; ++p) {
    int x = pos[p].first, y = pos[p].second, nx = pos[p + 1].first,
        ny = pos[p + 1].second;
    for (int k = 0; k < 3; ++k)
      if (dp[x][y][k].first != inf)
        for (int l = 0; l < 3; ++l)
          dp[nx][ny][l] = min(dp[nx][ny][l], dp[x][y][k] + cost[x][y][k][l]);
  }
  auto ans = min({dp[pos[n * n].first][pos[n * n].second][0],
                  dp[pos[n * n].first][pos[n * n].second][1],
                  dp[pos[n * n].first][pos[n * n].second][2]});
  cout << ans.first << " " << ans.second << "\n";
  return 0;
}
