#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define Li inline
#define R register int
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
//#define int ll
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=2e5+7;
int n,m;
int a[N],b[N],p[N],id[N],q[N];
vector<pi>v;

bool cmp(int lhs,int rhs){
	return b[lhs]>b[rhs];
}

signed main(){
	read(n);
	fs(i,1,n)read(a[i]);
	fs(i,1,n)id[i]=i,read(b[i]);
	fs(i,1,n)read(p[i]),q[p[i]]=i;
	sort(id+1,id+n+1,cmp);
	fs(i,1,n){
		int x=id[i];
		if(q[x]==x)continue;
		if(a[q[x]]>b[x]&&a[x]>b[p[x]]){
			v.push_back(mpi(q[x],x));
			p[q[x]]=p[x];
			q[p[x]]=q[x];
		}else{
			printf("-1");return 0;
		}
	}
	int len=v.size();
	printf("%d\n",len);
	fs(i,0,len-1){
		printf("%d %d\n",v[i].first,v[i].second);
	}
	return 0;
}

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n),b(n),p(n);
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>> pq;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
        pq.push({b[i],i});
    }
    vector<ll> f(n);
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i]--;
        f[p[i]]=i;
    }
    vector<string> ans;
    while(!pq.empty()){
        // 重さ、荷物番号
        auto [weight, index] = pq.top();pq.pop();
        auto current_owner = f[index];
        auto current_bag   = index;
        auto true_owner = index;
        if(current_owner == true_owner)continue;
        auto true_owner_bag = p[true_owner];

        if(a[current_owner]>b[current_bag]&&a[true_owner]>b[true_owner_bag]){
            ans.push_back(to_string(current_owner+1)+" "+to_string(true_owner+1));
            f[true_owner_bag] = current_owner;
            f[current_bag] = true_owner;
            p[current_owner] = true_owner_bag;
            p[true_owner] = current_bag;
        }else{
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << ans.size() << std::endl;
    for (auto e : ans) {
        std::cout << e << std::endl;
    }
}
