#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
int dp[101][101][3][3];
int op[101][101][3][3];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  vector<int> x(n * n + 1), y(n * n + 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
      x[a[i][j]] = i;
      y[a[i][j]] = j;
    }
  }
  for (int beg = 1; beg < n * n; ++beg) {
    for (int t_beg = 0; t_beg < 3; ++t_beg) {
      vector<vector<int>> w(n * n + 1, vector<int>(3, inf));
      w[beg][t_beg] = 0;
      vector<vector<int>> r(n * n + 1, vector<int>(3, inf));
      r[beg][t_beg] = 0;
      queue<pair<int, int>> q;
      q.emplace(beg, t_beg);
      while (!q.empty()) {
        int cur = q.front().first;
        int t_cur = q.front().second;
        q.pop();
        if (w[cur][(t_cur + 1) % 3] == inf) {
          w[cur][(t_cur + 1) % 3] = w[cur][t_cur] + 1;
          r[cur][(t_cur + 1) % 3] = r[cur][t_cur] + 1;
          q.emplace(cur, (t_cur + 1) % 3);
        } else if (w[cur][t_cur] + 1 == w[cur][(t_cur + 1) % 3]) {
          r[cur][(t_cur + 1) % 3] =
              min(r[cur][(t_cur + 1) % 3], r[cur][t_cur] + 1);
        }
        if (w[cur][(t_cur + 2) % 3] == inf) {
          w[cur][(t_cur + 2) % 3] = w[cur][t_cur] + 1;
          r[cur][(t_cur + 2) % 3] = r[cur][t_cur] + 1;
          q.emplace(cur, (t_cur + 2) % 3);
        } else if (w[cur][t_cur] + 1 == w[cur][(t_cur + 2) % 3]) {
          r[cur][(t_cur + 2) % 3] =
              min(r[cur][(t_cur + 2) % 3], r[cur][t_cur] + 1);
        }
        if (t_cur == 0) {
          int i = x[cur];
          int j = y[cur];
          for (int di : {-2, -1, +1, +2}) {
            for (int dj : {-2, -1, +1, +2}) {
              if (abs(di) + abs(dj) != 3) {
                continue;
              }
              int ni = i + di;
              int nj = j + dj;
              if (ni < 0 || ni >= n || nj < 0 || nj >= n) {
                continue;
              }
              int nxt = a[ni][nj];
              if (w[nxt][t_cur] == inf) {
                w[nxt][t_cur] = w[cur][t_cur] + 1;
                r[nxt][t_cur] = r[cur][t_cur];
                q.emplace(nxt, t_cur);
              } else if (w[cur][t_cur] + 1 == w[nxt][t_cur]) {
                r[nxt][t_cur] = min(r[nxt][t_cur], r[cur][t_cur]);
              }
            }
          }
        }
        if (t_cur == 1) {
          int i = x[cur];
          int j = y[cur];
          for (int di = -n; di <= n; ++di) {
            for (int dj : {-di, +di}) {
              int ni = i + di;
              int nj = j + dj;
              if (ni < 0 || ni >= n || nj < 0 || nj >= n) {
                continue;
              }
              int nxt = a[ni][nj];
              if (w[nxt][t_cur] == inf) {
                w[nxt][t_cur] = w[cur][t_cur] + 1;
                r[nxt][t_cur] = r[cur][t_cur];
                q.emplace(nxt, t_cur);
              } else if (w[cur][t_cur] + 1 == w[nxt][t_cur]) {
                r[nxt][t_cur] = min(r[nxt][t_cur], r[cur][t_cur]);
              }
            }
          }
        }
        if (t_cur == 2) {
          int i = x[cur];
          int j = y[cur];
          for (int di = -n; di <= n; ++di) {
            int ni = i + di;
            int nj = j;
            if (ni < 0 || ni >= n || nj < 0 || nj >= n) {
              continue;
            }
            int nxt = a[ni][nj];
            if (w[nxt][t_cur] == inf) {
              w[nxt][t_cur] = w[cur][t_cur] + 1;
              r[nxt][t_cur] = r[cur][t_cur];
              q.emplace(nxt, t_cur);
            } else if (w[cur][t_cur] + 1 == w[nxt][t_cur]) {
              r[nxt][t_cur] = min(r[nxt][t_cur], r[cur][t_cur]);
            }
          }
          for (int dj = -n; dj <= n; ++dj) {
            int ni = i;
            int nj = j + dj;
            if (ni < 0 || ni >= n || nj < 0 || nj >= n) {
              continue;
            }
            int nxt = a[ni][nj];
            if (w[nxt][t_cur] == inf) {
              w[nxt][t_cur] = w[cur][t_cur] + 1;
              r[nxt][t_cur] = r[cur][t_cur];
              q.emplace(nxt, t_cur);
            } else if (w[cur][t_cur] + 1 == w[nxt][t_cur]) {
              r[nxt][t_cur] = min(r[nxt][t_cur], r[cur][t_cur]);
            }
          }
        }
      }
      for (int end = beg; end <= n * n; ++end) {
        for (int t_end = 0; t_end < 3; ++t_end) {
          dp[beg][end][t_beg][t_end] = w[end][t_end];
          op[beg][end][t_beg][t_end] = r[end][t_end];
        }
      }
    }
  }
  vector<vector<int>> dp2(n * n + 1, vector<int>(3, inf));
  vector<vector<int>> op2(n * n + 1, vector<int>(3, inf));
  dp2[1][0] = dp2[1][1] = dp2[1][2] = 0;
  op2[1][0] = op2[1][1] = op2[1][2] = 0;
  for (int end = 2; end <= n * n; ++end) {
    for (int t_end = 0; t_end < 3; ++t_end) {
      int beg = end - 1;
      for (int t_beg = 0; t_beg < 3; ++t_beg) {
        if (dp2[beg][t_beg] + dp[beg][end][t_beg][t_end] < dp2[end][t_end]) {
          dp2[end][t_end] = dp2[beg][t_beg] + dp[beg][end][t_beg][t_end];
          op2[end][t_end] = op2[beg][t_beg] + op[beg][end][t_beg][t_end];
        } else if (dp2[beg][t_beg] + dp[beg][end][t_beg][t_end] ==
                   dp2[end][t_end]) {
          op2[end][t_end] = min(op2[end][t_end],
                                op2[beg][t_beg] + op[beg][end][t_beg][t_end]);
        }
      }
    }
  }
  int ret_dp = inf, ret_op = inf;
  for (int i = 0; i < 3; ++i) {
    if (dp2[n * n][i] < ret_dp) {
      ret_dp = dp2[n * n][i];
      ret_op = op2[n * n][i];
    } else if (dp2[n * n][i] == ret_dp) {
      ret_op = min(ret_op, op2[n * n][i]);
    }
  }
  cout << ret_dp << ' ' << ret_op << '\n';
  return 0;
}
