#include <bits/stdc++.h>
using namespace std;
pair<int, int> dp[12][12][3][102];
int a[12][12], n;
int X[8] = {2, 1, -1, -2, -2, -1, 1, 2};
int Y[8] = {1, 2, 2, 1, -1, -2, -2, -1};
pair<int, int> go(int x, int y, int curr, int target) {
  if (a[x][y] == target && target == n * n) {
    return make_pair(0, 0);
  }
  pair<int, int>& ret = dp[x][y][curr][target];
  pair<int, int> p;
  if (ret.first != -1) return ret;
  int i, j;
  ret = {(int)1e8, (int)1e8};
  if (a[x][y] == target) target++;
  for (i = 0; i < 8; i++) {
    int nowx = x + X[i], nowy = y + Y[i];
    if (nowx >= 1 && nowx <= n && nowy >= 1 && nowy <= n) {
      p = go(nowx, nowy, 0, target);
      p.first++;
      if (curr != 0) {
        p.second++;
        p.first++;
      }
      ret = min(ret, p);
    }
  }
  for (j = 1;; j++) {
    int nowx = x, nowy = y + j;
    if (nowy > n) break;
    p = go(nowx, nowy, 1, target);
    p.first++;
    if (curr != 1) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (j = 1;; j++) {
    int nowx = x, nowy = y - j;
    if (nowy <= 0) break;
    p = go(nowx, nowy, 1, target);
    p.first++;
    if (curr != 1) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (i = 1;; i++) {
    int nowx = x + i, nowy = y;
    if (nowx > n) break;
    p = go(nowx, nowy, 1, target);
    p.first++;
    if (curr != 1) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (i = 1;; i++) {
    int nowx = x - i, nowy = y;
    if (nowx <= 0) break;
    p = go(nowx, nowy, 1, target);
    p.first++;
    if (curr != 1) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (i = 1;; i++) {
    int nowx = x + i, nowy = y + i;
    if (nowx > n || nowy > n) break;
    p = go(nowx, nowy, 2, target);
    p.first++;
    if (curr != 2) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (i = 1;; i++) {
    int nowx = x - i, nowy = y - i;
    if (nowx <= 0 || nowy <= 0) break;
    p = go(nowx, nowy, 2, target);
    p.first++;
    if (curr != 2) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (i = 1;; i++) {
    int nowx = x + i, nowy = y - i;
    if (nowx <= 0 || nowx > n || nowy > n || nowy <= 0) break;
    p = go(nowx, nowy, 2, target);
    p.first++;
    if (curr != 2) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  for (i = 1;; i++) {
    int nowx = x - i, nowy = y + i;
    if (nowx <= 0 || nowx > n || nowy > n || nowy <= 0) break;
    p = go(nowx, nowy, 2, target);
    p.first++;
    if (curr != 2) {
      p.second++;
      p.first++;
    }
    ret = min(ret, p);
  }
  return ret;
}
int main() {
  int i, j, sx, sy;
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j] == 1) {
        sx = i, sy = j;
      }
    }
  }
  pair<int, int> ans = go(sx, sy, 0, 1);
  ans = min(ans, min(go(sx, sy, 1, 1), go(sx, sy, 2, 1)));
  printf("%d %d\n", ans.first, ans.second);
  return 0;
}
