#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;
    }
    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;
}

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

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

typedef pair<int, int> pi;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long long int ll;
typedef unsigned long long int  ull;
typedef priority_queue<ll> mxhpl;
typedef priority_queue<int> mxhpi;
typedef priority_queue<ll, vector<ll>, greater<ll>> mnhpl;
typedef priority_queue<int, vector<int>, greater<int>> mnhpi;

#define rep(i,start,end) for(ll i = start; i <= end; ++i)
#define rrep(i,end,start) for(ll i = end; i >= start; --i)
#define parr(a,n) rep(i,0,n-1){cout << a[i] << " ";}cout<<"\n"
#define sarr(a,n) rep(i,0,n-1)cin >> a[i]
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define mset(a,x) memset(a, x, sizeof(a))
#define ps(x,y) fixed<<setprecision(y)<<x //cout << ps(ans, decimal places);
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)

// DEBUGGING
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; }
template<typename T>
void __print(const T& x) { int f = 0; cerr << '{'; for (auto& i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// Fast IO
void IO() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif
}

#define MOD 1000000007

//CODE
/*******************************************************/
#define MX 200001 

ll n;


void solve() {
  cin >> n;
  vl a(n), b(n), c(n), whoHasMyBag(n);

  sarr(a, n);
  sarr(b, n);
  sarr(c, n);
  vector<pll> wp;
  rep(i, 0, n - 1) {
    if (c[i] - 1 != i && a[i] <= b[c[i] - 1]) {
      cout << "-1\n";
      return;
    }
    c[i]--;
    wp.pb({ a[i],i });
    whoHasMyBag[c[i]] = i;
  }

  sort(all(wp));
  vector<pll> ans;
  for (auto p : wp) {
    if (c[p.S] == p.S) continue;
    ans.pb({ p.S + 1,whoHasMyBag[p.S] + 1 });

    c[whoHasMyBag[p.S]] = c[p.S];
    whoHasMyBag[c[whoHasMyBag[p.S]]] = whoHasMyBag[p.S];
  }

  // debug("TEST");
  cout << ans.size() << "\n";
  for (auto p : ans) {
    cout << p.F << " " << p.S << "\n";
  }
  // debug(ans, c);
}

int main() {
  IO();
  int t = 1;

  // cin >> t;

  while (t--) {
    solve();
  }
  return 0;
}

/*******************************************************/
