#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, a[MX], b[MX], aux[MX], p[MX], vis[MX];
vii res;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	forn (i, n) cin >> a[i + 1];
	forn (i, n) cin >> aux[i + 1];
	forn (i, n) cin >> p[i + 1];
	
	for (int i = 1; i <= n; i++)
		b[i] = aux[p[i]];
	
	for (int i = 1; i <= n; i++) if (!vis[i]) {
		vi v;
		int u = i;
		
		while (!vis[u]) {
			vis[u] = 1;
			v.pb(u);
			u = p[u];
		}
		
		if (v.size() == 1) continue;
		
		for (int u : v)
			if (b[u] >= a[u]) {
				cout << -1 << endl;
				return 0;
			}
		
		int ind = 0;
		forn (j, v.size())
			if (a[v[j]] > a[v[ind]])
				ind = j;
			
		forn (j, (int)v.size() - 1) {
			int to = (ind + j + 1) % (int)v.size();
			res.pb({v[ind], v[to]});
		}
	}
	
	cout << res.size() << endl;
	for (ii &p : res)
		cout << p.fi << " " << p.se << endl;
	
	return 0;
}

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

// clang-format off
#define forn(i, x, y) for (int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
#define all(v) v.begin(), v.end()
// clang-format on

using VI = vector<int>;

class UF
{
    vector<int> root;

public:
    UF(int n)
    {
        root.resize(n);
        forn(i, 0, n) root[i] = i;
    }

    int find(int x)
    {
        while (x != root[x])
            x = root[x] = root[root[x]];
        return x;
    }

    int connect(int x, int y)
    {
        return root[find(x)] = find(y);
    }
};

int N;
int X[100], Y[100];

bool check(double r)
{
    UF uf(N + 2);
    forn(i, 0, N)
    {
        if (Y[i] - 2 * r < -100)
            uf.connect(N, i);
        if (Y[i] + 2 * r > 100)
            uf.connect(N + 1, i);
    }

    forn(i, 0, N) forn(j, 0, N)
    {
        if (hypot(X[i] - X[j], Y[i] - Y[j]) < 2 * r)
            uf.connect(i, j);
    }
    return uf.find(N) != uf.find(N + 1);
}

int main()
{
    IOS;
    cin >> N;
    forn(i, 0, N) cin >> X[i] >> Y[i];

    double l = 0.0, r = 100.0, m;
    forn(i, 0, 100)
    {
        m = (l + r) / 2;
        if (check(m))
            l = m;
        else
            r = m;
    }
    cout << fixed << setprecision(10) << l << endl;

    return 0;
}
