#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#pragma comment(linker, "/stack:200000000")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 2e5 + 5;

int i, n, a[N], b[N], p[N], vis[N];

void solve() {
    cin >> n;
    vpii w, ans;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        w.pb({a[i], i});
    }
    for (i = 1; i <= n; i++) {
        cin >> b[i];
    }
    map<int, int> have, mp;
    for (i = 1; i <= n; i++) {
        cin >> p[i];
        have[p[i]] = i;
        mp[i] = p[i];
    }
    for (i = 1; i <= n; i++) {
        if (i != p[i] && a[i] <= b[p[i]]) {
            cout << -1 << endl;
            return;
        }
    }
    int cnt = 0;
    for (i = 1; i <= n; i++) {
        if (!vis[i]) {
            int v = i;
            cnt++;
            while (!vis[v]) {
                vis[v] = 1;
                v = p[v];
            }
        }
    }
    cout << n - cnt << endl;
    sort(all(w));
    for (i = 1; i <= n; i++) {
        if (mp[w[i - 1].s] == w[i - 1].s) {
            continue;
        }
        int give = mp[w[i - 1].s], get = have[w[i - 1].s];
        ans.pb({w[i - 1].s, get});
        have[give] = get;
        mp[get] = give;
    }
    assert(sz(ans) == n - cnt);
    for (auto &i : ans) {
        cout << i.f << " " << i.s << endl;
    }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

/*
the vast starry sky,
bright for those who chase the light.
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mk make_pair
const int inf=(int)1e9;
const ll INF=(ll)5e18;
const int MOD=998244353;
int _abs(int x){return x<0 ? -x : x;}
int add(int x,int y){x+=y; return x>=MOD ? x-MOD : x;}
int sub(int x,int y){x-=y; return x<0 ? x+MOD : x;}
#define mul(x,y) (ll)(x)*(y)%MOD
void Add(int &x,int y){x+=y; if(x>=MOD) x-=MOD;}
void Sub(int &x,int y){x-=y; if(x<0) x+=MOD;}
void Mul(int &x,int y){x=mul(x,y);}
int qpow(int x,int y){int ret=1; while(y){if(y&1) ret=mul(ret,x); x=mul(x,x); y>>=1;} return ret;}
void checkmin(int &x,int y){if(x>y) x=y;}
void checkmax(int &x,int y){if(x<y) x=y;}
void checkmin(ll &x,ll y){if(x>y) x=y;}
void checkmax(ll &x,ll y){if(x<y) x=y;}
#define out(x) cerr<<#x<<'='<<x<<' '
#define outln(x) cerr<<#x<<'='<<x<<endl
#define sz(x) (int)(x).size()
inline int read(){
    int x=0,f=1; char c=getchar();
    while(c>'9'||c<'0'){if(c=='-') f=-1; c=getchar();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
const int N=500005;
int n,a[N],b[N],p[N],id[N],pos[N];
bool cmp(int x,int y){return a[x]<a[y];}
vector<pii> ans;

int main()
{
    n=read();
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<=n;i++) b[i]=read();
    for(int i=1;i<=n;i++) p[i]=read(),pos[p[i]]=i;
    for(int i=1;i<=n;i++) if(i!=p[i]&&a[i]<=b[p[i]]){puts("-1"); return 0;}
    for(int i=1;i<=n;i++) id[i]=i;
    sort(id+1,id+n+1,cmp);
    for(int i=1;i<=n;i++){
        int u=id[i];
        if(u==p[u]) continue;
        int from=pos[u];
        ans.push_back(mk(from,u));
        pos[p[u]]=from; swap(p[from],p[u]);        
    }
    printf("%d\n",sz(ans));
    for(auto &u : ans) printf("%d %d\n",u.first,u.second);
    return 0;
}