#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n),p(n);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);
	rep(i,n) scanf("%d",&p[i]), p[i]--;

	vector<int> inv(n);
	rep(i,n) inv[p[i]]=i;

	vector<int> q(n);
	iota(q.begin(),q.end(),0);
	sort(q.begin(),q.end(),[&](int i,int j){
		return a[i]<a[j];
	});

	vector<pair<int,int>> ans;
	for(int i:q){
		if(p[i]==i) continue;
		if(a[i]<=b[p[i]]){
			puts("-1");
			return 0;
		}
		ans.emplace_back(i,inv[i]);
		p[inv[i]]=p[i];
		inv[p[i]]=inv[i];
		p[i]=i;
		inv[i]=i;
	}

	printf("%ld\n",ans.size());
	for(auto [i,j]:ans) printf("%d %d\n",i+1,j+1);

	return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second

int main(int argc, char const *argv[])
{
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  int n; cin >> n;
  vi a(n), b(n), p(n);
  for(int& x : a) cin >> x, x--;
  for(int& x : b) cin >> x, x--;
  for(int& x : p) cin >> x, x--;
  debug(a, b, p);
  vi host(n), to(n), what(n), from(n);
  set<ii> st;
  for(int i = 0; i < n; ++i) {
    from[p[i]] = i;
    to[i] = p[i];
    what[i] = b[p[i]];
    if(p[i] != i) {
      st.insert(ii(what[i], i));
    }
  }
  vector<ii> ans;
  while(st.size()) {
    debug(st);
    int y = st.begin() -> second;
    st.erase(st.begin());
    if(from[y] == y) continue;
    int x = from[y];
    if(what[x] >= a[x] or what[y] >= a[y]) {
      cout << "-1" << endl;
      exit(0);
    }
    ans.emplace_back(x+1, y+1);
    st.erase(ii(what[x], x));
    what[x] = what[y];
    st.insert(ii(what[x], x));
    to[x] = to[y];
    from[to[x]] = x;
  }
  cout << sz(ans) << "\n";
  for(ii& pa : ans) {
    cout << pa.fi << ' ' << pa.se << "\n";
  }
  return 0;
}