#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#ifdef SINA
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args> void __f (const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); }
#define dbg2(x, j, n) cout<< #x << " : "; output((j), (n), x, 1);
#else
#define dbg(...) 0
#define dbg2(x, j, n) 0
#endif
#define SZ(x) ((ll)((x).size()))
#define File(s, t) freopen(s ".txt", "r", stdin); freopen(t ".txt", "w", stdout);
#define input(j, n, a) for (int _i = (j); _i < (n)+(j); _i++) cin>> a[_i];
#define output(j, n, a, t) for (int _i = (j); _i < (n)+(j); _i++) cout<< a[_i] << (((t) && _i != (n)+(j)-1)? ' ' : '\n');
#define kill(x) return cout<< x << endl, 0
#define cl const ll
#define fr first
#define sc second
#define lc (v << 1)
#define rc (lc | 1)
#define mid ((l + r) >> 1)
#define All(x) (x).begin(), (x).end()

cl inf = sizeof(ll) == 4 ? (1e9 + 10) : (3e18), mod = 1e9 + 7, MOD = 998244353;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out << '(' << a.first << ", " << a.second << ')';    }
template <class A> ostream& operator << (ostream& out, const vector<A> &a) {
    if(!a.size())return cout<<"[]";cout<< '[' << a[0]; for (int i = 0; ++i < (int)(a.size());) cout<< ", " << a[i];cout<< ']';  }
template <class T, typename _t = less <T> > using Tree = tree <T, null_type, _t, rb_tree_tag, tree_order_statistics_node_update>;

cl N = 2e5 + 7;

ll par [N], a [N], b [N], p [N];
vector <ll> comp [N];

ll root (ll v) { return par[v] = (par[v] == v ? v : root(par[v])); }
inline void unite (ll v, ll u) { par[root(u)] = root(v); }

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

    iota(par, par + N, 0);

    ll n, ans = 0;
    cin>> n;
    input(1, n, a);
    input(1, n, b);
    input(1, n, p);
    for (ll i = 1; i <= n; i++) {
        if (i == p[i])  continue;
        if (b[p[i]] >= a[i])    kill(-1);
        unite(i, p[i]);
    }

    ans = n;
    for (ll i = 1; i <= n; i++) {
        if (par[i] == i)    ans--;
        comp[root(i)].push_back(i);
    }

    cout<< ans << '\n';

    for (ll i = 1; i <= n; i++) if (SZ(comp[i]) > 1) {
        sort(All(comp[i]), [&](ll x, ll y) { return a[x] > a[y]; });
        ll hvy = comp[i][0];
        while (p[hvy] ^ hvy) {
            cout<< hvy << ' ' << p[hvy] << '\n';
            swap(p[hvy], p[p[hvy]]);
        }
    }

    cerr<< "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}
/*

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n; cin >> n;
	vi a(n), b(n), p(n), h(n);
    bool possible = true;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n) cin >> p[i];
	rep(i,n) p[i]--;
	rep(i,n) h[p[i]] = i;
	rep(i,n){
		if(i != p[i] && a[i] <= b[p[i]]) possible = false;
	}
	if(possible == false){
		cout << -1 << endl;
		return 0;
	}
	vector <pii> bb; rep(i,n) bb.pb(mp(b[i],i));
	vector <pii> ans;
	sort(all(bb));
	reverse(all(bb));
	rep(i,n){
		int bi = bb[i].snd; //bi is bag
		int bw = bb[i].fst;
		int hb = h[bi]; //hb is holder of bag
		if(bi == hb) continue; //Already holds bag
		ans.pb(mp(bi,h[bi]));
		swap(h[bi], h[p[bi]]); //Bags swap owners
		swap(p[bi], p[hb]); //Owners swap bags
	}
	cout << sz(ans) << endl;
	rep(i,sz(ans)){
		cout << ans[i].fst + 1 << " " << ans[i].snd + 1 << '\n';
	}
	return 0;
}

