#include <bits/stdc++.h>
int n;
int matrix[12][12];
struct state {
  state() { no_repl = 0; }
  int no_steps;
  int no_repl;
};
int pos[105][2];
state dp[12][12][3];
state dp_in_order[102][3];
int knight[][2] = {{-2, -1}, {-2, 1}, {-1, 2}, {-1, -2},
                   {1, 2},   {1, -2}, {2, -1}, {2, 1}};
int MAX_INT = 99999999;
void fill_dp(int x, int y);
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      scanf("%d", matrix[i] + j);
      pos[matrix[i][j]][0] = i;
      pos[matrix[i][j]][1] = j;
    }
  for (int i = 0; i <= 10; i++)
    for (int j = 0; j <= 10; j++)
      dp[i][j][0].no_steps = dp[i][j][1].no_steps = dp[i][j][2].no_steps =
          MAX_INT;
  int n2 = n * n;
  dp_in_order[1][0].no_steps = 0;
  dp_in_order[1][1].no_steps = 0;
  dp_in_order[1][2].no_steps = 0;
  for (int move = 1; move < n2; move++) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int f = 0; f < 3; f++) dp[i][j][f].no_steps = MAX_INT;
    for (int f = 0; f < 3; f++) {
      dp[pos[move][0]][pos[move][1]][f].no_steps =
          dp_in_order[move][f].no_steps;
      dp[pos[move][0]][pos[move][1]][f].no_repl = dp_in_order[move][f].no_repl;
    }
    fill_dp(pos[move][1], pos[move][0]);
    for (int f = 0; f < 3; f++) {
      dp_in_order[move + 1][f].no_steps =
          dp[pos[move + 1][0]][pos[move + 1][1]][f].no_steps;
      dp_in_order[move + 1][f].no_repl =
          dp[pos[move + 1][0]][pos[move + 1][1]][f].no_repl;
    }
  }
  int score = MAX_INT;
  int no_trans = MAX_INT;
  for (int fig = 0; fig < 3; fig++) {
    if (dp_in_order[n2][fig].no_steps < score) {
      score = dp_in_order[n2][fig].no_steps;
      no_trans = dp_in_order[n2][fig].no_repl;
    } else if (dp_in_order[n2][fig].no_steps == score &&
               dp_in_order[n2][fig].no_repl < no_trans) {
      score = dp_in_order[n2][fig].no_steps;
      no_trans = dp_in_order[n2][fig].no_repl;
    }
  }
  printf("%d %d\n", score, no_trans);
  return 0;
}
struct vis_state {
  int y, x;
  int fig;
  int no_moves;
  int no_trans;
};
void fill_dp(int start_x, int start_y) {
  std::queue<vis_state> q;
  for (int f = 0; f < 3; f++) {
    q.push({start_y, start_x, f, dp[start_y][start_x][f].no_steps,
            dp[start_y][start_x][f].no_repl});
    dp[start_y][start_x][f].no_steps = MAX_INT;
  }
  while (!q.empty()) {
    vis_state vs = q.front();
    q.pop();
    if (dp[vs.y][vs.x][vs.fig].no_steps < vs.no_moves ||
        (dp[vs.y][vs.x][vs.fig].no_steps == vs.no_moves &&
         dp[vs.y][vs.x][vs.fig].no_repl <= vs.no_trans)) {
      continue;
    }
    dp[vs.y][vs.x][vs.fig].no_steps = vs.no_moves;
    dp[vs.y][vs.x][vs.fig].no_repl = vs.no_trans;
    if (vs.fig == 0) {
      for (int h = 0; h < 8; h++) {
        int newx = vs.x + knight[h][0];
        int newy = vs.y + knight[h][1];
        if (newx >= 0 && newx <= n - 1 && newy >= 0 && newy <= n - 1) {
          vis_state new_state = {newy, newx, vs.fig, vs.no_moves + 1,
                                 vs.no_trans};
          q.push(new_state);
        }
      }
    } else if (vs.fig == 1) {
      for (int h = -n; h <= n; h++) {
        for (int t = -1; t <= 1; t += 2) {
          int newx = vs.x + h;
          int newy = vs.y + t * h;
          if (newx >= 0 && newx <= n - 1 && newy >= 0 && newy <= n - 1) {
            vis_state new_state = {newy, newx, vs.fig, vs.no_moves + 1,
                                   vs.no_trans};
            q.push(new_state);
          }
        }
      }
    } else if (vs.fig == 2) {
      for (int h = -n; h <= n; h++) {
        for (int t = 0; t <= 1; t++) {
          int newx = vs.x + h;
          int newy = vs.y;
          if (t == 1) {
            newx = vs.x;
            newy = vs.y + h;
          }
          if (newx >= 0 && newx <= n - 1 && newy >= 0 && newy <= n - 1) {
            vis_state new_state = {newy, newx, vs.fig, vs.no_moves + 1,
                                   vs.no_trans};
            q.push(new_state);
          }
        }
      }
    }
    for (int f = 0; f < 3; f++) {
      if (f == vs.fig)
        continue;
      else {
        vis_state new_state = {vs.y, vs.x, f, vs.no_moves + 1, vs.no_trans + 1};
        q.push(new_state);
      }
    }
  }
}
