#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int n2 = n * n;
  vector<pair<int, int>> a(n2 + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int x;
      cin >> x;
      a[x].first = i;
      a[x].second = j;
    }
  }
  vector<vector<pair<int, int>>> e(n2 + 1);
  auto knight = [&](pair<int, int> i, pair<int, int> j) {
    int x = abs(i.first - j.first);
    int y = abs(i.second - j.second);
    if (x == 1 && y == 2) {
      return true;
    }
    if (x == 2 && y == 1) {
      return true;
    }
    return false;
  };
  auto bishop = [&](pair<int, int> i, pair<int, int> j) {
    int x = abs(i.first - j.first);
    int y = abs(i.second - j.second);
    return x == y;
  };
  auto rook = [&](pair<int, int> i, pair<int, int> j) {
    return i.first == j.first || i.second == j.second;
  };
  for (int i = 1; i <= n2; ++i) {
    for (int j = 1; j <= n2; ++j) {
      if (i != j) {
        if (knight(a[i], a[j])) {
          e[i].push_back({j, 0});
        }
        if (bishop(a[i], a[j])) {
          e[i].push_back({j, 1});
        }
        if (rook(a[i], a[j])) {
          e[i].push_back({j, 2});
        }
      }
    }
  }
  vector<vector<vector<int>>> f(n2 + 1, vector<vector<int>>(3, vector<int>(3)));
  vector<vector<vector<int>>> g(n2 + 1, vector<vector<int>>(3, vector<int>(3)));
  auto dijkstra = [&](int s, int t, int kind) {
    vector<vector<int>> df(n2 + 1, vector<int>(3, 123123123));
    vector<vector<int>> dg(n2 + 1, vector<int>(3, 123123123));
    auto cmp = [&](pair<pair<int, int>, pair<int, int>> i,
                   pair<pair<int, int>, pair<int, int>> j) {
      if (i.second.first != j.second.first) {
        return i.second.first > j.second.first;
      }
      return (i.second.second > j.second.second);
    };
    priority_queue<pair<pair<int, int>, pair<int, int>>,
                   vector<pair<pair<int, int>, pair<int, int>>>, decltype(cmp)>
        q(cmp);
    q.push({{s, kind}, {0, 0}});
    while (!q.empty()) {
      int u = q.top().first.first;
      int ku = q.top().first.second;
      int midf = q.top().second.first;
      int midg = q.top().second.second;
      q.pop();
      for (auto i : e[u]) {
        int v = i.first;
        int kv = i.second;
        if (df[v][kv] > midf + 1 + (ku != kv)) {
          df[v][kv] = midf + 1 + (ku != kv);
          dg[v][kv] = midg + (ku != kv);
          q.push({{v, kv}, {df[v][kv], dg[v][kv]}});
        } else {
          if (df[v][kv] == midf + 1 + (ku != kv) &&
              dg[v][kv] > midg + (ku != kv)) {
            dg[v][kv] = midg + (ku != kv);
            q.push({{v, kv}, {df[v][kv], dg[v][kv]}});
          }
        }
      }
    }
    for (int i = 0; i < 3; ++i) {
      f[s][kind][i] = df[t][i];
      g[s][kind][i] = dg[t][i];
    }
  };
  for (int i = 1; i < n2; ++i) {
    for (int j = 0; j < 3; ++j) {
      dijkstra(i, i + 1, j);
    }
  }
  vector<vector<int>> dpf(n2 + 1, vector<int>(3, 123123123));
  vector<vector<int>> dpg(n2 + 1, vector<int>(3, 123123123));
  for (int i = 0; i < 3; ++i) {
    dpf[1][i] = 0;
    dpg[1][i] = 0;
  }
  for (int i = 2; i <= n2; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int t = 0; t < 3; ++t) {
        if (dpf[i - 1][t] + f[i - 1][t][j] < dpf[i][j]) {
          dpf[i][j] = dpf[i - 1][t] + f[i - 1][t][j];
          dpg[i][j] = dpg[i - 1][t] + g[i - 1][t][j];
        } else {
          if (dpf[i - 1][t] + f[i - 1][t][j] == dpf[i][j]) {
            dpg[i][j] = min(dpg[i][j], dpg[i - 1][t] + g[i - 1][t][j]);
          }
        }
      }
    }
  }
  int pos = 0;
  for (int i = 1; i < 3; ++i) {
    if (dpf[n2][i] < dpf[n2][pos]) {
      pos = i;
    } else {
      if (dpf[n2][i] == dpf[n2][pos] && dpg[n2][i] < dpg[n2][pos]) {
        pos = i;
      }
    }
  }
  cout << dpf[n2][pos] << ' ' << dpg[n2][pos] << '\n';
  return 0;
}
