#include <cstdio>
#include <vector>
#define MAXN (1 << 17)
using namespace std;

int n;
int a[MAXN], pos[MAXN];
int from[MAXN], to[MAXN];

vector< pair<int, int> > solution;


inline vector< pair<int, int> > solve()
{
	vector<pair< int, int> > sol;
	sol.clear();

	for (int cur=1; cur < n; ++cur)
	{
		int a = pos[cur];
		//printf("first a = %d\n", a);
		for (int i=0; i < sol.size(); ++i)
			if (sol[i].first <= a && sol[i].second >= a)
				a = sol[i].first + sol[i].second-a;

		//printf("found a = %d\n", a);
		int b = cur;
		if (a == b) continue;

		sol.push_back(make_pair(b, a));
	}

	return sol;
}



inline void read()
{
	for (int i=0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		pos[a[i]] = i+1;
	}
}

int main()
{
	scanf("%d", &n);
	read();
	solution = solve();
	read();
	vector<pair<int, int> > other = solve();
	printf("%d\n", other.size() + solution.size());
	for (int i=0; i < solution.size(); ++i)
		printf("%d %d\n", solution[i].first, solution[i].second);
	for (int i=other.size()-1; i >= 0; --i)
		printf("%d %d\n", other[i].first, other[i].second);
	return 0;
}
