#include <bits/stdc++.h>
#pragma optimize("avx")
#pragma optimize("no-stack-protector")
namespace io {
inline char gnc() { return (char)getchar(); }
template <typename T>
inline void gi(T &dx) {
  dx = 0;
  int yc = gnc();
  bool nega = false;
  while (yc < '0' || yc > '9') {
    nega = (yc == '-' ? true : nega);
    yc = gnc();
  }
  while (yc >= '0' && yc <= '9') {
    dx = (T)(dx * 10 + yc - '0');
    yc = gnc();
  }
  if (nega) {
    dx = -dx;
  }
}
void gc(char &a) {
  do a = gnc();
  while (!isgraph(a));
}
void gss(char *c) {
  *c = gnc();
  while (!isgraph(*c)) *c = gnc();
  while (isgraph(*c)) *++c = gnc();
  *c = 0;
}
template <typename t1, typename t2>
inline void gi(t1 &a, t2 &b) {
  gi(a);
  gi(b);
}
template <typename t1, typename t2, typename t3>
inline void gi(t1 &a, t2 &b, t3 &c) {
  gi(a);
  gi(b);
  gi(c);
}
template <typename t1, typename t2, typename t3, typename t4>
inline void gi(t1 &a, t2 &b, t3 &c, t4 &d) {
  gi(a);
  gi(b);
  gi(c);
  gi(d);
}
template <typename t1, typename t2, typename t3, typename t4, typename t5>
inline void gi(t1 &a, t2 &b, t3 &c, t4 &d, t5 &e) {
  gi(a);
  gi(b);
  gi(c);
  gi(d);
  gi(e);
}
}  // namespace io
using namespace io;
using namespace std;
inline int gcd(int x, int y) {
  return y > x ? gcd(y, x) : y ? gcd(y, x % y) : x;
}
inline void exgcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - (a / b) * y;
}
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
template <typename T>
inline void Sol(T &x) {
  if (x >= MOD) x -= MOD;
}
template <typename T1, typename T2>
inline void Inc(T1 &x, T2 y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
template <typename T1, typename T2>
inline void Dec(T1 &x, T2 y) {
  x += MOD - y;
  if (x >= MOD) x -= MOD;
}
inline long long qpow(long long x, int y) {
  long long res = 1;
  for (; y; y >>= 1, x = x * x % MOD)
    if (y & 1) res = res * x % MOD;
  return res;
}
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
template <typename T>
inline void Getmin(T &x, T y) {
  if (x > y) x = y;
}
template <typename T>
inline void Getmax(T &x, T y) {
  if (x < y) x = y;
}
const int maxn = 205;
int n, a[15][15];
pair<int, int> pos[maxn];
int d[maxn * 3][maxn * 3], tot, num, g[maxn * 3][maxn * 3];
inline int id1(int x, int y) { return (x - 1) * n + y; }
inline int id2(int x, int y) { return id1(x, y) + tot; }
inline int id3(int x, int y) { return id1(x, y) + tot * 2; }
inline void floyd() {
  for (int k = 1; k <= num; k++)
    for (int i = 1; i <= num; i++)
      for (int j = 1; j <= num; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          g[i][j] = g[i][k] + g[k][j];
        } else if (d[i][j] == d[i][k] + d[k][j])
          Getmin(g[i][j], g[i][k] + g[k][j]);
      }
  for (int k = 1; k <= num; k++)
    for (int i = 1; i <= num; i++)
      for (int j = 1; j <= num; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          g[i][j] = g[i][k] + g[k][j];
        } else if (d[i][j] == d[i][k] + d[k][j])
          Getmin(g[i][j], g[i][k] + g[k][j]);
      }
}
const int cx[] = {-1, 1, 2, 2, 1, -1, -2, -2};
const int cy[] = {2, 2, 1, -1, -2, -2, -1, 1};
int ans1[10], ans2[10];
inline void upd(int &x, int &y, int sx, int sy) {
  if (x > sx) {
    x = sx, y = sy;
  } else if (x == sx)
    Getmin(y, sy);
}
int main() {
  n = read();
  tot = n * n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      a[i][j] = read();
      pos[a[i][j]] = make_pair(i, j);
    }
  memset(d, 0x3f, sizeof d);
  memset(g, 0, sizeof g);
  num = tot * 3 + 1;
  int s = tot * 3 + 1;
  for (int i = 1; i <= num; i++) d[i][i] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int p1 = id1(i, j), p2 = p1 + tot, p3 = p2 + tot;
      d[p1][p2] = d[p2][p1] = d[p1][p3] = d[p3][p1] = d[p2][p3] = d[p3][p2] = 1;
      g[p1][p2] = g[p2][p1] = g[p1][p3] = g[p3][p1] = g[p2][p3] = g[p3][p2] = 1;
      for (int k = 1; k <= n; k++)
        Getmin(d[p1][id1(i, k)], 1), Getmin(d[p1][id1(k, j)], 1);
      for (int k = 0; k < 8; k++) {
        int x = i + cx[k], y = j + cy[k];
        if (x > 0 && y > 0 && x <= n && y <= n) Getmin(d[p2][id2(x, y)], 1);
      }
      for (int x = 1; x <= n; x++)
        for (int y = 1; y <= n; y++)
          if (x - y == i - j || x + y == i + j) Getmin(d[p3][id3(x, y)], 1);
    }
  }
  int p1 = id1(pos[1].first, pos[1].second), p2 = p1 + tot, p3 = p2 + tot;
  d[s][p1] = d[s][p2] = d[s][p3] = 0;
  p1 = id1(pos[tot].first, pos[tot].second);
  p2 = p1 + tot, p3 = p2 + tot;
  floyd();
  int now[5] = {0, s, s, s};
  memset(ans1, 0, sizeof ans1);
  for (int i = 1; i <= tot; i++) {
    static int p[5];
    p[1] = id1(pos[i].first, pos[i].second);
    p[2] = p[1] + tot;
    p[3] = p[2] + tot;
    static int pre1[5], pre2[5];
    for (int i = 1; i <= 3; i++) pre1[i] = ans1[i], pre2[i] = ans2[i];
    for (int j = 1; j <= 3; j++) {
      ans1[j] += d[now[j]][p[j]];
      ans2[j] += g[now[j]][p[j]];
      for (int k = 1; k <= 3; k++)
        upd(ans1[j], ans2[j], pre1[k] + d[now[k]][p[j]],
            pre2[k] + g[now[k]][p[j]]);
    }
    now[1] = p[1], now[2] = p[2], now[3] = p[3];
  }
  int res1 = ans1[1], res2 = ans2[1];
  for (int i = 2; i <= 3; i++) upd(res1, res2, ans1[i], ans2[i]);
  printf("%d %d\n", res1, res2);
  return 0;
}
