#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << "[" << H << "]";
  debug_out(T...);
}
clock_t startTime;
double getCurrentTime() {
  return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.00001;
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e6 + 3e2;
const int M = 404;
pair<pair<pair<int, int>, pair<int, int> >, int> MP5(pair<int, int> d, int x,
                                                     int y, int t) {
  d.first *= -1;
  d.second *= -1;
  return make_pair(make_pair(d, make_pair(x, y)), t);
}
vector<int> vx[3], vy[3];
int n;
int a[11][11];
bool valid(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= n); }
pair<int, int> dp[110][11][11][3];
bool processed[11][11][3];
pair<int, int> MIN(pair<int, int> x, pair<int, int> y) {
  if (x.first < y.first || x.first == y.first && x.second < y.second) return x;
  return y;
}
bool chmin(pair<int, int> &x, pair<int, int> y) {
  if (MIN(x, y) == x) return false;
  x = y;
  return true;
}
void run_dijkstra(int ii, int x, int y) {
  memset(processed, 0, sizeof(processed));
  priority_queue<pair<pair<pair<int, int>, pair<int, int> >, int> > pq;
  pq.push(MP5(dp[ii][x][y][0], x, y, 0));
  pq.push(MP5(dp[ii][x][y][1], x, y, 1));
  pq.push(MP5(dp[ii][x][y][2], x, y, 2));
  while (!pq.empty()) {
    x = pq.top().first.second.first, y = pq.top().first.second.second;
    int t = pq.top().second;
    pq.pop();
    if (processed[x][y][t]) continue;
    processed[x][y][t] = true;
    for (int tt = 0; tt < 3; tt++) {
      for (int i = 0; i < vx[tt].size(); i++) {
        int X = x + vx[tt][i], Y = y + vy[tt][i];
        int new_d1 = dp[ii][x][y][t].first + 1 + (t != tt);
        int new_d2 = dp[ii][x][y][t].second + (t != tt);
        if (valid(X, Y) && chmin(dp[ii][X][Y][tt], make_pair(new_d1, new_d2))) {
          pq.push(MP5(make_pair(new_d1, new_d2), X, Y, tt));
        }
      }
    }
  }
}
pair<int, int> p[111];
void solve(int TC) {
  cin >> n;
  vx[0] = {1, 1, -1, -1, 2, 2, -2, -2};
  vy[0] = {2, -2, 2, -2, 1, -1, 1, -1};
  for (int i = 1; i <= n; i++) {
    vx[1].push_back(i);
    vy[1].push_back(i);
    vx[1].push_back(i);
    vy[1].push_back(-i);
    vx[1].push_back(-i);
    vy[1].push_back(i);
    vx[1].push_back(-i);
    vy[1].push_back(-i);
  }
  for (int i = 1; i <= n; i++) {
    vx[2].push_back(i);
    vy[2].push_back(0);
    vx[2].push_back(0);
    vy[2].push_back(i);
    vx[2].push_back(-i);
    vy[2].push_back(0);
    vx[2].push_back(0);
    vy[2].push_back(-i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      p[a[i][j]] = make_pair(i, j);
    }
  }
  for (int k = 1; k <= n * n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int t = 0; t < 3; t++) {
          dp[k][i][j][t] = make_pair(INF, INF);
        }
      }
    }
  }
  for (int i = 1; i <= n * n; i++) {
    int x = p[i].first, y = p[i].second;
    for (int j = 0; j < 3; j++) {
      dp[i][x][y][j] = dp[i - 1][x][y][j];
    }
    run_dijkstra(i, x, y);
  }
  int x = p[n * n].first, y = p[n * n].second;
  pair<int, int> ans = make_pair(INF, INF);
  for (int i = 0; i < 3; i++) {
    ans = MIN(ans, dp[n * n][x][y][i]);
  }
  cout << ans.first << ' ' << ans.second;
}
int main() {
  startTime = clock();
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  bool llololcal = false;
  int TC = 1;
  for (int test = 1; test <= TC; test++) {
    42;
    solve(test);
  }
  if (llololcal)
    cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl;
  return 0;
}
