#include <bits/stdc++.h>
using namespace std;
template <class T, class T2>
inline int chkmax(T &x, const T2 &y) {
  return x < y ? x = y, 1 : 0;
}
template <class T, class T2>
inline int chkmin(T &x, const T2 &y) {
  return x > y ? x = y, 1 : 0;
}
const int MAXN = 15;
const int inf = (int)1e9;
int n;
pair<int, int> pos[MAXN * MAXN];
bool ok(int x, int y) { return x >= 0 && y >= 0 && x < n && y < n; }
vector<int> dx[3];
vector<int> dy[3];
void read() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      int x;
      cin >> x;
      pos[x] = {i, j};
    }
}
pair<int, int> dist[MAXN * MAXN][MAXN][MAXN][3];
struct state {
  int x, y, val, f;
  state() { x = y = val = f = 0; }
  state(int v, int i, int j, int o) {
    f = o;
    x = i;
    y = j;
    val = v;
  }
};
pair<int, int> add_f(pair<int, int> a) { return {a.first + 1, a.second}; }
pair<int, int> add_b(pair<int, int> a) { return {a.first + 1, a.second + 1}; }
void solve() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int v = 1; v <= n * n; v++)
        for (int b = 0; b < 3; b++) dist[v][i][j][b] = {inf, inf};
  deque<state> q;
  q.push_back(state(1, pos[1].first, pos[1].second, 0));
  q.push_back(state(1, pos[1].first, pos[1].second, 1));
  q.push_back(state(1, pos[1].first, pos[1].second, 2));
  dist[1][pos[1].first][pos[1].second][0] = {0, 0};
  dist[1][pos[1].first][pos[1].second][1] = {0, 0};
  dist[1][pos[1].first][pos[1].second][2] = {0, 0};
  while (!q.empty()) {
    auto tp = q.front();
    q.pop_front();
    int v = tp.val, i = tp.x, j = tp.y, type = tp.f;
    if (v < n * n && pos[v] == make_pair(i, j))
      if (chkmin(dist[v + 1][i][j][type], dist[v][i][j][type]))
        q.push_front(state(v + 1, i, j, type));
    if (type == 2)
      for (int ii = 0; ii < 8; ii++) {
        int x = i + dx[2][ii], y = j + dy[2][ii];
        if (!ok(x, y)) continue;
        if (chkmin(dist[v][x][y][type], add_f(dist[v][i][j][type])))
          q.push_back(state(v, x, y, type));
      }
    else {
      for (int s = 1; s <= n; s++) {
        for (int ii = 0; ii < 4; ii++) {
          int x = i + s * dx[type][ii], y = j + s * dy[type][ii];
          if (!ok(x, y)) continue;
          if (chkmin(dist[v][x][y][type], add_f(dist[v][i][j][type])))
            q.push_back(state(v, x, y, type));
        }
      }
    }
    for (int nt = 0; nt < 3; nt++)
      if (chkmin(dist[v][i][j][nt], add_b(dist[v][i][j][type])))
        q.push_back(state(v, i, j, nt));
  }
  pair<int, int> answer = {inf, inf};
  for (int f = 0; f < 3; f++)
    chkmin(answer, dist[n * n][pos[n * n].first][pos[n * n].second][f]);
  cout << answer.first << " " << answer.second << '\n';
}
void prepare() {
  dx[0] = {1, 0, -1, 0};
  dy[0] = {0, -1, 0, 1};
  dx[1] = {1, 1, -1, -1};
  dy[1] = {-1, 1, -1, 1};
  dx[2] = {2, -2, -2, 2, 1, -1, 1, -1};
  dy[2] = {1, 1, -1, -1, 2, 2, -2, -2};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  prepare();
  read();
  solve();
  return 0;
}
