#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using pdd = pair<double, double>; using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using pbb = pair<bool, bool>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using pss = pair<string, string>; using vs = vector<string>; using vvs = vector<vs>; using vvvs = vector<vvs>;
#define repeat(counter, start, goal, step) for (int counter = (int)(start); counter < (int)(goal); counter += step)
#define rep(counter, times) repeat(counter, 0, times, 1)
#define rep2(counter, start, goal) repeat(counter, start, goal, 1)
#define rep0(times) repeat(counter, 0, times, 1)
#define rrepeat(counter, start, goal, step) for (int counter = (int)(start); counter > (int)(goal); counter -= step)
#define rep3(counter, start, goal) rrepeat(counter, start, goal, 1)
#define rrep(counter, start, goal) rrepeat(counter, start - 1, goal - 1, 1)
#define all(container) begin(container), end(container)
template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; }
template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; }
void yn(bool flag) { cout << (flag ? "yes" : "no") << "\n"; }
void Yn(bool flag) { cout << (flag ? "Yes" : "No") << "\n"; }
void YN(bool flag) { cout << (flag ? "YES" : "NO") << "\n"; }
void set_prec(const int &digits) { cout << fixed << setprecision(digits); cerr << fixed << setprecision(digits); }
template <typename T> void pr(const T &obj) { cerr << obj; }
template <typename T, typename ...Ts> void pr(const T &first, const Ts &...rest) { pr(first); pr(", "); pr(rest...); }
template <typename S, typename T> void pr(const pair<S, T> &pair) { pr("("); pr(pair.first); pr(", "); pr(pair.second); pr(")"); }
template <typename T> void pr(const vector<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename T> void pr(const vector<vector<T>> &vv) { pr("\n"); rep(index, vv.size()) { pr("["); pr(index); pr("]: "); pr(vv[index]); pr("\n"); } }
template <typename T> void pr(const set<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename S, typename T> void pr(const map<S, T> &map) { pr("{"); for (pair<S, T> pair : map) { pr("("); pr(pair.first); pr(": "); pr(pair.second); pr("), "); } pr("}"); }
#define db(obj) cerr << #obj << ": "; pr(obj); cerr << " "
#define dl(obj) db(obj); cerr << "\n";
#define dm(...) cerr << "(" << #__VA_ARGS__ << "): ("; pr(__VA_ARGS__); cerr << ") "
#define dml(...) dm(__VA_ARGS__); cerr << "\n"
// #include <atcoder/all>
// using namespace atcoder;
// const ll MOD = 1000000007;
// const ll MOD = 998244353;

int main() {
	int N, S, D; cin >> N >> S >> D;
	vi X(N), Y(N);
	rep(i, N) cin >> X[i] >> Y[i];
	bool f = false;
	rep(i, N) if (X[i] < S && Y[i] > D) f = true;
	Yn(f);
}
#include <bits/stdc++.h>
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
using namespace std;

const int maxn = 2e5+10;

int n, a[maxn], b[maxn], p[maxn];
int pre[maxn];
vector<pair<int,int> > ans;

void debug() {
	printf("p: ");
	REP(i,1,n) printf("%d%c", p[i], " \n"[i==n]);
	printf("pre: ");
	REP(i,1,n) printf("%d%c", pre[i], " \n"[i==n]);
}

void solve(int i) {
	int mn = i;
	vector<int> loop;
	for (int x = p[i]; x != i; x = p[x]) {
		if (b[p[x]] < b[p[mn]]) mn = x;
	}
	for (int x = pre[mn]; x != mn; x = pre[x]) {
		ans.push_back(make_pair(x, p[x]));
	}
	for (int x = p[i]; x != i; x = p[x]) {
		loop.push_back(x);
	}
//	printf("SOLVE: %d %d\n", i, (int)loop.size()); 
	for (int x = 0; x < (int)loop.size(); ++x) {
		p[loop[x]] = pre[loop[x]] = loop[x];
	}
}

signed main() {
	scanf("%d", &n);
	REP(i,1,n) scanf("%d", a+i);
	REP(i,1,n) scanf("%d", b+i);
	REP(i,1,n) scanf("%d", p+i), pre[p[i]] = i;
	REP(i,1,n) {
		if (p[i] != i && b[p[i]] >= a[i]) {
			puts("-1");
			return 0;
		}
	}
	REP(i,1,n) if (p[i] != i) solve(i);
	printf("%d\n", (int)ans.size());
	REP(i,0,(int)ans.size()-1) {
		printf("%d %d\n", ans[i].first, ans[i].second);
	}
}