#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=2e5;
int n;
int a[maxn+5],b[maxn+5];
int c[maxn+5];
int p[maxn+5],id[maxn+5];
int anss;
bool used[maxn+5];
struct Ans{
	int x,y;
}ans[maxn+5];
bool check(){
	for(int i=1;i<=n;i++)
		if(p[i]!=i&&b[p[i]]>=a[i]) return 1;
	return 0;
}
bool cmp(int ta,int tb){
	return a[ta]<a[tb];
}
void work(int st){
	int s=0;
	for(;!used[st];st=p[st]){
		c[++s]=st; used[st]=1;
	}
	sort(c+1,c+1+s,cmp);
	for(int i=1;i<s;i++){
		ans[++anss]=Ans{c[i],id[c[i]]};
		p[id[c[i]]]=p[c[i]];
		id[p[c[i]]]=id[c[i]];
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		id[p[i]]=i;
	}
	if(check()){
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(!used[i]) work(i);
	printf("%d\n",anss);
	for(int i=1;i<=anss;i++)
		printf("%d %d\n",ans[i].x,ans[i].y);
	return 0;
}

#include <bits/stdc++.h>
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
using namespace std;

const int maxn = 2e5+10;

int n, a[maxn], b[maxn], p[maxn];
int pre[maxn];
vector<pair<int,int> > ans;

void debug() {
	printf("p: ");
	REP(i,1,n) printf("%d%c", p[i], " \n"[i==n]);
	printf("pre: ");
	REP(i,1,n) printf("%d%c", pre[i], " \n"[i==n]);
}

void solve(int i) {
	int mn = i;
	vector<int> loop;
	for (int x = p[i]; x != i; x = p[x]) {
		if (b[p[x]] < b[p[mn]]) mn = x;
	}
	for (int x = pre[mn]; x != mn; x = pre[x]) {
		ans.push_back(make_pair(x, p[x]));
	}
	for (int x = p[i]; x != i; x = p[x]) {
		loop.push_back(x);
	}
//	printf("SOLVE: %d %d\n", i, (int)loop.size()); 
	for (int x = 0; x < (int)loop.size(); ++x) {
		p[loop[x]] = pre[loop[x]] = loop[x];
	}
}

signed main() {
	scanf("%d", &n);
	REP(i,1,n) scanf("%d", a+i);
	REP(i,1,n) scanf("%d", b+i);
	REP(i,1,n) scanf("%d", p+i), pre[p[i]] = i;
	REP(i,1,n) {
		if (p[i] != i && b[p[i]] >= a[i]) {
			puts("-1");
			return 0;
		}
	}
	REP(i,1,n) if (p[i] != i) solve(i);
	printf("%d\n", (int)ans.size());
	REP(i,0,(int)ans.size()-1) {
		printf("%d %d\n", ans[i].first, ans[i].second);
	}
}