#include <bits/stdc++.h>
using namespace std;
int N;
int x[110], y[110];
struct S {
  int xc, yc, type, sq;
  S(const int v1, const int v2, const int v3, const int v4) {
    xc = v1;
    yc = v2;
    type = v3;
    sq = v4;
  }
};
queue<S> Q1;
vector<vector<int> > dx = {{}, {}, {-1, -2, -2, -1, 1, 2, 2, 1}};
vector<vector<int> > dy = {{}, {}, {-2, -1, 1, 2, 2, 1, -1, -2}};
int D[3][101][11][11];
int replacements[3][101][11][11];
void BFS() {
  int dist = 1;
  memset(D, -1, sizeof(D));
  memset(replacements, 0, sizeof(replacements));
  queue<S> Q2;
  for (int i = 0; i < 3; i++)
    Q1.push(S(x[1], y[1], i, 1)), D[i][1][x[1]][y[1]] = 0;
  while (!Q1.empty()) {
    while (!Q1.empty()) {
      auto& v = Q1.front();
      Q1.pop();
      if (D[v.type][v.sq][v.xc][v.yc] < dist - 1) continue;
      if (v.sq == N * N) continue;
      if (v.xc == x[v.sq + 1] && v.yc == y[v.sq + 1]) {
        if (D[v.type][v.sq + 1][v.xc][v.yc] == -1 ||
            D[v.type][v.sq + 1][v.xc][v.yc] >= dist - 1) {
          if (D[v.type][v.sq + 1][v.xc][v.yc] == -1 ||
              D[v.type][v.sq + 1][v.xc][v.yc] == dist) {
            D[v.type][v.sq + 1][v.xc][v.yc] = dist - 1;
            Q1.push(S(v.xc, v.yc, v.type, v.sq + 1));
            replacements[v.type][v.sq + 1][v.xc][v.yc] =
                replacements[v.type][v.sq][v.xc][v.yc];
          } else
            replacements[v.type][v.sq + 1][v.xc][v.yc] =
                min(replacements[v.type][v.sq + 1][v.xc][v.yc],
                    replacements[v.type][v.sq][v.xc][v.yc]);
        }
      }
      for (int p = 0; p < 3; p++) {
        if (p != v.type) {
          if (D[p][v.sq][v.xc][v.yc] == -1) {
            D[p][v.sq][v.xc][v.yc] = dist;
            Q2.push(S(v.xc, v.yc, p, v.sq));
            replacements[p][v.sq][v.xc][v.yc] =
                replacements[v.type][v.sq][v.xc][v.yc] + 1;
          } else if (D[p][v.sq][v.xc][v.yc] == dist)
            replacements[p][v.sq][v.xc][v.yc] =
                min(replacements[p][v.sq][v.xc][v.yc],
                    replacements[v.type][v.sq][v.xc][v.yc] + 1);
        }
      }
      for (int i = 0; i < (int)dx[v.type].size(); i++) {
        int cx = v.xc + dx[v.type][i];
        int cy = v.yc + dy[v.type][i];
        if (cx >= 1 && cx <= N && cy >= 1 && cy <= N &&
            (D[v.type][v.sq][cx][cy] == -1 ||
             D[v.type][v.sq][cx][cy] == dist)) {
          if (D[v.type][v.sq][cx][cy] == dist)
            replacements[v.type][v.sq][cx][cy] =
                min(replacements[v.type][v.sq][cx][cy],
                    replacements[v.type][v.sq][v.xc][v.yc]);
          else {
            D[v.type][v.sq][cx][cy] = dist;
            Q2.push(S(cx, cy, v.type, v.sq));
            replacements[v.type][v.sq][cx][cy] =
                replacements[v.type][v.sq][v.xc][v.yc];
          }
        }
      }
    }
    Q1 = Q2;
    Q2 = queue<S>();
    dist++;
  }
}
int main() {
  int v;
  vector<pair<int, int> > V;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    dx[0].push_back(-i), dx[0].push_back(0), dx[0].push_back(i),
        dx[0].push_back(0);
    dy[0].push_back(0), dy[0].push_back(i), dy[0].push_back(0),
        dy[0].push_back(-i);
    dx[1].push_back(i), dx[1].push_back(i), dx[1].push_back(-i),
        dx[1].push_back(-i);
    dy[1].push_back(-i), dy[1].push_back(i), dy[1].push_back(-i),
        dy[1].push_back(i);
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) scanf("%d", &v), x[v] = i, y[v] = j;
  BFS();
  for (int i = 0; i < 3; i++)
    if (D[i][N * N][x[N * N]][y[N * N]] != -1)
      V.push_back(pair<int, int>(D[i][N * N][x[N * N]][y[N * N]],
                                 replacements[i][N * N][x[N * N]][y[N * N]]));
  sort(V.begin(), V.end());
  printf("%d %d\n", V[0].first, V[0].second);
  return 0;
}
