#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define real long double
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pi M_PI
#define elif else if
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;


const int INF = 2e18, MOD = 998244353, RANDOM = chrono::steady_clock::now().time_since_epoch().count();
const real EPS = 1e-12;
mt19937 rng(RANDOM);
struct chash {

    int operator() (int x) const { return (x ^ RANDOM) % MOD; }
};


int n;
vector<vector<int>> people;
vector<int> ind;
vector<pair<int, int>> answer;


int search(){
    int cnt = 0;
    for (int i=0; i<n - 1; ++i){
        if (people[i][2] == people[i][3]) continue;
        if (people[i][1] >= people[i][0]) return -1;
        int j = ind[people[i][3]];
        if (people[j][1] >= people[j][0]) return -1;
        ind[people[i][2]] = j;
        ind[people[i][3]] = people[i][3];
        swap(people[i][1], people[j][1]);
        swap(people[i][2], people[j][2]);
        answer.push_back({people[i][3], people[j][3]});
        ++cnt;
    }
    return cnt;
}

    
void debug(){
    cerr << "\n";
    
    cerr << "\n";
}


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // cout.precision(6);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;
    people.assign(n, vector<int>(4, 0));
    ind.assign(n, 0);
    vector<int> b(n);
    for (int i=0; i<n; ++i) cin >> people[i][0];
    for (int i=0; i<n; ++i) cin >> b[i];
    for (int i=0; i<n; ++i){
        cin >> people[i][2];
        --people[i][2];
        people[i][1] = b[people[i][2]];
        people[i][3] = i;
    }
    sort(all(people));
    for (int i=0; i<n; ++i) ind[people[i][2]] = i;
    int res = search();
    cout << res << "\n";
    if (res != -1) for (auto i: answer) cout << i.f + 1 << " " << i.s + 1 << "\n";
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> b(N+1);
  vector<vector<int> > iap(N+1, vector<int>(3));
  vector<int> who_has(N+1);
  vector<int> who_is(N+1);
  vector<pair<int, int> > ans;
  for (int i = 1; i < 3; i++)
  {
    for (int j = 1; j < N+1; j++) cin >> iap.at(j).at(i);
    if (i == 1)
    {
      for (int j = 1; j < N+1; j++) cin >> b.at(j);
    }
  }
  for (int i = 1; i < N+1; i++) iap.at(i).at(0) = i;
  sort(iap.begin(),iap.end(),[](const vector<int> &alpha,const vector<int> &beta){return alpha[1] < beta[1];});
  for (int i = 1; i < N+1; i++)
  {
    who_has.at(iap.at(i).at(2)) = i;
    who_is.at(iap.at(i).at(0)) = i;
  }
  for (int i = 1; i < N+1; i++)
  {
    if (iap.at(i).at(0) == iap.at(i).at(2)) continue;
    if (iap.at(i).at(1) <= b.at( iap.at(i).at(2) ))
    {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(make_pair(iap.at(i).at(0), iap.at(who_has.at( iap.at(i).at(0) )).at(0)));
    iap.at(who_is.at( iap.at(who_has.at( iap.at(i).at(0) )).at(0) )).at(2) = iap.at(i).at(2);
    who_has.at( iap.at(i).at(2) ) = who_has.at( iap.at(i).at(0) );
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans.at(i).first << " " << ans.at(i).second << endl;
}
