#line 1 "main.cpp"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> xs(n), ys(n), ps(n);
    for (auto& x : xs) cin >> x;
    for (auto& y : ys) cin >> y;
    for (auto& p : ps) {
        cin >> p;
        --p;
    }

    vector<int> prev(n);
    for (int i = 0; i < n; ++i) prev[ps[i]] = i;

    vector<int> is(n);
    iota(is.begin(), is.end(), 0);
    sort(is.begin(), is.end(),
         [&](auto i, auto j) { return xs[i] < xs[j]; });

    vector<pair<int, int>> ans;
    for (auto i : is) {
        if (ps[i] == i) continue;
        if (ys[ps[i]] >= xs[i]) {
            cout << "-1\n";
            return;
        }

        int j = prev[i];
        ans.emplace_back(i, j);

        swap(prev[ps[i]], prev[ps[j]]);
        swap(ps[i], ps[j]);
    }

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


struct bit {
    vector<ll> a;
    int n;
    void init(int _n) {
	n = _n;
	a.resize(n+10);
    }

    void upd(int i, ll dx) {
	for (; i<=n; i+=i&-i) {
	    a[i] += dx;
	}
    }

    ll qry(int i) {
	ll res = 0;
	for (; i; i-=i&-i) {
	    res += a[i];
	}
	return res;
    }
};

ll invs(vector<int> a) {
    int n = a.size();
    ll res = 0;
    bit bit;
    bit.init(n);
    for (int i=n-1; i>=0; i--) {
	res += bit.qry(a[i]);
	bit.upd(a[i],+1);	
    }
    return res;
}

vector<int> rand_perm(int n, int index=1) {
    assert(n>=1);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    vector<int> a(n);
    iota(a.begin(), a.end(), index);
    shuffle(a.begin(), a.end(), rng);
    return a;
}


// needs to be 1 cycle, with n-1 inversions
bool check(vector<int> a) {
    int n = a.size();
    if (invs(a) != n-1) return false;

    
    for (int i=0; i<n; i++) {
	a[i] --;
    }
    vector<int> viz(n,0);
    int len = 0;
    int at = 0;
    while (!viz[at]) {
	len++;
	viz[at]=1;
	at=a[at];
    }
    return len==n;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    /*auto p = rand_perm(10);
    while (!check(p)) {
	p = rand_perm(10);
    }
    for (int x: p) cout<<x<<" ";
    cout<<endl;*/


    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    if (!check(a)) out(-1);



    
    for (int i=0; i<n; i++) {
	a[i] --;
    }
    vector<int> ans;

    for (int i=0; i<n; i++) {
	if (i>a[i]) {
	    for (int j=i-1; j>=a[i]; j--) {
		ans.push_back(j);
	    }
	}
    }

    assert(int(ans.size()) == n-1);


    for (int i: ans) {
	cout<<i+1<<"\n";
	swap(a[i],a[i+1]);
    }

    assert(is_sorted(a.begin(),a.end()));
    return 0;
}
