// C - Too Heavy
#include<bits/stdc++.h>
#define forn(i,s,t) for(register int i=(s);i<=(t);++i)
using namespace std;
typedef pair<int, int> pii;
const int N = 2e5+3;
int n, a[N], b[N], p[N], rft[N];
bool vis[N];
int main() {
	scanf("%d", &n);
	forn(i,1,n) scanf("%d", a+i);
	forn(i,1,n) scanf("%d", b+i);
	forn(i,1,n) scanf("%d", p+i);
	static priority_queue<pii> q;
	forn(i,1,n) {
		if(i == p[i]) {vis[i] = 1; continue ;}
		if(a[i] <= b[p[i]]) {puts("-1"); return 0;}
		rft[p[i]] = i;
		q.push(make_pair(-a[i], i));
	}
	static int cnt, L[N], R[N];
	while(!q.empty()) {
		static int cur;
		cur = q.top().second;
		q.pop();
		if(vis[cur]) continue ;
		L[++cnt] = cur, R[cnt] = rft[cur];
		vis[cur] = 1, rft[p[cur]] = rft[cur];
		if(rft[cur] == p[cur]) vis[rft[cur]] = 1;
		swap(p[cur], p[rft[cur]]);
	}
	printf("%d\n", cnt);
	forn(i,1,cnt) printf("%d %d\n", L[i], R[i]);
	return 0;
}
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
struct H{int i,x;};
int i,j,k,m,n,u,v,a[200040],b[200040],p[200040],q[200040],x[200040],y[200040];
H w[200040];
int C(H a,H b){return a.x>b.x;}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)cin>>a[i];
	for(i=0;i++<n;)
	{
		cin>>b[i];
		w[i-1]={i,b[i]};
	}
	for(i=0;i++<n;)
	{
		cin>>p[i];
		q[p[i]]=i;
		if(i^p[i]&&a[i]<=b[p[i]])
		{
			cout<<-1;
			return 0;
		}
	}
	sort(w,w+n,C);
	for(i=0;i<n;i++)
	{
		v=w[i].i;
		if(q[v]^v)
		{
			u=q[v];
			swap(p[u],p[v]);
			q[p[u]]=u;
			q[p[v]]=v;
			x[++k]=u;
			y[k]=v;
		}
	}
	cout<<k<<endl;
	for(i=0;i++<k;)cout<<x[i]<<' '<<y[i]<<endl;
}