/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N=2e5+10;

inline int Rint(int &r){
	int b=1,c=getchar();r=0;
	while(c<'0' || '9'<c) b=c=='-'? -1:b,c=getchar();
	while('0'<=c && c<='9') r=(r<<1)+(r<<3)+(c^'0'),c=getchar();
	return r*=b;
}

int n,m,nstk,cnt;
int wei[N],now[N],uni[N],ans[N<<1][2],stk[N],fstk[N];
pair<int,int> lmt[N];
bool vis[N];

void Answer(int a,int b){
	a=lmt[a].second,b=lmt[b].second;
	ans[++m][0]=a,ans[m][1]=b;
	swap(now[a],now[b]);
}
int main(){
	Rint(n);
	for(int i=1;i<=n;i++) Rint(lmt[i].first),lmt[i].second=i;
	for(int i=1;i<=n;i++) Rint(wei[i]);
	for(int i=1;i<=n;i++) Rint(now[i]);
	for(int i=1;i<=n;i++)
		if(now[i]!=i && wei[now[i]]>=lmt[i].first){
			printf("-1\n");
			return 0;
		}
	sort(lmt+1,lmt+1+n);
	for(int i=1;i<=n;i++){
		uni[lmt[i].second]=i;
		if(lmt[i].second==now[lmt[i].second])
			vis[i]=true;
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			nstk=0;
			int tmp=i;
			while(true){
				stk[++nstk]=tmp;
				tmp=uni[now[lmt[tmp].second]];
				if(tmp==i) break;
			}
			fstk[cnt=1]=stk[1];
			for(int j=2;j<=nstk;j++)
				if(fstk[cnt]>stk[j]) Answer(fstk[cnt],stk[j]);
				else fstk[++cnt]=stk[j];
			for(int j=1;j<cnt;j++)
				Answer(fstk[j],fstk[cnt]);
		}
	//for(int i=1;i<=n;i++)
	//	printf("%d %d\n",i,now[i]);
	printf("%d\n",m);
	for(int i=1;i<=m;i++)
		printf("%d %d\n",ans[i][0],ans[i][1]);
	return 0;
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using ll = long long;
using ld = long double;



#define mp make_pair
/*
int p =  1e9 + 7;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}*/


mt19937 rnd(time(0));

/*
const int N = 2000005;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/




/*struct DSU
{
    vector<int> sz;
    vector<int> parent;
    vector<bool> cycle;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a==b) cycle[a] = true;
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
            if (cycle[b]) cycle[a] = true;
        }
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        cycle.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n; cin>>n;
    vector<int> a(n), b(n), p(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    for (int i = 0; i<n; i++) cin>>b[i];
    for (int i = 0; i<n; i++) {cin>>p[i]; p[i]--;}

    vector<int> have(n);
    for (int i = 0; i<n; i++) have[i] = b[p[i]];

    for (int i = 0; i<n; i++) if (a[i]<=have[i] && p[i]!=i) {cout<<-1; return 0;}

    vector<pair<int, int>> ops;
    vector<bool> visited(n);
    for (int i = 0; i<n; i++) if (p[i]!=i && !visited[i])
    {
        vector<int> bruh = {i};
        visited[i] = true;
        int cur = p[i];
        while (cur!=i)
        {
            visited[cur] = true; bruh.push_back(cur); cur = p[cur];
        }


        int best = 0;

        int k = bruh.size();

        for (int j = 1; j<k; j++) if (have[bruh[j]]<have[bruh[best]]) best = j;

        for (int i = 0; i<k-1; i++)
        {
            ops.push_back(mp(bruh[(best-i-1+k)%k], bruh[(best-i+k)%k]));
        }
    }

    cout<<ops.size()<<endl;
    for (auto it: ops) cout<<it.first+1<<' '<<it.second+1<<endl;




}
