#include <bits/stdc++.h>
using namespace std;
long long mult(long long a, long long b, long long p = 1000000007) {
  return ((a % p) * (b % p)) % p;
}
long long add(long long a, long long b, long long p = 1000000007) {
  return (a + b + p) % p;
}
long long sub(long long a, long long b, long long p = 1000000007) {
  a -= b;
  if (a < 0) a += p;
  return a;
}
long long fpow(long long n, long long k, long long p = 1000000007) {
  long long r = 1;
  for (; k; k >>= 1LL) {
    if (k & 1LL) r = mult(r, n, p);
    n = mult(n, n, p);
  }
  return r;
}
long long inv(long long a, long long p = 1000000007) {
  return fpow(a, p - 2, p);
}
void self_max(long long &a, long long b) { a = max(a, b); }
void self_min(long long &a, long long b) { a = min(a, b); }
void self_add(long long &a, long long b, long long p = 1000000007) {
  a += b;
  if (a >= p) a -= p;
}
void self_sub(long long &a, long long b, long long p = 1000000007) {
  a -= b;
  if (a < 0) a += p;
}
const long long INF = 1e18 + 5;
long long n, m;
long long get(long long first, long long second, long long p) {
  return ((first - 1) * m + second - 1) * 3 + p + 1;
}
pair<long long, pair<long long, long long>> out(long long no) {
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      for (long long p = 0; p < 3; p++) {
        if (get(i, j, p) == no) {
          return make_pair(p, make_pair(i, j));
        }
      }
    }
  }
}
long long check(long long first, long long second) {
  return (first >= 1 && first <= n && second >= 1 && second <= m);
}
void add(long long first, long long second, long long a, long long b,
         long long p, vector<long long> &v) {
  while (check(first + a, second + b)) {
    first += a;
    second += b;
    v.push_back(get(first, second, p));
  }
}
void aMoves(long long first, long long second, long long p,
            vector<long long> &v) {
  add(first, second, 1, 0, p, v);
  add(first, second, -1, 0, p, v);
  add(first, second, 0, 1, p, v);
  add(first, second, 0, -1, p, v);
}
void bMoves(long long first, long long second, long long p,
            vector<long long> &v) {
  add(first, second, 1, 1, p, v);
  add(first, second, -1, -1, p, v);
  add(first, second, 1, -1, p, v);
  add(first, second, -1, 1, p, v);
}
void cMoves(long long first, long long second, long long p,
            vector<long long> &v) {
  long long a[8] = {2, 2, -2, -2, 1, -1, 1, -1};
  long long b[8] = {1, -1, 1, -1, 2, 2, -2, -2};
  for (long long i = 0; i < 8; i++) {
    if (check(first + a[i], second + b[i])) {
      v.push_back(get(first + a[i], second + b[i], p));
    }
  }
}
void changeStateMove(long long top, vector<long long> &v) {
  pair<long long, pair<long long, long long>> state = out(top);
  long long first = state.second.first, second = state.second.second,
            p = state.first;
  for (long long i = 0; i < 3; i++) {
    if (i == p) continue;
    v.push_back(get(first, second, i));
  }
}
void getMoves(long long top, vector<long long> &v) {
  pair<long long, pair<long long, long long>> state = out(top);
  long long first = state.second.first, second = state.second.second,
            p = state.first;
  if (p == 0)
    aMoves(first, second, p, v);
  else if (p == 1)
    bMoves(first, second, 1, v);
  else
    cMoves(first, second, 2, v);
}
long long dist[600];
long long change[600];
long long visited[600];
queue<long long> q;
void printState(long long no) {
  pair<long long, pair<long long, long long>> state = out(no);
  long long first = state.second.first, second = state.second.second,
            p = state.first;
  cout << "stat : " << p << " "
       << "cor " << first << " " << second << " ";
}
void disk(long long no) {
  for (long long k = 0; k < n * m * 3 + 10; k++) {
    dist[k] = INF;
    change[k] = 0;
    visited[k] = false;
  }
  q.push(no);
  dist[no] = 0;
  visited[no] = true;
  while (!q.empty()) {
    long long top = q.front();
    q.pop();
    vector<long long> v;
    getMoves(top, v);
    changeStateMove(top, v);
    for (long long curr : v) {
      if (!visited[curr]) {
        q.push(curr);
        visited[curr] = true;
        dist[curr] = dist[top] + 1;
        change[curr] = change[top] + (out(curr).first != out(top).first);
      }
    }
  }
}
long long D[600][600];
long long C[600][600];
void solve() {
  cin >> n;
  m = n;
  long long a[n + 1][m + 1];
  vector<pair<long long, long long>> cord(n * m + 1);
  for (long long i = 1; i < n + 1; i++)
    for (long long j = 1; j < m + 1; j++) {
      cin >> a[i][j];
      cord[a[i][j]] = make_pair(i, j);
    }
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      for (long long p = 0; p < 3; p++) {
        long long no = get(i, j, p);
        disk(no);
        for (long long i = 0; i < 600; i++) {
          D[no][i] = dist[i];
          C[no][i] = change[i];
        }
      }
    }
  }
  long long dp[600][3];
  long long ch[600][3];
  memset(ch, 0, sizeof(ch));
  for (long long i = 0; i < 600; i++)
    for (long long j = 0; j < 3; j++) dp[i][j] = INF;
  for (long long i = n * m - 1; i >= 1; i--) {
    for (long long curr = 0; curr < 3; curr++) {
      for (long long next = 0; next < 3; next++) {
        long long a = get(cord[i].first, cord[i].second, curr);
        long long b = get(cord[i + 1].first, cord[i + 1].second, next);
        if (i < n * m - 1) {
          if (dp[i][curr] > D[a][b] + dp[i + 1][next]) {
            ch[i][curr] = C[a][b] + ch[i + 1][next];
            dp[i][curr] = D[a][b] + dp[i + 1][next];
          } else if (dp[i][curr] == D[a][b] + dp[i + 1][next]) {
            self_min(ch[i][curr], C[a][b] + ch[i + 1][next]);
          }
        } else {
          if (dp[i][curr] > D[a][b]) {
            dp[i][curr] = D[a][b];
            ch[i][curr] = C[a][b];
          } else if (dp[i][curr] == D[a][b]) {
            self_min(ch[i][curr], C[a][b]);
          }
        }
      }
    }
  }
  pair<long long, long long> ans;
  ans.first = INF;
  for (long long i = 0; i < 3; i++) {
    if (ans.first > dp[1][i]) {
      ans.first = dp[1][i];
      ans.second = ch[1][i];
    } else if (ans.first == dp[1][i])
      self_min(ans.second, ch[1][i]);
  }
  cout << ans.first << " " << ans.second << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
