#include<bits/stdc++.h>
using namespace std;
const int N=500005;
typedef long long ll;
int n,p[N],q[N],a[N],b[N],i,id[N];
bool cmp(int x,int y)
{
	return b[x]>b[y];
}
struct str{
	int u,v;
};
vector<str> g;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&b[i]);
		id[i]=i;
	}
	sort(id+1,id+1+n,cmp);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&p[i]);
		q[p[i]]=i;
	}
	for(i=1;i<=n;++i)
	{
		int x=id[i];
		if(q[x]!=x)
		if(a[q[x]]>b[x]&&a[x]>b[p[x]])
		{
			g.push_back((str){x,q[x]});
			int u=p[x],v=q[x];
			q[u]=v;
			p[v]=u;
		}
		else
		{
			puts("-1");
			return 0;
		}
	}
	printf("%d\n",g.size());
	for(auto it:g)
		printf("%d %d\n",it.u,it.v);
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
#define debug(output) cout<<#output<<"= "<<output<<endl
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n),b(n),p(n),memo(n,0);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>p[i];
  rep(i,n)--p[i];
  rep(i,n)memo[p[i]]=i;
  priority_queue<P,vector<P>,greater<P>> que;
  rep(i,n){
    que.push({a[i],i});
  }
  vector<P> res;
  while(!que.empty()){
    auto [w,i]=que.top();que.pop();
    if(i==p[i])continue;
    else if(a[i]<=b[p[i]]||a[memo[i]]<=b[i]){
      cout<<-1<<"\n";
      return 0;
    }
    int hoge=p[i];
    res.push_back({i,memo[i]});
    swap(p[i],p[memo[i]]);
    swap(memo[i],memo[hoge]);
  }
  cout<<res.size()<<"\n";
  rep(i,res.size()){
    cout<<res[i].first+1<<" "<<res[i].second+1<<"\n";
  }
  return 0;
}