#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>people_weight(n);
    vector<int>bag_weight(n);
    vector<int>has_bag(n);
    set<pair<int,int>>people_priority;
    vector<int>has_my_bag(n);
    for(int i = 0; i < n; ++i){
        cin >> people_weight[i];
        people_priority.insert({people_weight[i],i});
    }
    for(int j = 0; j < n; ++j){
        cin >> bag_weight[j];
    }
    for(int i = 0; i < n; ++i){
        cin >> has_bag[i];
        has_bag[i]--;
        has_my_bag[has_bag[i]] = i;
    }
    bool works = true;
    vector<pair<int,int>>ans;
    while(people_priority.size()){
        auto nxt = *people_priority.begin();
        int me = nxt.second;
        people_priority.erase(people_priority.begin());
        if(has_bag[me] == me){
            continue;
        }
        else if(bag_weight[has_bag[me]] >= people_weight[me]){
            //cerr << me << " has a weight of "<< people_weight[me] 
            //<<  " he is carrying a bag of weight of "<<       
             // bag_weight[has_bag[me]] << "\n";
            works = false;
            break;
        }
        else{
            int who = has_my_bag[me];
            if(bag_weight[has_bag[who]] >= people_weight[who]){
                works = false;
                break;
            }
            has_my_bag[has_bag[me]] = who;
            has_bag[who] = has_bag[me];
            has_bag[me] = me;
            ans.emplace_back(me,who);
            //cerr << me << " and "<< who << " are exchanging bags\n";
        }
    }
    if(works){
        cout << ans.size() << "\n";
        for(auto a : ans){
            cout << a.first+1 << " " << a.second+1 << "\n";
        }
        
    }
    else {
        cout << "-1\n";
    }
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n), B(n), P(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    copy_n(istream_iterator<int>(cin), n, B.begin());
    copy_n(istream_iterator<int>(cin), n, P.begin());

    for (auto &p: P)
        p--;

    for (int i = 0; i < n; i++){
        if (i != P[i] and A[i] <= B[P[i]]){
            puts("-1");
            return 0;
        }
    }

    vector<array<int, 2>> AI(n);
    for (int i = 0; i < n; i++){
        AI[i][0] = A[i];
        AI[i][1] = i;
    }

    sort(AI.begin(), AI.end());

    vector<int> Q(n);
    for (int i = 0; i < n; i++)
        Q[P[i]] = i;

    vector<array<int, 2>> ans;
    for (const auto &[a, i]: AI){
        if (i == P[i])
            continue;
        const int j = Q[i];
        ans.push_back({i, j});
        Q[P[i]] = j;
        Q[i] = i;
        swap(P[i], P[j]);
    }

    cout << ans.size() << endl;
    for (const auto &[i, j]: ans)
        cout << i + 1 << " " << j + 1 << "\n";
}