#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

bool solve(long long N, std::vector<long long> &a, std::vector<long long> &b, std::vector<long long> &p) {
	map<int, int> m;
	vector<int> seq(N);
	iota(seq.begin(), seq.end(), 0);
	sort(seq.begin(), seq.end(), [&](int lhs, int rhs) {
		return a[lhs] < a[rhs];
	});
	for (int i = 0; i < N; ++i) {
		if (p[i] != i && a[i] <= b[p[i]]) {
			return false;
		}
		m[p[i]] = i;		// 荷物p[i]はiが持っている
	}
	vector<II> ans;
	for (int i = 0; i < N; ++i) {
		int j = seq[i];
		if (m[j] == j) continue;
		int target = m[j];
		ans.emplace_back(II(j + 1, target + 1));
		m[p[j]] = target;
		m[j] = j;
		swap(p[j], p[target]);
	}
	cout << ans.size() << endl;
	for (auto kv : ans) {
		cout << kv.first << " " << kv.second << endl;
	}
	return true;
}

int main() {
    long long N;
	std::cin >> N;
	std::vector<long long> a(N), b(N), p(N);
	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		std::cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		std::cin >> p[i]; p[i]--;
	}
	if (!solve(N, a, b, p)) {
		cout << -1 << endl;
	}
	return 0;
}

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define vll vector<ll> 
#define vvl vector<vll>
#define pii pair<ll,ll>
#define F first
#define S second
#define endl "\n"
#define M 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll min(ll a,ll b){if(a<b) return a; return b;}
 
ll po(ll x, ll y){
    if(y==0)
    return 1;
    if(y%2){
        return ((x)*(po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
    }
   return ((po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
}
 
 
void seive(bool prime[]){
    //bool prime[100002]; 
     
  
    for (ll p=2; p*p<=1000001; p++) 
    { 
        if (prime[p]) 
        { 
            for (ll i=p*p; i<=1000001; i+=p) 
                prime[i] = false; 
        } 
    }
}

ll powermod(ll x,ll y,ll p)  
{   ll res = 1;     
    x = x % p; 
 if (x == 0) return 0;  
    while (y > 0)  
    {     if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

ll gcd(ll x, ll y){
    if (y == 0)
    return x;
    else
    return gcd(y, x % y);
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
    //cin>>t;
    while(t--){
        ll n; cin>>n;
        vll a(n),b(n);
        vll mx(n);
        fo(i,n){
            cin>>a[i];
            if(i==0)
            mx[i]=a[i];
            else
            mx[i]=max(a[i],mx[i-1]);
        }
        fo(i,n)
        cin>>b[i];
        vll c(n);
        c[0]=a[0]*b[0];
        for(ll i=1; i<n; i++){
            c[i]=max(c[i-1],b[i]*mx[i]);
        }
        fo(i,n)
        cout<<c[i]<<endl;
    }
    return 0;
}