#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;
 
template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
 
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int where[1 << 20];
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	VI a(n), b(n), p(n);
	FOR(i, 0, n)
		cin >> a[i];
	FOR(i, 0, n)
		cin >> b[i];
	vector<PII> arr;
	FOR(i, 0, n)
	{
		cin >> p[i];
		p[i]--;
		where[p[i]] = i;
		if(i == p[i]) continue;
		if(a[i] <= b[p[i]])
		{
			cout << "-1" << endl;
			return 0;
		}
		arr.PB(MP(a[i], i));
	}
	vector<PII> ans;
	sort(ALL(arr));
	FOR(j, 0, SZ(arr))
	{
		int i = arr[j].Y;
		if(p[i] == i) continue;
		ans.PB(MP(i, where[i]));
		
		where[p[i]] = where[i];
		swap(p[i], p[where[i]]);
	}
	
	
	cout << SZ(ans) << endl;
	FOR(i, 0, SZ(ans))
		cout << ans[i].X + 1 << " " << ans[i].Y + 1 << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<class T>
class BIT {
    vector<T> bit;
public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T sum(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret += bit[k];
        return ret;
    }

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    auto u = v;
    sort(u.begin(), u.end());
    u.erase(unique(u.begin(), u.end()), u.end());
    for (int i = 0; i < n; ++i) {
        v[i] = lower_bound(u.begin(),u.end(), v[i])-u.begin();
    }
    BIT<int> bit(n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += i-bit.sum(v[i]);
        bit.add(v[i], 1);
    }
    vector<int> S(u.size()+1);
    for (int i = 0; i < n; ++i) {
        S[v[i]+1]++;
    }
    for (int i = 0; i < u.size(); ++i) {
        S[i+1] += S[i];
    }
    for (int i = 0; i < n; ++i) {
        printf("%lld\n", ans);
        ans += (n-S[v[i]+1]-S[v[i]]);
    }
    return 0;
}