//arc111_c.cpp
//Sat Jan  9 22:32:39 2021

#include <bits/stdc++.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;

	vector<int> konohitonotaijyu(n);
	vector<P> taijyu;
	rep(i,n){
		int tmp;
		cin >> tmp;
		taijyu.push_back(P(tmp,i));
		konohitonotaijyu[i] = tmp;
	}
	vector<int> cargo(n);
	rep(i,n){
		cin >> cargo[i];
	}

	//何番さんが何番の荷物持ってるか
	vector<int> cn(n);
	rep(i,n){
		cin >> cn[i];
		cn[i]--;
	}
	//何番の荷物を何番さんが持ってるか
	vector<int> mn(n);
	rep(i,n){
		mn[cn[i]]=i;
	}

	sort(taijyu.begin(),taijyu.end());
	vector<int> order;
	rep(i,n){
		order.push_back(taijyu[i].second);
	}

	vector<P> ans;
	rep(i,n){
		int from = order[i];
		if (cn[from]==from)continue;
		if (cargo[cn[from]]>=konohitonotaijyu[from]){
			if (i==n-1)break;
			cout << -1 << endl;
			return 0;
		}
		int to = mn[order[i]];
		ans.push_back(P(from,to));
		int fromnimotu = cn[from];
		int tonimotu = cn[to];
		int x = fromnimotu;
		cn[from] = tonimotu;
		cn[to] = fromnimotu;
		mn[fromnimotu] = to;
		mn[tonimotu] = from;
	}

	cout << ans.size() << endl;

	rep(i,ans.size()){
		cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
	}
}
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> A(n + 1), B(n + 1), P(n + 1), par(n + 1);
	vector<vector<int>> cycles(n + 1);
	int cid = 0;
	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];
		par[i] = P[i];
	}
	vector<int> vs(n + 1, 0);
	for(int i = 1; i <= n; ++i) {
		if(!vs[i]) {
			int x = i;
			while(!vs[x]) {
				cycles[cid].push_back(x);
				vs[x] = 1;
				x = par[x];
			}
			cid += 1;
		}
	}
	vector<pair<int, int>> ans;
	bool imps = 0;
	for(auto cycle: cycles) {
		set<pair<int, int>> wts;
		for(auto x: cycle) {
			// cout<<"x = "<<x<<endl;
			if(B[par[x]] >= A[x] && par[x] != x) {
				imps = 1;
			}
			wts.insert({B[par[x]], x});
		}
		while(!imps && !wts.empty()) {
			auto tp = --wts.end();
			int cur = tp->second;
			int nxt = par[cur];
			wts.erase(tp);
			if(nxt == cur) {
				continue;
			}
			// cout<<" next "<<nxt<<" "<<cur<<endl;
			par[cur] = par[nxt];
			par[nxt] = nxt;
			ans.push_back({cur, nxt});
			wts.insert({B[par[cur]], cur});
			if(B[par[cur]] >= A[cur] && par[cur] != cur) {
				imps = 1;
				break;
			}
		}
	}
	if(imps) {
		cout<<"-1\n"<<endl;
		return 0;
	}
	cout<<ans.size()<<endl;
	for(auto x: ans) {
		cout<<x.first<<" "<<x.second<<endl;;
	}
	
	return 0;
}