#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &b[i]);
    int p[n], owner[n];
    rep(i, n) {
        scanf("%d", &p[i]);
        --p[i];
        owner[p[i]] = i;
    }

    vector<int> idx(n);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(),
         [&](const int& i, const int& j) { return a[i] < a[j]; });
    vector<pii> ans;
    for (auto i : idx) {
        int j = owner[i];
        if (i == j) continue;
        if (a[i] <= b[p[i]] || a[j] <= b[p[j]]) {
            puts("-1");
            return 0;
        }
        ans.emplace_back(i, j);
        swap(p[i], p[j]);
        swap(owner[p[i]], owner[p[j]]);
    }

    printf("%d\n", ans.size());
    for (auto [i, j] : ans) printf("%d %d\n", i + 1, j + 1);
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
#define pi M_PI
typedef pair<ll, ll> llPair;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef priority_queue<ll> pqll;
ll MOD = 1000000007;
/*
Really doe, like really doe
Really doe, like really doe
*/
class DisjSet {
    int *rank, *parent, *size, n;

public:
    DisjSet(int n)
    {
        rank = new int[n];
        parent = new int[n];
        size = new int[n];
        this->n = n;
        makeSet();
    }
    void makeSet()
    {
        for (int i = 0; i < n; i++) {
            parent[i] = i;
            size[i] = 1;
        }
    }
    int siz(int x)
    {
        return size[x];
    }
    int find(int x)
    {
        if (parent[x] != x) {
            parent[x] = find(parent[x]);
        }

        return parent[x];
    }
    void Union(int x, int y)
    {
        int xset = find(x);
        int yset = find(y);

        if (xset == yset)
            return;

        if (rank[xset] < rank[yset]) {
            parent[xset] = yset;
            size[yset] = size[yset] + size[xset];
        }
        else if (rank[xset] > rank[yset]) {
            parent[yset] = xset;
            size[xset] = size[yset] + size[xset];
        }
        else {
            parent[yset] = xset;
            rank[xset] = rank[xset] + 1;
            size[xset] = size[yset] + size[xset];
        }
    }
};


int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    t = 1;
    for (ll z = 0; z < t; ++z)
    {
        ll n;
        cin >> n;
        vll a(n);
        vll b(n);
        vll p(n);
        vll p2(n);
        vb finish(n, false);
        DisjSet obj(n);
        bool pos = true;
        ll res = n;
        for (ll i = 0; i < n; ++i)
        {
            cin >> a[i];
        }
        for (ll i = 0; i < n; ++i)
        {
            cin >> b[i];
        }
        for (ll i = 0; i < n; ++i)
        {
            cin >> p[i];
            p[i]--;
            if (obj.find(i) != obj.find(p[i]))
            {
                obj.Union(i, p[i]);
                --res;
            }
            p2[p[i]] = i;
            if (p[i] != i && a[i] <= b[p[i]])
            {
                pos = false;
            }
            else if (p[i] == i)
            {
                finish[i] = true;
            }
        }

        if (!pos)
        {
            cout << -1 << '\n';
            continue;
        }
        else if (n == 1)
        {
            cout << 0 << '\n';
            continue;
        }
        vector<tuple<ll, ll, ll>> pair(n);
        for (ll i = 0; i < n; ++i)
        {
            pair[i] = make_tuple(b[p[i]], i, p2[i]);
        }
        cout << n - res << '\n';
        ll k = n - res;
        sort(pair.begin(), pair.end());
        for (ll i = 0; i < n; ++i)
        {
            ll j = get<1>(pair[i]);
            if (!finish[obj.find(j)])
            {
                finish[obj.find(j)] = true;
                ll t = get<2>(pair[i]);
                while (t != j)
                {
                    cout << t + 1 << ' ' << p[t] + 1 << '\n';
                    t = p2[t];
                }
            }
        }

    }

    return 0;
}
