#include <bits/stdc++.h>
using namespace std;
int n, m, dx[] = {-1, -1, 1, 1, -2, -2, 2, 2},
          dy[] = {-2, 2, -2, 2, 1, -1, -1, 1};
int seen[112][112], TC = 0, dpsin[112][4][10];
pair<int, int> dp[112][4][10], xy[112];
pair<int, int> combine(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) return a;
  if (a.first > b.first) return b;
  return {a.first, min(b.second, a.second)};
}
pair<int, int> diff(pair<int, int> a, pair<int, int> b) {
  return {abs(a.first - b.first), abs(a.second - b.second)};
}
pair<int, int> sum(pair<int, int> a, pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
queue<pair<pair<int, int>, int> > q;
int bfs(int idx) {
  ++TC;
  q.push({xy[idx], 0});
  pair<pair<int, int>, int> arq;
  int a, b, ans = 0x3f3f3f3f;
  while (!q.empty()) {
    arq = q.front();
    q.pop();
    if (arq.first == xy[idx + 1]) ans = min(ans, arq.second);
    for (int i = 0; i < 8 && ans == 0x3f3f3f3f; ++i) {
      a = arq.first.first + dx[i], b = arq.first.second + dy[i];
      if (a < 1 || b < 1 || a > n | b > n) continue;
      if (seen[a][b] != TC) {
        q.push({{a, b}, arq.second + 1});
        seen[a][b] = TC;
      }
    }
  }
  return ans;
}
pair<int, int> knishop(int idx, int f) {
  pair<int, int> nxt;
  for (int i = 0; i < 8; ++i) {
    nxt = sum(xy[idx + f], {dx[i], dy[i]});
    if (nxt.first < 1 || nxt.second < 1 || nxt.first > n || nxt.second > n)
      continue;
    nxt = diff(xy[idx + 1 - f], nxt);
    if (nxt.first == nxt.second) return {3, 1};
  }
  return {0x3f3f3f3f, 0x3f3f3f3f};
}
pair<int, int> sol(int idx, int maskc, int maskp) {
  if (idx == m) return {0, 0};
  if (dpsin[idx][maskc][maskp]) return dp[idx][maskc][maskp];
  pair<int, int> ans = {0x3f3f3f3f, 0x3f3f3f3f},
                 nxt = diff(xy[idx], xy[idx + 1]);
  for (int i = 0; i < 3; ++i)
    if (~maskp & (1 << i))
      ans = combine(ans, sum(sol(idx, i, maskp | (1 << i)), {1, 1}));
  if (!maskc) {
    ans =
        combine(ans, sum(sol(idx + 1, 0, 1),
                         {(int)(nxt.first != 0) + (int)(nxt.second != 0), 0}));
  } else if (maskc & 1) {
    if (~(nxt.first + nxt.second) & 1)
      ans = combine(ans, sum(sol(idx + 1, 1, 2),
                             {2 - (int)(nxt.first == nxt.second), 0}));
    ans = combine(ans, sum(sol(idx + 1, 2, 4), knishop(idx, 1)));
  } else {
    int a = bfs(idx);
    if (a != 0x3f3f3f3f) ans = combine(ans, sum(sol(idx + 1, 2, 4), {a, 0}));
    ans = combine(ans, sum(sol(idx + 1, 1, 2), knishop(idx, 0)));
  }
  dpsin[idx][maskc][maskp] = 1;
  return dp[idx][maskc][maskp] = ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &x);
      xy[x] = {i, j};
    }
  }
  m = n * n;
  pair<int, int> ans =
      combine(combine(sol(1, 0, 1), sol(1, 1, 2)), sol(1, 2, 4));
  printf("%d %d\n", ans.first, ans.second);
}
