#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<bool> used;
vector<vector<pair<int, int>>> lol;
int n;
int change(int x, int y) {
  if (x == y) return 0;
  return 1;
}
int main() {
  int x;
  cin >> n;
  vector<pair<int, int>> v(n * n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> x;
      x--;
      v[x] = make_pair(i, j);
    }
  }
  lol.resize(3 * n * n);
  int maxN = 100000000;
  for (int i = 0; i < 3 * n * n; i++) {
    lol[i].resize(3 * n * n);
    for (int j = 0; j < 3 * n * n; j++) {
      lol[i][j] = make_pair(maxN, maxN);
      int fig1 = i / (n * n);
      int fig2 = j / (n * n);
      int x1 = v[i % (n * n)].first;
      int y1 = v[i % (n * n)].second;
      int x2 = v[j % (n * n)].first;
      int y2 = v[j % (n * n)].second;
      if (fig1 != fig2 && (i - j) % (n * n) == 0) lol[i][j] = make_pair(1, 1);
      if (fig1 == fig2 && i != j) {
        if ((x1 == x2 || y1 == y2) && fig1 == 0) lol[i][j] = make_pair(1, 0);
        if ((x1 - y1 == x2 - y2 || x1 + y1 == x2 + y2) && fig1 == 1)
          lol[i][j] = make_pair(1, 0);
        if (abs((x1 - x2) * (y1 - y2)) == 2 && fig1 == 2)
          lol[i][j] = make_pair(1, 0);
      }
    }
    lol[i][i] = make_pair(0, 0);
  }
  for (int k = 0; k < 3 * n * n; k++)
    for (int j = 0; j < 3 * n * n; j++)
      for (int i = 0; i < 3 * n * n; i++) {
        if (lol[i][j].first > lol[i][k].first + lol[k][j].first)
          lol[i][j] = make_pair(lol[i][k].first + lol[k][j].first,
                                lol[i][k].second + lol[k][j].second);
        if (lol[i][j].first == lol[i][k].first + lol[k][j].first)
          lol[i][j] = make_pair(
              lol[i][j].first,
              min(lol[i][j].second, lol[i][k].second + lol[k][j].second));
      }
  vector<vector<pair<int, int>>> dist(n * n);
  for (int i = 0; i < n * n; i++) dist[i].resize(3);
  dist[0][0] = make_pair(0, 0);
  dist[0][1] = make_pair(0, 0);
  dist[0][2] = make_pair(0, 0);
  for (int k = 1; k < n * n; k++) {
    for (int thisfig = 0; thisfig < 3; thisfig++) {
      int m = 0;
      int j = n * n * thisfig + k;
      for (int thatfig = 1; thatfig < 3; thatfig++) {
        int im = n * n * m + k - 1;
        int i = n * n * thatfig + (k - 1);
        if (dist[k - 1][thatfig].first + lol[i][j].first <
            dist[k - 1][m].first + lol[im][j].first)
          m = thatfig;
        if (dist[k - 1][thatfig].first + lol[i][j].first ==
                dist[k - 1][m].first + lol[im][j].first &&
            dist[k - 1][thatfig].second + lol[i][j].second <
                dist[k - 1][m].second + lol[im][j].second)
          m = thatfig;
      }
      int im = n * n * m + k - 1;
      dist[k][thisfig] = make_pair(dist[k - 1][m].first + lol[im][j].first,
                                   dist[k - 1][m].second + lol[im][j].second);
    }
  }
  int m = 0;
  int k = n * n - 1;
  for (int fig = 1; fig < 3; fig++) {
    if (dist[k][fig].first < dist[k][m].first) m = fig;
    if (dist[k][fig].first == dist[k][m].first &&
        dist[k][fig].second < dist[k][m].second)
      m = fig;
  }
  cout << dist[k][m].first << " " << dist[k][m].second;
}
