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

const int maxn = 2e5+8, inf = 1e18+9, mod  = 1e9+7;

int n, m, a[maxn], b[maxn], p[maxn], vs[maxn];

void solve() {
    int i, j;
    //cin >> n;
    scanf("%lld", &n);
    vector<pair<int, int>> vec;
    for (i = 1; i <= n; i++) scanf("%lld", &a[i]); //cin >> a[i];
    for (i = 1; i <= n; i++) scanf("%lld", &b[i]); //cin >> b[i];
    for (i = 1; i <= n; i++) scanf("%lld", &p[i]); //cin >> p[i];
    for (i = 1; i <= n; i++) if (a[i] <= b[p[i]] && i != p[i]) return (void)(printf("-1\n"));
    for (i = 1; i <= n; i++) if (!vs[i]) {
        int start = i; vs[i] = 1;
        if (i == p[i]) continue;
        for (j = p[i]; j != i; j = p[j]) {
            vs[j] = 1;
            if (a[j] > a[start]) start = j;
        }
        for (j = p[start]; j != start; j = p[j]) vec.push_back({start, j});
    }
    //cout << vec.size() << endl;
    printf("%lld\n", (int)vec.size());
    for (auto [x, y] : vec) printf("%lld %lld\n", x, y); //cout << x << " " << y << endl;
}

signed main() {
    //ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); //cout << fixed << setprecision(15);
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}


#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
#include <utility>


using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}


int main(void){
	//限界値が軽い方から処理
	int n,i;cin>>n;
	vector<int>a(n);
	vector<int>b(n);
	vector<int>p(n);
	vector<int>g(n);
	vector<pair<int,int>>sa(n);
	for(i=0;i<n;i++){cin>>a[i];sa[i]=mp(a[i],i);}
	for(i=0;i<n;i++){cin>>b[i];}
	for(i=0;i<n;i++){cin>>p[i];p[i]--;g[p[i]]=i;}
	for(i=0;i<n;i++){
		if(p[i]!=i){if(a[i]<=b[p[i]]){cout<<-1<<endl;return 0;}}
	}
	SO(sa);
	vector<pair<int,int>>ans;
	for(i=0;i<n;i++){
		int t=sa[i].sec;
		if(t==p[t]){continue;}
		int s=g[t];
		swap(p[t],p[s]);
		swap(g[p[t]],g[p[s]]);
			ans.pub({t+1,s+1});
	}
	cout<<ans.size()<<endl;
	for(auto it:ans){cout<<it.fir<<" "<<it.sec<<endl;}
}
