#include <bits/stdc++.h>
using namespace std;
const long long nax = 110;
long long n, a[nax][nax];
pair<long long, long long> pos[nax];
pair<long long, long long> dist[1200][1200];
bool visited[1200];
const long long INF = 1e9;
pair<long long, long long> dp[nax][3];
long long dx[] = {1, 1, 2, 2, -1, -1, -2, -2};
long long dy[] = {-2, 2, -1, 1, -2, 2, -1, 1};
long long encode(long long a, long long b, long long c) {
  return a * n * n + b * n + c;
}
vector<long long> decode(long long yeet) {
  long long cpy = yeet;
  vector<long long> res(3);
  res[2] = yeet % n;
  yeet -= res[2];
  yeet /= n;
  res[1] = yeet % n;
  if (res[1] == 0) res[1] = n;
  yeet -= res[1];
  res[0] = yeet / n;
  return res;
}
bool inside(long long i, long long j) {
  return (1 <= i && i <= n && 1 <= j && j <= n);
}
vector<long long> transition(long long yeet) {
  vector<long long> d = decode(yeet);
  long long i = d[0], j = d[1], k = d[2];
  d.clear();
  for (long long p = 0; p <= 2; ++p) {
    if (p == k) {
      continue;
    }
    d.push_back(encode(i, j, p));
  }
  if (k == 0) {
    for (long long x = 1; x <= n; ++x) {
      if (x == j) continue;
      d.push_back(encode(i, x, k));
    }
    for (long long x = 1; x <= n; ++x) {
      if (x == i) continue;
      d.push_back(encode(x, j, k));
    }
  } else if (k == 1) {
    for (long long x = i - 1, y = j - 1; inside(x, y); --x, --y) {
      d.push_back(encode(x, y, k));
    }
    for (long long x = i + 1, y = j + 1; inside(x, y); ++x, ++y) {
      d.push_back(encode(x, y, k));
    }
    for (long long x = i + 1, y = j - 1; inside(x, y); ++x, --y) {
      d.push_back(encode(x, y, k));
    }
    for (long long x = i - 1, y = j + 1; inside(x, y); --x, ++y) {
      d.push_back(encode(x, y, k));
    }
  } else if (k == 2) {
    for (long long direction = 0; direction < 8; ++direction) {
      long long x = i + dx[direction], y = j + dy[direction];
      if (!inside(x, y)) continue;
      d.push_back(encode(x, y, k));
    }
  }
  return d;
}
pair<long long, long long> add(const pair<long long, long long> &a,
                               const pair<long long, long long> &b) {
  return {a.first + b.first, a.second + b.second};
}
pair<long long, long long> calc(long long i, long long j) {
  if (dp[i][j].first != -1) return dp[i][j];
  if (i == 1) return (dp[i][j] = {0, 0});
  pair<long long, long long> ret = {INF, INF};
  long long x = pos[i - 1].first, y = pos[i - 1].second;
  long long z = pos[i].first, t = pos[i].second;
  for (long long k = 0; k <= 2; ++k) {
    ret = min(ret, add(calc(i - 1, k), dist[encode(x, y, k)][encode(z, t, j)]));
  }
  return (dp[i][j] = ret);
}
void solve() {
  for (long long i = 0; i <= nax - 1; ++i) {
    for (long long j = 0; j <= 2; ++j) {
      dp[i][j] = {-1, -1};
    }
  }
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= n; ++j) {
      cin >> a[i][j];
      pos[a[i][j]] = {i, j};
    }
  }
  for (long long i = 0; i < 1200; ++i) {
    for (long long j = 0; j < 1200; ++j) {
      dist[i][j] = {INF, INF};
    }
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= n; ++j) {
      for (long long k = 0; k <= 2; ++k) {
        fill(visited, visited + 1200, false);
        priority_queue<pair<pair<long long, long long>, long long>> pq;
        long long yeet = encode(i, j, k);
        pq.push({{0, 0}, yeet});
        dist[yeet][yeet] = {0, 0};
        while (!pq.empty()) {
          auto p = pq.top();
          pq.pop();
          long long u = p.second;
          if (visited[u]) continue;
          visited[u] = true;
          for (auto &c : transition(u)) {
            pair<long long, long long> comp;
            comp.first = dist[yeet][u].first + 1;
            comp.second = dist[yeet][u].second;
            if (u % n != c % n) ++comp.second;
            if (dist[yeet][c] > comp) {
              dist[yeet][c] = comp;
              pq.push({{-dist[yeet][c].first, -dist[yeet][c].second}, c});
            }
          }
        }
      }
    }
  }
  pair<long long, long long> ans =
      min({calc(n * n, 0), calc(n * n, 1), calc(n * n, 2)});
  cout << ans.first << ' ' << ans.second;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
