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;
    }
}

#include <bits/stdc++.h>
#define fir first
#define sec second
#define PB push_back
#define MP make_pair

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i < (int)(n); ++i)
#define foreach(itr, c) for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)

template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); }
template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); }

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

const int N = 2e5 + 5;

int n, a[N], b[N];
int p[N], pos[N];
bool vis[N];

vi d[N];
int kd;

void dfs(int now){
    vis[now] = 1;
    d[kd].PB(now);
    if (!vis[p[now]]) dfs(p[now]);
}

bool cmp(int x, int y){
    return a[x] < a[y];
}

int main(){
    scanf("%d", &n);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &b[i]);
    rep(i, n){
        scanf("%d", &p[i]), p[i]--;
        pos[p[i]] = i;
    }
    rep(i, n) if (i != p[i] && a[i] <= b[p[i]]){
        printf("-1\n");
        return 0;
    }

    int cnt = 0;
    rep(i, n) if (!vis[i]){
        dfs(i);
        if (d[kd].size() > 1) kd++;
        else d[kd].clear(), cnt++;
    }

    rep(i, kd) sort(d[i].begin(), d[i].end(), cmp);

    printf("%d\n", n - cnt - kd);
    rep(i, kd){
        rep(j, d[i].size() - 1){
            printf("%d %d\n", d[i][j] + 1, pos[d[i][j]] + 1);
            pos[p[d[i][j]]] = pos[d[i][j]];
            p[pos[d[i][j]]] = p[d[i][j]];
        }
    }
    return 0;
}