#include <bits/stdc++.h>
const long double PI = 3.14159265358979323846;
using namespace std;
struct jj {
  int step, change;
} vis[10][10][3];
struct kk {
  int x, y, kind, step, change;
} a[100];
int walk[3][8][2] = {
    {{0, 1}, {1, 0}, {-1, 0}, {0, -1}},
    {{1, 1}, {-1, 1}, {1, -1}, {-1, -1}},
    {{1, 2}, {2, 1}, {-1, 2}, {2, -1}, {1, -2}, {-2, 1}, {-1, -2}, {-2, -1}}};
void bfs(int n) {
  int i, i1, i2, ans = 0x3f3f3f3f, change, temp, tempchange;
  struct jj kind0, kind1, kind2;
  struct kk pre, pos;
  queue<struct kk> q;
  for (i = 0; 3 > i; i++) {
    for (i1 = 0; n * n - 1 > i1; i1++) {
      if (i1 != 0) {
        kind0 = vis[a[i1].x][a[i1].y][0];
        kind1 = vis[a[i1].x][a[i1].y][1];
        kind2 = vis[a[i1].x][a[i1].y][2];
      }
      memset(vis, 0x3f3f3f3f, sizeof(vis));
      if (i1 == 0) {
        vis[a[i1].x][a[i1].y][i].step = vis[a[i1].x][a[i1].y][i].change = 0;
        q.push(kk{a[i1].x, a[i1].y, i, 0, 0});
      } else {
        vis[a[i1].x][a[i1].y][0] = kind0;
        vis[a[i1].x][a[i1].y][1] = kind1;
        vis[a[i1].x][a[i1].y][2] = kind2;
        q.push(kk{a[i1].x, a[i1].y, 0, kind0.step, kind0.change});
        q.push(kk{a[i1].x, a[i1].y, 1, kind1.step, kind1.change});
        q.push(kk{a[i1].x, a[i1].y, 2, kind2.step, kind2.change});
      }
      while (q.empty() == 0) {
        pre = q.front();
        q.pop();
        if (pre.kind == 0) {
          for (i2 = 0; 4 > i2; i2++) {
            pos = pre;
            pos.step++;
            while (1) {
              pos.x = pos.x + walk[0][i2][0];
              pos.y = pos.y + walk[0][i2][1];
              if (pos.x < 0 || pos.x >= n || pos.y < 0 || pos.y >= n) {
                break;
              }
              if (vis[pos.x][pos.y][pos.kind].step > pos.step ||
                  (vis[pos.x][pos.y][pos.kind].step == pos.step &&
                   vis[pos.x][pos.y][pos.kind].change > pos.change)) {
                vis[pos.x][pos.y][pos.kind].step = pos.step;
                vis[pos.x][pos.y][pos.kind].change = pos.change;
                q.push(pos);
              }
            }
          }
        } else if (pre.kind == 1) {
          for (i2 = 0; 4 > i2; i2++) {
            pos = pre;
            pos.step++;
            while (1) {
              pos.x = pos.x + walk[1][i2][0];
              pos.y = pos.y + walk[1][i2][1];
              if (pos.x < 0 || pos.x >= n || pos.y < 0 || pos.y >= n) {
                break;
              }
              if (vis[pos.x][pos.y][pos.kind].step > pos.step ||
                  (vis[pos.x][pos.y][pos.kind].step == pos.step &&
                   vis[pos.x][pos.y][pos.kind].change > pos.change)) {
                vis[pos.x][pos.y][pos.kind].step = pos.step;
                vis[pos.x][pos.y][pos.kind].change = pos.change;
                q.push(pos);
              }
            }
          }
        } else {
          for (i2 = 0; 8 > i2; i2++) {
            pos.x = pre.x + walk[2][i2][0];
            pos.y = pre.y + walk[2][i2][1];
            pos.step = pre.step + 1;
            pos.kind = pre.kind;
            pos.change = pre.change;
            if (pos.x >= 0 && pos.x < n && pos.y >= 0 && pos.y < n &&
                (vis[pos.x][pos.y][pos.kind].step > pos.step ||
                 (vis[pos.x][pos.y][pos.kind].step == pos.step &&
                  vis[pos.x][pos.y][pos.kind].change > pos.change))) {
              vis[pos.x][pos.y][pos.kind].step = pos.step;
              vis[pos.x][pos.y][pos.kind].change = pos.change;
              q.push(pos);
            }
          }
        }
        pos = pre;
        for (i2 = 0; 3 > i2; i2++) {
          if (pre.kind != i2) {
            pos.kind = i2;
            pos.step = pre.step + 1;
            pos.change = pre.change + 1;
            if (vis[pos.x][pos.y][pos.kind].step > pos.step ||
                (vis[pos.x][pos.y][pos.kind].step == pos.step &&
                 vis[pos.x][pos.y][pos.kind].change > pos.change)) {
              vis[pos.x][pos.y][pos.kind].step = pos.step;
              vis[pos.x][pos.y][pos.kind].change = pos.change;
              q.push(pos);
            }
          }
        }
      }
    }
    temp = 0x3f3f3f3f;
    for (i1 = 0; 3 > i1; i1++) {
      if (temp > vis[a[n * n - 1].x][a[n * n - 1].y][i1].step ||
          (temp == vis[a[n * n - 1].x][a[n * n - 1].y][i1].step &&
           tempchange > vis[a[n * n - 1].x][a[n * n - 1].y][i1].change)) {
        temp = vis[a[n * n - 1].x][a[n * n - 1].y][i1].step;
        tempchange = vis[a[n * n - 1].x][a[n * n - 1].y][i1].change;
      }
    }
    if (ans > temp || (ans == temp && change > tempchange)) {
      ans = temp;
      change = tempchange;
    }
  }
  printf("%d %d", ans, change);
}
int main() {
  int n, i, i1, x;
  scanf("%d", &n);
  for (i = 0; n > i; i++) {
    for (i1 = 0; n > i1; i1++) {
      scanf("%d", &x);
      a[x - 1].x = i;
      a[x - 1].y = i1;
    }
  }
  bfs(n);
  return 0;
}
