#include <bits/stdc++.h>
using namespace std;
int N, Mat[11][11];
pair<int, int> d[101][3], c[101][3];
pair<int, int> pos[105];
vector<int> BGraph[101];
vector<int> KGraph[101];
vector<pair<pair<int, int>, pair<int, int> > > Graph[101][3];
int dx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};
int dy[8] = {-1, 1, -2, 2, -2, 2, -1, 1};
int Rook(pair<int, int> s, pair<int, int> e) {
  if (s.first == e.first || s.second == e.second)
    return 1;
  else
    return 2;
}
bool comp(pair<int, int> const &a, pair<int, int> const &b) {
  return a.first > b.first || (a.first == b.first && a.second > b.second);
}
void precalc(int n) {
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      for (int k = 0; k < 8; k++)
        if (i + dx[k] > 0 && i + dx[k] <= N && j + dy[k] > 0 && j + dy[k] <= N)
          KGraph[Mat[i][j]].push_back(Mat[i + dx[k]][j + dy[k]]);
      for (int k = -N; k <= N; k++)
        if (i + k > 0 && i + k <= N && j + k > 0 && j + k <= N && k)
          BGraph[Mat[i][j]].push_back(Mat[i + k][j + k]);
      for (int k = -N; k <= N; k++)
        if (i + k > 0 && i + k <= N && j - k > 0 && j - k <= N && k)
          BGraph[Mat[i][j]].push_back(Mat[i + k][j - k]);
    }
  for (int i = 1; i <= N * N; i++)
    for (int j = 0; j < 3; j++) {
      if (j == 0)
        for (int k = 0; k < KGraph[i].size(); k++)
          Graph[i][j].push_back({{KGraph[i][k], j}, {1, 0}});
      else if (j == 1)
        for (int k = 0; k < BGraph[i].size(); k++)
          Graph[i][j].push_back({{BGraph[i][k], j}, {1, 0}});
      else
        for (int k = 1; k <= N * N; k++) {
          if (k == i) continue;
          Graph[i][j].push_back({{k, j}, {Rook(pos[i], pos[k]), 0}});
        }
      for (int k = 0; k < 3; k++) {
        if (k == j) continue;
        Graph[i][j].push_back({{i, k}, {1, 1}});
      }
    }
}
pair<int, int> add(pair<int, int> a, pair<int, int> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<int, int> BFS(pair<int, int> s, pair<int, int> e) {
  pair<int, int> son, cost;
  queue<pair<int, int> > Q;
  for (int i = 1; i <= N * N; i++)
    for (int j = 0; j < 3; j++) c[i][j] = make_pair(214000000, 214000000);
  c[s.first][s.second] = make_pair(0, 0);
  Q.push(s);
  while (!Q.empty()) {
    s = Q.front();
    Q.pop();
    for (int i = 0; i < Graph[s.first][s.second].size(); i++) {
      son = Graph[s.first][s.second][i].first;
      cost = Graph[s.first][s.second][i].second;
      if (comp(c[son.first][son.second], add(c[s.first][s.second], cost))) {
        c[son.first][son.second] = add(c[s.first][s.second], cost);
        Q.push(son);
      }
    }
  }
  return c[e.first][e.second];
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) {
      int X;
      scanf("%d", &X);
      Mat[i][j] = X;
      pos[X] = {i, j};
    }
  precalc(N);
  for (int i = 2; i <= N * N; i++)
    for (int j = 0; j < 3; j++) {
      d[i][j] = make_pair(214000000, 214000000);
      for (int k = 0; k < 3; k++) {
        BFS(make_pair(i - 1, k), make_pair(i, j));
        if (comp(d[i][j], add(d[i - 1][k], c[i][j])))
          d[i][j] = add(d[i - 1][k], c[i][j]);
      }
    }
  pair<int, int> aux = d[N * N][0];
  if (comp(aux, d[N * N][1])) aux = d[N * N][1];
  if (comp(aux, d[N * N][2])) aux = d[N * N][2];
  printf("%d %d\n", aux.first, aux.second);
  return 0;
}
