#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 200001;

int A[N], B[N], P[N], IP[N];
vector<pii > v, ans;

int main() {
  int n;
  S(n);
  rep(i,1,n+1) {
    S(A[i]);
    v.pb(mp(A[i], i));
  }
  rep(i,1,n+1) {
    S(B[i]);
  }
  rep(i,1,n+1) {
    S(P[i]);
    IP[P[i]] = i;
  }

  sort(all(v));
  rep(i,0,v.size()) {
    int x = v[i].SS;
    if(IP[x] == x) continue;
    if(B[P[x]] >= A[x]) {
      P(-1);
      return 0;
    }
    ans.pb(mp(x, IP[x]));
    int y = P[x];
    IP[y] = IP[x];
    P[IP[x]] = y;
    IP[x] = x;
    P[x] = x;
  }
  P((int)ans.size());
  rep(i,0,ans.size()) {
    printf("%d %d\n",ans[i].FF, ans[i].SS);
  }
  return 0;
}

#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using lint = long long;
using ulint = unsigned long long;
template<class T>using graph = vector<vector<T>>;
#define endl '\n'
int const INF = 1<<30;
lint const INF64 = 1LL<<61;
lint const mod = 1e9+7;
//long const mod = 998244353;
lint ceilDiv(lint x, lint y){if(x >= 0){return (x+y-1)/y;}else{return x/y;}}
lint floorDiv(lint x, lint y){if(x >= 0){return x/y;}else{return (x-y+1)/y;}}
lint Sqrt(lint x){lint upper = 1e9;lint lower = 0;while(upper - lower > 0){lint mid = (1+upper + lower)/2;if(mid * mid > x){upper = mid-1;}else{lower = mid;}}return upper;}
lint gcd(lint a,lint b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
lint lcm(lint a,lint b){return (a / gcd(a,b)) * b;}
lint chmin(vector<lint>&v){lint ans = INF64;for(lint i:v){ans = min(ans, i);}return ans;}
lint chmax(vector<lint>&v){lint ans = -INF64;for(lint i:v){ans = max(ans, i);}return ans;}
double dist(double x1, double y1, double x2, double y2){return sqrt(pow(x1-x2, 2) + pow(y1-y2,2));}
vector<lint>prime;void makePrime(lint n){prime.push_back(2);for(lint i=3;i<=n;i+=2){bool chk = true;for(lint j=0;j<prime.size() && prime[j]*prime[j] <= i;j++){if(i % prime[j]==0){chk=false;break;}}if(chk)prime.push_back(i);}}

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int 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]--;
        if(i != p[i] && a[i] <= b[p[i]]){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<pair<int,int>>ans;
    vector<int>invP(n);  //荷物iを誰が持ってるか
    for(int i=0;i<n;i++){
        invP[p[i]] = i;
    }
    priority_queue<pair<lint,int>>que;
    for(int i=0;i<n;i++){
        que.push({b[i], i});
    }
    while(!que.empty()){
        auto f = que.top();
        que.pop();
        if(f.second == invP[f.second])continue;
        int nimotu1 = f.second;
        int hito1 = invP[f.second];
        int hito2 = nimotu1;
        int nimotu2 = p[hito2];
        ans.push_back({hito1+1, 1+hito2});
        p[hito1] = nimotu2;
        p[hito2] = nimotu1;
        invP[nimotu1] = hito2;
        invP[nimotu2] = hito1;
    }
    cout << ans.size() << endl;
    for(auto p: ans){
        cout << p.first << " " << p.second<<endl;
    }

}

