//#define NDEBUG

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}
constexpr char eoln = '\n';
template <class T> T ceildiv(const T &l, const T &r) {
  return l / r + (l % r != 0 ? 1 : 0);
}

} // namespace n91

#include <numeric>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  std::vector<u32> a(n), b(n);
  std::vector<usize> p(n), inv(n);
  for (auto &e : a) {
    std::cin >> e;
  }
  for (auto &e : b) {
    std::cin >> e;
  }
  for (auto &e : p) {
    std::cin >> e;
    --e;
  }

  for (const usize i : rep(0, n)) {
    if (a[i] <= b[p[i]] && p[i] != i) {
      std::cout << "-1" << eoln;
      return;
    }
  }

  for (const usize i : rep(0, n)) {
    inv[p[i]] = i;
  }

  std::vector<std::pair<usize, usize>> ans;

  std::vector<usize> idx(n);
  std::iota(idx.begin(), idx.end(), usize(0));
  std::sort(idx.begin(), idx.end(),
            [&](usize l, usize r) { return b[l] > b[r]; });
  for (const usize i : idx) {
    if (p[i] == i) {
      continue;
    }
    const usize j = inv[i];
    std::swap(inv[p[i]], inv[p[j]]);
    std::swap(p[i], p[j]);
    ans.emplace_back(i, j);
  }
  std::cout << ans.size() << eoln;
  for (const auto &e : ans) {
    std::cout << e.first + 1 << " " << e.second + 1 << eoln;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}

//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 998244353LL;
// static const ll MOD = (1LL << 61LL) - 1LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807LL

template <ull N, class T, class... Args, std::enable_if_t<N == 0, int> = 0>
auto make_multiple_vector(Args... args) {
    return T(args...);
}

template <ull N, class T, class... Args, std::enable_if_t<N != 0, int> = 0>
auto make_multiple_vector(ull size, Args... args) {
    using value_type = std::decay_t<decltype(make_multiple_vector<N - 1, T>(args...))>;
    return vector<value_type>(size, make_multiple_vector<N - 1, T>(args...));
}

int solve() {
	ll n;
	cin >> n;
	
	vector<ll> as(n), bs(n), ps(n);
	REPD(i, 0, n) cin >> as[i];
	REPD(i, 0, n) cin >> bs[i];
	REPD(i, 0, n) cin >> ps[i], --ps[i];

	vector<pair<ll, ll>> results;
	vector<bool> is_visited(n, false);
	REPD(i, 0, n) {
		if (is_visited[i]) continue;

		ll begin_idx = i, curr_idx = i;
		vector<ll> idxs;
		ll cnt = 0, min_cnt;
		ll min_val = MAX_VALUE;
		do {
			if (as[curr_idx] <= bs[ps[curr_idx]] && curr_idx != ps[curr_idx]) RET(-1);
			idxs.emplace_back(curr_idx);
			if (bs[ps[curr_idx]] < min_val) {
				min_val = bs[ps[curr_idx]];
				min_cnt = cnt;
			}
			++cnt;
			is_visited[curr_idx]= true;
			curr_idx = ps[curr_idx];
		}
		while (curr_idx != begin_idx);
		
		REPD(j, 1, idxs.size()) {
			results.emplace_back(idxs[min_cnt] + 1LL, idxs[(min_cnt - 1LL + idxs.size()) %  idxs.size()] + 1LL);
			min_cnt = (min_cnt - 1LL + idxs.size()) %  idxs.size();
		}
	}

	cout << results.size() << endl;
	REPI(res, results) cout << res.first << " " << res.second << endl;

	return 0;
}

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}
