#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int X[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int Y[] = {-1, 0, +1, 1, 1, 0, -1, -1};
int n;
int arr[2010];
int target[2010];
int pos[2010];
vector<pair<int, int> > reply;
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(arr[i]);
  }
  for (int i = 1; i <= n; i++) {
    read(target[i]);
    pos[target[i]] = i;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int a = i;
    while (arr[a] != target[i]) a++;
    for (int j = a - 1; j >= i; j--) {
      if (pos[arr[j]] >= a) {
        ans += (a - j);
        reply.push_back(pair<int, int>(a, j));
        swap(arr[j], arr[a]);
        a = j;
      }
    }
  }
  printf("%d\n%d\n", ans, reply.size());
  for (int i = 0; i < reply.size(); i++)
    printf("%d %d\n", reply[i].first, reply[i].second);
  return 0;
}
