#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
using Graph=vector<vector<pair<int,int>>>;


int main(){
  int N;
  cin>>N;
  vector<int> a(N),b(N),p(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  set<pair<int,int>> s;
  for(int i=0;i<N;i++){
    cin>>b[i];
    s.insert(make_pair(-b[i],i));
  }
  map<int,int> rp;
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]--;
    rp[p[i]]=i;
  }
  vector<pair<int,int>> ans;
  bool flag=true;
  for(auto pp:s){
    int w=-pp.first;
    int load_i=pp.second;
    int person_i=rp[load_i];
    if(person_i==load_i){
      continue;
    }
    if(a[person_i]<=b[load_i]){
      flag=false;
      break;
    }
    if(a[load_i]<=b[p[load_i]]){
      flag=false;
      break;
    }else{
      ans.push_back(make_pair(person_i,load_i));
      int load_j=p[load_i];
      p[load_i]=load_i;
      rp[load_i]=load_i;
      p[person_i]=load_j;
      rp[load_j]=person_i;
    }
  }
  if(flag==true){
    int n=ans.size();
    cout<<n<<endl;
    for(int i=0;i<n;i++){
      cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
    }
  }else{
    cout<<-1<<endl;
  }
}

#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           998244353
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)
#define hell        1000000007
#define re          resize
const int INF=1e18;
const int N=2e5+5;


int powm(int a,int b,int c)
{
  int res=1;
  while(b)
  {
    if(b&1) 
    res=(res*a)%c;
      a=(a*a)%c;
      b>>=1;
  }
 
  return res;
}
int pow(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1) 
    res=(res*a);
      a=(a*a);
      b>>=1;
  }
 
  return res;
}

vi g[N],vis2(N,0),a(N);
int idx=0,mn=INF,cnt=0;

void dfs(int node)
{ 
  
   if(a[node]<mn)
   {
     mn=a[node];
     idx=node;
   }

   vis2[node]=1;
   cnt++;
   for(auto j:g[node])
   {
     if(!vis2[j]) dfs(j);
   }
}
signed main(void)
{ios
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("answer.txt", "w", stdout);
    #endif

    
    int n;
    cin>>n;
    vi b(n+1),p(n+1),vis(n+1,0),weight(n+1),have(n+1);
    int ans=0;
    int f=1;
    vii ind;

    rep(i,1,n+1) cin>>a[i];
    rep(i,1,n+1) cin>>b[i];
    rep(i,1,n+1) 
    {
       cin>>p[i];
       if(p[i]==i) vis[i]=1;
       else have[p[i]]=i;
    } 
    
    rep(i,1,n+1)
    {
       if(!vis[i]&&b[p[i]]>=a[i]) f=0;
    }

    if(!f) {cout<<-1<<endl;return 0;}
    int grp=0;
    rep(i,1,n+1)
    {
       if(p[p[i]]==i&&!vis[i]&&!vis[p[i]])
       {
         ind.pb({i,p[i]});
         ans++;
         vis[i]=1;
         vis[p[i]]=1;
       }
    }
 
   
    rep(i,1,n+1) if(!vis[i]) {g[p[i]].pb(i);g[i].pb(p[i]);}
   
    rep(i,1,n+1)
    {
       if(!vis2[i])
       {
         mn=INF,idx=0,cnt=0;
         dfs(i);
         ans+=(cnt-1);
         int j=have[idx],k=idx; 
         rep(ii,0,cnt-1)
         {
            ind.pb({k,j});
            k=j;
            j=have[j];
         }
       }

       
    }
        
    
    cout<<ans<<endl;rep(i,0,sz(ind)) cout<<ind[i].F<<' '<<ind[i].S<<endl; 
    
  
}