#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[15][15];
pair<long long, long long> ds[3][104];
long long vis[3][104];
pair<long long, long long> pos[104];
pair<long long, long long> add(pair<long long, long long> x,
                               pair<long long, long long> y) {
  pair<long long, long long> a1 = x;
  a1.first += y.first;
  a1.second += y.second;
  return a1;
}
vector<pair<long long, long long> > find_min(long long x1, long long y1,
                                             long long p1, long long cell) {
  priority_queue<pair<pair<long long, long long>, vector<long long> > > pq;
  vector<long long> temp1 = {x1, y1, p1};
  pq.push(make_pair(make_pair(0, 0), temp1));
  pair<long long, long long> dist[14][14][3];
  for (int i = 0; i < 14; i++) {
    for (int j = 0; j < 14; j++) {
      for (int k = 0; k < 3; k++) {
        dist[i][j][k] = {1e16, 1e16};
      }
    }
  }
  dist[x1][y1][p1] = {0, 0};
  while (!pq.empty()) {
    pair<long long, long long> d = pq.top().first;
    long long x = pq.top().second[0];
    long long y = pq.top().second[1];
    long long p = pq.top().second[2];
    pq.pop();
    if (d > dist[x][y][p]) continue;
    for (int i = 0; i < 3; i++) {
      pair<long long, long long> t = d;
      t.first++;
      t.second++;
      if (dist[x][y][i] > t) {
        dist[x][y][i] = t;
        vector<long long> temp = {x, y, i};
        pq.push(make_pair(t, temp));
      }
    }
    pair<long long, long long> t = d;
    t.first++;
    if (p == 0) {
      for (int i = 1; i <= n; i++) {
        if (dist[x][i][0] > t) {
          dist[x][i][0] = t;
          vector<long long> temp = {x, i, 0};
          pq.push(make_pair(t, temp));
        }
        if (dist[i][y][0] > t) {
          dist[i][y][0] = t;
          vector<long long> temp = {i, y, 0};
          pq.push(make_pair(t, temp));
        }
      }
    } else if (p == 1) {
      long long x1 = x;
      long long y1 = y;
      while (x1 > 0 && y1 > 0) {
        if (dist[x1][y1][1] > t) {
          dist[x1][y1][1] = t;
          vector<long long> temp = {x1, y1, 1};
          pq.push(make_pair(t, temp));
        }
        x1--;
        y1--;
      }
      x1 = x;
      y1 = y;
      while (x1 <= n && y1 <= n) {
        if (dist[x1][y1][1] > t) {
          dist[x1][y1][1] = t;
          vector<long long> temp = {x1, y1, 1};
          pq.push(make_pair(t, temp));
        }
        x1++;
        y1++;
      }
      x1 = x;
      y1 = y;
      while (x1 <= n && y1 > 0) {
        if (dist[x1][y1][1] > t) {
          dist[x1][y1][1] = t;
          vector<long long> temp = {x1, y1, 1};
          pq.push(make_pair(t, temp));
        }
        x1++;
        y1--;
      }
      x1 = x;
      y1 = y;
      while (x1 > 0 && y1 <= n) {
        if (dist[x1][y1][1] > t) {
          dist[x1][y1][1] = t;
          vector<long long> temp = {x1, y1, 1};
          pq.push(make_pair(t, temp));
        }
        x1--;
        y1++;
      }
    } else {
      for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
          if (abs(i) + abs(j) != 3) continue;
          if (i == 0 || j == 0) continue;
          if (x + i <= 0 || x + i > n) continue;
          if (y + j <= 0 || y + j > n) continue;
          if (dist[x + i][y + j][2] > t) {
            dist[x + i][y + j][2] = t;
            vector<long long> temp = {x + i, y + j, 2};
            pq.push(make_pair(t, temp));
          }
        }
      }
    }
  }
  vector<pair<long long, long long> > ans;
  ans.push_back(dist[pos[cell].first][pos[cell].second][0]);
  ans.push_back(dist[pos[cell].first][pos[cell].second][1]);
  ans.push_back(dist[pos[cell].first][pos[cell].second][2]);
  return ans;
}
pair<long long, long long> dp(int p, int cell) {
  if (cell > n * n) {
    return {0, 0};
  }
  if (vis[p][cell] == 1) {
    return ds[p][cell];
  }
  vis[p][cell] = 1;
  vector<pair<long long, long long> > x1 =
      find_min(pos[cell - 1].first, pos[cell - 1].second, p, cell);
  pair<long long, long long> ans = add(x1[0], dp(0, cell + 1));
  ans = min(ans, add(x1[1], dp(1, cell + 1)));
  ans = min(ans, add(x1[2], dp(2, cell + 1)));
  return ds[p][cell] = ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  pair<long long, long long> ps;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      if (a[i][j] == 1) {
        ps.first = i;
        ps.second = j;
      }
      pos[a[i][j]] = {i, j};
    }
  }
  pair<long long, long long> ans = min(dp(0, 2), dp(1, 2));
  ans = min(ans, dp(2, 2));
  cout << ans.first << " " << ans.second << "\n";
  return 0;
}
