//IQ134高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}



int main() {
	ll ans = 0;
	ll tmp = 0;
	int n; cin >> n;
	vector<int> a(n), b(n), p(n);
    cin >> a >> b >> p;
    bool ch = true;
    REP(i, n) p[i]--;
    REP(i, n){
        if(p[i] != i && a[i] <= b[p[i]]) ch = false;
    } 
    if(ch == false){
        cout << -1 << endl;
    }
    else{
        priority_queue<pair<int, int>> q;
        vector<pair<int, int> > answer;
        REP(i, n){
            q.push(make_pair(a[i], i));
        }
        while(!q.empty()){
            int tai = q.top().first;
            int num = q.top().second;
            q.pop();
            //cout << "human" << num << "(weight:" << tai << ") has bag" << p[num] << endl;
            if(p[num] == num) continue;
            else{
                answer.push_back(make_pair(num, p[num]));
                swap(p[num], p[p[num]]);
                q.push(make_pair(tai, num));
            }
        }
        cout << answer.size() << endl;
        REP(i, answer.size()) cout << answer[i].first + 1 << " " << answer[i].second + 1 << endl;
    }
	//cout << ans << endl;
}
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*--------------------------------------------------------------------------------------*/

signed main() { EmiliaMyWife
	int n;
	cin >> n;
	vector<int> arr(n + 1), brr(n + 1), p(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> arr[i];
	for(int i = 1; i <= n; i++)
		cin >> brr[i];
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	vector<pair<int, int>> owo(n);
	for(int i = 0; i < n; i++)
		owo[i] = {arr[i + 1], i + 1};
	sort(owo.begin(), owo.end(), greater<pair<int, int>>());
	vector<pair<int, int>> ans;
	for(const auto &[a, id] : owo) {
		if(p[id] == id)
			continue;
		if(a <= brr[p[id]])
			return cout << "-1\n", 0;
		while(p[id] != id) {
			if(arr[p[id]] <= brr[p[p[id]]])
				return cout << "-1\n", 0;
			ans.push_back({id, p[id]});
			swap(p[id], p[p[id]]);
		}
	}
	cout << ans.size() << '\n';
	for(auto [a, b] : ans)
		cout << a << ' ' << b << '\n';
}
