#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define real long double
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pi M_PI
#define elif else if
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;


const int INF = 2e18, MOD = 998244353, RANDOM = chrono::steady_clock::now().time_since_epoch().count();
const real EPS = 1e-12;
mt19937 rng(RANDOM);
struct chash {

    int operator() (int x) const { return (x ^ RANDOM) % MOD; }
};


int n;
vector<vector<int>> people;
vector<int> ind;
vector<pair<int, int>> answer;


int search(){
    int cnt = 0;
    for (int i=0; i<n - 1; ++i){
        if (people[i][2] == people[i][3]) continue;
        if (people[i][1] >= people[i][0]) return -1;
        int j = ind[people[i][3]];
        if (people[j][1] >= people[j][0]) return -1;
        ind[people[i][2]] = j;
        ind[people[i][3]] = people[i][3];
        swap(people[i][1], people[j][1]);
        swap(people[i][2], people[j][2]);
        answer.push_back({people[i][3], people[j][3]});
        ++cnt;
    }
    return cnt;
}

    
void debug(){
    cerr << "\n";
    
    cerr << "\n";
}


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // cout.precision(6);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;
    people.assign(n, vector<int>(4, 0));
    ind.assign(n, 0);
    vector<int> b(n);
    for (int i=0; i<n; ++i) cin >> people[i][0];
    for (int i=0; i<n; ++i) cin >> b[i];
    for (int i=0; i<n; ++i){
        cin >> people[i][2];
        --people[i][2];
        people[i][1] = b[people[i][2]];
        people[i][3] = i;
    }
    sort(all(people));
    for (int i=0; i<n; ++i) ind[people[i][2]] = i;
    int res = search();
    cout << res << "\n";
    if (res != -1) for (auto i: answer) cout << i.f + 1 << " " << i.s + 1 << "\n";
}
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif


const int MAXN = 2e5+10;


int a[MAXN];
int b[MAXN];
int p[MAXN];
int q[MAXN];



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> a[i];
    for (int i = 1; i <= N; i++) cin >> b[i];
    for (int i = 1; i <= N; i++) cin >> p[i], q[p[i]] = i;
    for (int i = 1; i <= N; i++) {
		if (a[i] <= b[p[i]] and p[i] != i) {
			cout << -1 << "\n";
			return 0;
		}
	}
    vector<int> o;
    for (int i = 1; i <= N; i++) o.push_back(i);
    sort(o.begin(), o.end(), [&](int i, int j) {return b[i] > b[j];});
    //for (int x : o) cout << x << " " << b[x] << endl;
    
    vector<pair<int,int>> op;
    for (int x : o) {
		if (p[x] == x) continue;
		int y = q[x];
		op.push_back({x,y});
		q[p[x]] = y;
		p[y] = p[x];
		q[x] = x;
		p[x] = x;
	}
    cout << op.size() << "\n";
    for (auto pp : op) cout << pp.first << " " << pp.second << "\n";
}
