#include <bits/stdc++.h>
using namespace std;
int n;
int num[2][2010], pos[2][2010];
vector<pair<int, int> > ans;
int main() {
  while (~scanf("%d", &n)) {
    ans.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &num[0][i]);
      pos[0][num[0][i]] = i;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &num[1][i]);
      pos[1][num[1][i]] = i;
    }
    int score = 0;
    pair<int, int> temp;
    for (int i = 1; i <= n; i++) {
      if (num[0][i] != num[1][i]) {
        int x = pos[1][num[0][i]];
        int z = num[0][i];
        if (x > i) continue;
        int re = i;
        score += (i - x);
        for (int j = i - 1; j >= x; j--) {
          if (num[0][j] != num[1][j]) {
            pos[0][num[0][j]] = re;
            num[0][re] = num[0][j];
            num[0][j] = z;
            pos[0][z] = j;
            temp.first = re;
            temp.second = j;
            re = j;
            ans.push_back(temp);
          }
        }
      }
    }
    printf("%d\n", score);
    int s = ans.size();
    printf("%d\n", s);
    for (int i = 0; i < s; i++) {
      printf("%d %d\n", ans[i].first, ans[i].second);
    }
  }
  return 0;
}
