#include <bits/stdc++.h>
using namespace std;
int n, m = 0, k, l, g[20][20], h[310],
       ma[8][2] = {{1, 2},  {2, 1},  {-1, 2},  {-2, 1},
                   {1, -2}, {2, -1}, {-1, -2}, {-2, -1}},
       d[310][310], dc[310][310], dp[310], c[310];
void cone(int x, int y) {
  d[x][y] = d[y][x] = 1;
  dc[x][y] = dc[y][x] = !((x - y) % (n * n));
  return;
}
int mx(int x, int y) { return x > y ? x : y; }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &g[i][j]);
  for (int i = 1; i <= n * n * 3; i++)
    for (int j = 1; j <= n * n * 3; j++)
      d[i][j] = dc[i][j] = (i == j) ? 0 : 1e9;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cone(g[i][j], g[i][j] + n * n);
      cone(g[i][j], g[i][j] + n * n * 2);
      cone(g[i][j] + n * n, g[i][j] + n * n * 2);
      for (int a = 0; a < n; a++) {
        if (j ^ a) cone(g[i][j], g[i][a]);
        if (i ^ a) cone(g[i][j], g[a][j]);
        k = j - i + a;
        if (k >= 0 && k < n && (a ^ i))
          cone(g[i][j] + n * n * 2, g[a][k] + n * n * 2);
        k = j * 2 - k;
        if (k >= 0 && k < n && (a ^ i))
          cone(g[i][j] + n * n * 2, g[a][k] + n * n * 2);
      }
      for (int a = 0; a < 8; a++)
        if (i + ma[a][0] >= 0 && i + ma[a][0] < n && j + ma[a][1] >= 0 &&
            j + ma[a][1] < n)
          cone(g[i][j] + n * n, g[i + ma[a][0]][j + ma[a][1]] + n * n);
    }
  for (int a = 1; a <= n * n * 3; a++)
    for (int i = 1; i <= n * n * 3; i++)
      for (int j = 1; j <= n * n * 3; j++)
        if (d[i][j] > d[i][a] + d[a][j] ||
            (d[i][j] == d[i][a] + d[a][j] && dc[i][j] > dc[i][a] + dc[a][j])) {
          d[i][j] = d[i][a] + d[a][j];
          dc[i][j] = dc[i][a] + dc[a][j];
        }
  for (int i = 1; i <= n * n * 3; i++) dp[i] = c[i] = 1e9;
  dp[1] = dp[n * n + 1] = dp[n * n * 2 + 1] = 0;
  c[1] = c[n * n + 1] = c[n * n * 2 + 1] = 0;
  for (int i = 2; i <= n * n; i++)
    for (int j = 0; j < n * n * 3; j += n * n)
      for (int a = 0; a < n * n * 3; a += n * n) {
        if (dp[i + j] > dp[i + a - 1] + d[i + a - 1][i + j] ||
            (dp[i + j] == dp[i + a - 1] + d[i + a - 1][i + j] &&
             c[i + j] > c[i + a - 1] + dc[i + a - 1][i + j])) {
          dp[i + j] = dp[i + a - 1] + d[i + a - 1][i + j];
          c[i + j] = c[i + a - 1] + dc[i + a - 1][i + j];
        }
      }
  k = dp[n * n];
  l = c[n * n];
  if (dp[n * n * 2] < k || (dp[n * n * 2] == k && c[n * n * 2] < l)) {
    k = dp[n * n * 2];
    l = c[n * n * 2];
  }
  if (dp[n * n * 3] < k || (dp[n * n * 3] == k && c[n * n * 3] < l)) {
    k = dp[n * n * 3];
    l = c[n * n * 3];
  }
  printf("%d %d\n", k, l);
  return 0;
}
