#include <bits/stdc++.h>
const long long N = 1000006;
using namespace std;
const long long MOD = 1000000007LL;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T power(T x, T y, long long m = MOD) {
  T ans = 1;
  while (y > 0) {
    if (y & 1LL) ans = (ans * x) % m;
    y >>= 1LL;
    x = (x * x) % m;
  }
  return ans % m;
}
long long sted[11][11][11][11][3][3], n;
long long bd[11][11], vis[11][11][3];
long long mm[11][11][11][11][3][3];
vector<pair<long long, long long>> km = {{2, -1}, {2, 1},  {-2, -1}, {-2, 1},
                                         {1, 2},  {1, -2}, {-1, 2},  {-1, -2}};
vector<pair<long long, long long>> bm;
vector<pair<long long, long long>> rm;
vector<vector<pair<long long, long long>>> fm;
void lul() {
  for (long long i = 1; i <= 10; i++) {
    bm.push_back({i, i});
    bm.push_back({-i, -i});
    bm.push_back({i, -i});
    bm.push_back({-i, i});
    rm.push_back({0, i});
    rm.push_back({0, -i});
    rm.push_back({i, 0});
    rm.push_back({-i, 0});
  }
  fm.emplace_back(km);
  fm.emplace_back(bm);
  fm.emplace_back(rm);
}
bool ch(long long x, long long y) {
  if (x < 0 || x >= n || y < 0 || y >= n) return 0;
  return 1;
}
void pre() {
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      for (long long t = 0; t < 3; t++) {
        memset(vis, 0, sizeof(vis));
        queue<pair<pair<long long, long long>, pair<long long, long long>>> q;
        q.push({{i, j}, {t, 0}});
        vis[i][j][t] = 1;
        while (!q.empty()) {
          auto f = q.front();
          q.pop();
          long long u = f.first.first, v = f.first.second, ct = f.second.first,
                    mv = f.second.second;
          for (auto x : fm[ct]) {
            long long nx = u + x.first, ny = v + x.second;
            if (!ch(nx, ny) || vis[nx][ny][ct]) continue;
            sted[i][j][nx][ny][t][ct] = mv + 1;
            mm[i][j][nx][ny][t][ct] = mm[i][j][u][v][t][ct];
            vis[nx][ny][ct] = 1;
            q.push({{nx, ny}, {ct, mv + 1}});
          }
          if (!vis[u][v][0]) {
            vis[u][v][0] = 1;
            sted[i][j][u][v][t][0] = mv + 1;
            mm[i][j][u][v][t][0] = mm[i][j][u][v][t][ct];
            if (ct != 0) ++mm[i][j][u][v][t][0];
            q.push({{u, v}, {0, mv + 1}});
          }
          if (!vis[u][v][1]) {
            vis[u][v][1] = 1;
            sted[i][j][u][v][t][1] = mv + 1;
            mm[i][j][u][v][t][1] = mm[i][j][u][v][t][ct];
            if (ct != 1) ++mm[i][j][u][v][t][1];
            q.push({{u, v}, {1, mv + 1}});
          }
          if (!vis[u][v][2]) {
            vis[u][v][2] = 1;
            sted[i][j][u][v][t][2] = mv + 1;
            mm[i][j][u][v][t][2] = mm[i][j][u][v][t][ct];
            if (ct != 2) ++mm[i][j][u][v][t][2];
            q.push({{u, v}, {2, mv + 1}});
          }
        }
      }
    }
  }
}
map<long long, pair<long long, long long>> np;
pair<long long, long long> dp[11][11][3][11 * 11];
long long nvis[11][11][3][11 * 11];
pair<long long, long long> comp(pair<long long, long long> l,
                                pair<long long, long long> r) {
  if (l.first < r.first) return l;
  if (r.first < l.first) return r;
  if (l.second < r.second) return l;
  return r;
}
pair<long long, long long> go(long long i, long long j, long long t,
                              long long curr) {
  if (curr == n * n) return {0, 0};
  if (nvis[i][j][t][curr]) return dp[i][j][t][curr];
  nvis[i][j][t][curr] = 1;
  pair<long long, long long> ans = {1000111000111000111LL,
                                    1000111000111000111LL};
  long long nx = np[curr + 1].first, ny = np[curr + 1].second;
  for (long long(ct) = (0); ct < (3); ct++) {
    pair<long long, long long> np = go(nx, ny, ct, curr + 1);
    np.first += sted[i][j][nx][ny][t][ct];
    np.second += mm[i][j][nx][ny][t][ct];
    ans = comp(ans, np);
  }
  return dp[i][j][t][curr] = ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  lul();
  cin >> n;
  pre();
  for (long long(i) = (0); i < (n); i++) {
    for (long long(j) = (0); j < (n); j++) {
      cin >> bd[i][j];
      np[bd[i][j]] = {i, j};
    }
  }
  memset(dp, -1, sizeof(dp));
  pair<long long, long long> ans = {1000111000111000111LL,
                                    1000111000111000111LL};
  for (long long(ct) = (0); ct < (3); ct++) {
    ans = comp(ans, go(np[1].first, np[1].second, ct, 1));
  }
  cout << ans.first << " " << ans.second;
}
