//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod= 1e9+7;
long double pi = acosl(-1);
//const ll infl = LLONG_MAX;
const int inf = 1e9+2;
const int nmax = 2e5+5;
//const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

void NA(){
    cout<<"-1", exit(0);
}


int a[nmax], b[nmax], p[nmax];
pii a2[nmax];
int koi[nmax];

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

    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];
    for(int i=1; i<=n; i++) a2[i] = {a[i], i};
    sort(a2+1, a2+1+n);
    for(int i=1; i<=n; i++){
        koi[ a2[i].second ] = i;
    }
    for(int i=1; i<=n; i++){
        if(p[i]!=i and b[ p[i] ] >= a[i]) NA();
    }

    vector<pii>ans;
    for(int i=1; i<=n; i++){
        int manid = a2[i].second;
        int bagid = p[ manid ];
        while( koi[ bagid ] < i){
            ans.push_back( {manid, bagid} );
            bagid = p[ bagid ];
            p[ manid ] = bagid;
        }
    }
    cout<<ans.size()<<"\n";
    for(pii z : ans) cout<<z.first<<" "<<z.second<<"\n";
}
/*
*/

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }

class BinaryIndexedTree {
private:
	int n;
	vector<ll> bit;

public:
	BinaryIndexedTree(int num)
	{
		// 0は番兵
		n = num + 1;
		bit.assign(n + 1, 0);
	}

	// idx is 1-indexed
	void add(int idx, ll val)
	{
		while (idx <= n) {
			bit[idx] += val;
			idx += idx & -idx;
		}
	}

	// [1, idx) idx is 1-indexed
	ll sum(int idx)
	{
		ll sum = 0;
		while (0 < idx) {
			sum += bit[idx];
			idx -= idx & (-idx);
		}
		return sum;
	}

	// [a, b) idx is 1-indexed
	ll range(int a, int b)
	{
		return (sum(b) - sum(a));
	}

	// val-th number (val is 0-indexed)
	int lower_bound(ll val)
	{
		int idx = 0;
		int k = 1;
		while (2 * k <= n) {
			k <<= 1;
		}
		for (; 0 < k; k >>= 1) {
			if (idx + k < n && bit[idx + k] < val) {
				val -= bit[idx + k];
				idx += k;
			}
		}
		return idx + 1;
	}
};

struct PINFO {
	ll	pIdx;
	ll	pWeight;
	ll	bIdx;
	ll	bWeight;
};

// 処理
void Solve()
{
	ll K;
	cin >> K;
	vector<PINFO> hito(K);
	VL b2w(K);
	REP(i, K) {
		ll a;
		cin >> a;
		hito[i].pIdx = i;
		hito[i].pWeight = a;
	}
	REP(i, K) {
		ll b;
		cin >> b;
		b2w[i] = b;
	}
	REP(i, K) {
		ll p;
		cin >> p;
		p--;
		hito[i].bIdx = p;
		hito[i].bWeight = b2w[p];
	}

	for (auto one : hito) {
		if (one.pIdx != one.bIdx) {
			if (one.pWeight <= one.bWeight) {
				cout << -1 << endl;
				return;
			}
		}
	}

	vector<PINFO> sortedHito = hito;
	auto comp = [](PINFO a, PINFO b) {
		return a.pWeight < b.pWeight;
	};
	sort(ALL(sortedHito), comp);

	VL b2Idx(K);
	REP(i, K) {
		auto one = hito[i];
		b2Idx[one.bIdx] = i;
	}

	vector<P> ans;
	for (PINFO s : sortedHito) {
		ll srcIdx = s.pIdx;
		auto &src = hito[srcIdx];
		auto dstIdx = b2Idx[srcIdx];
		auto &dst = hito[dstIdx];

		if (dstIdx == srcIdx) continue;
		
		ans.emplace_back(src.pIdx + 1, dst.pIdx + 1);

		swap(b2Idx[src.bIdx], b2Idx[dst.bIdx]);
		swap(src.bIdx, dst.bIdx);
		swap(src.bWeight, dst.bWeight);
	}

	cout << ans.size() << endl;
	for (auto a : ans) {
		cout << a.first << " " << a.second << endl;
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}
