#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > V[303];
int mp[12][12];
long long inf;
int n;
int ha(int a, int b) { return b + a * 100; }
bool check(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= n; }
void add(int a, int b) { V[a].push_back(make_pair(b, 1)); }
pair<int, int> dis[303][303];
pair<int, int> ans = make_pair(1e9, 1e9);
pair<int, int> minn[303][303];
void dfs(int first, int id, int cost, int d) {
  if (minn[first][id] < make_pair(cost, d)) return;
  minn[first][id] = make_pair(cost, d);
  if (id == n * n) {
    ans = min(ans, make_pair(cost, d));
    return;
  }
  if (dis[ha(first, id)][ha(1, id + 1)].first != inf)
    dfs(1, id + 1, cost + dis[ha(first, id)][ha(1, id + 1)].first,
        dis[ha(first, id)][ha(1, id + 1)].second + d);
  if (dis[ha(first, id)][ha(2, id + 1)].first != inf)
    dfs(2, id + 1, cost + dis[ha(first, id)][ha(2, id + 1)].first,
        dis[ha(first, id)][ha(2, id + 1)].second + d);
  if (dis[ha(first, id)][ha(0, id + 1)].first != inf)
    dfs(0, id + 1, cost + dis[ha(first, id)][ha(0, id + 1)].first,
        dis[ha(first, id)][ha(0, id + 1)].second + d);
}
void dijk(int dex, int first) {
  dis[dex][first] = make_pair(0, 0);
  multiset<pair<pair<int, int>, int> > st;
  st.insert({{0, 0}, first});
  while (!st.empty()) {
    auto now = st.begin()->second;
    st.erase(st.begin());
    for (auto j : V[now]) {
      if (dis[dex][j.first] >
          make_pair(dis[dex][now].first + j.second,
                    dis[dex][now].second +
                        ((now - 1) / 100 != (j.first - 1) / 100))) {
        st.erase({dis[dex][j.first], j.first});
        dis[dex][j.first] = make_pair(
            dis[dex][now].first + j.second,
            dis[dex][now].second + ((now - 1) / 100 != (j.first - 1) / 100));
        st.insert({dis[dex][j.first], j.first});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> mp[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int now = mp[i][j];
      if (check(i + 2, j + 1)) add(ha(0, now), ha(0, mp[i + 2][j + 1]));
      if (check(i + 2, j - 1)) add(ha(0, now), ha(0, mp[i + 2][j - 1]));
      if (check(i - 2, j + 1)) add(ha(0, now), ha(0, mp[i - 2][j + 1]));
      if (check(i - 2, j - 1)) add(ha(0, now), ha(0, mp[i - 2][j - 1]));
      if (check(i + 1, j + 2)) add(ha(0, now), ha(0, mp[i + 1][j + 2]));
      if (check(i + 1, j - 2)) add(ha(0, now), ha(0, mp[i + 1][j - 2]));
      if (check(i - 1, j + 2)) add(ha(0, now), ha(0, mp[i - 1][j + 2]));
      if (check(i - 1, j - 2)) add(ha(0, now), ha(0, mp[i - 1][j - 2]));
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int now = mp[i][j];
      for (int k = -n; k <= n; k++) {
        if (k == 0) continue;
        if (check(i + k, j + k)) {
          add(ha(1, now), ha(1, mp[i + k][j + k]));
        }
        if (check(i - k, j + k)) {
          add(ha(1, now), ha(1, mp[i - k][j + k]));
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int now = mp[i][j];
      for (int k = -n; k <= n; k++) {
        if (k == 0) continue;
        if (check(i + k, j)) {
          add(ha(2, now), ha(2, mp[i + k][j]));
        }
        if (check(i, j + k)) {
          add(ha(2, now), ha(2, mp[i][j + k]));
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      add(ha(0, mp[i][j]), ha(1, mp[i][j]));
      add(ha(0, mp[i][j]), ha(2, mp[i][j]));
      add(ha(1, mp[i][j]), ha(2, mp[i][j]));
      add(ha(1, mp[i][j]), ha(0, mp[i][j]));
      add(ha(2, mp[i][j]), ha(0, mp[i][j]));
      add(ha(2, mp[i][j]), ha(1, mp[i][j]));
    }
  }
  memset(dis, 0x3F, sizeof(dis));
  inf = dis[0][0].first;
  for (int i = 1; i <= n * n; i++) {
    dijk(ha(0, i), ha(0, i));
    dijk(ha(1, i), ha(1, i));
    dijk(ha(2, i), ha(2, i));
  }
  memset(minn, 0x3F, sizeof(minn));
  dfs(0, 1, 0, 0);
  memset(minn, 0x3F, sizeof(minn));
  dfs(1, 1, 0, 0);
  memset(minn, 0x3F, sizeof(minn));
  dfs(2, 1, 0, 0);
  cout << ans.first << ' ' << ans.second << endl;
  return 0;
}
