#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include<iomanip>

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vpl = std::vector<pll>;
using vb = std::vector<bool>;
using db = double;
using vdb = std::vector<db>;
using qlg= std::priority_queue<ll, vl, std::greater<ll> > ; //ascending
using qll= std::priority_queue<ll, vl, std::less<ll> > ; // descending
using qdg= std::priority_queue<db, vdb, std::greater<db> > ; //ascending
using qdl= std::priority_queue<db, vdb, std::less<db> > ; // descending
template<class T>
using vv = std::vector<std::vector<T> >;
using std::cout; using std::string;
using std::endl; using std::cin;
using std::transform; using std::toupper;

#define REPL(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FORL(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FORL(i, 0, n)

#define MREP(i, n) for (ll i= (ll)(n)-1; i>=0; i-- )
#define MFOR(i, a, b) for (ll i = (ll)(b)-1; i >= (ll)(a); i--)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
#define INF pow(10, 10)
void chmin(ll& a, ll b){ if(a > b) a = b; }
void chmax(ll& a, ll b){ if(a < b) a = b; }


int main(void)
{
    // たてx, 横y

    ll N, M;
    cin >> N >> M;
    vl As(N), Bs(M);


    REP(i, N)
    {
        cin >> As[i];
    }

    REP(i, M)
    {
        cin >> Bs[i];
    }

    ll i = 0, j = 0;
    while(i < N && j < M)
    {
        if(As[i] == Bs[j])
        {
            i ++;
            j ++;
        }
        else if(As[i] < Bs[j])
        {
            cout << As[i] << " ";
            i++;
        }
        else
        {
            cout << Bs[j] << " ";
            j ++;
        }
    }

    if(i < N)
    {
        while(i<N)
        {
            cout << As[i] << " ";
            i++;
        }
    }
    else
    {
        while(j < M)
        {
            cout << Bs[j] << " ";
            j ++;
        }
    }

    cout << endl;


    return 0;
}

// ＵＴＦ−８

#include<bits/stdc++.h>
/* #include<atcoder/all> */
/* using namespace atcoder; */

using namespace std;
using ll = long long int;
using lc = complex<double>;

template<class T>bool chmax(T &a, const T &b) { return (a<b ? (a=b,1) : 0); }
template<class T>bool chmin(T &a, const T &b) { return (a>b ? (a=b,1) : 0); }

int main(void) {
    constexpr ll MOD = 1 ? 1e9+7 : 998244353;
    const double PI = acos(-1);
    constexpr double eps = 1e-10;
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    if(1) {
        ll n;
        cin >> n;
        vector<ll> a(n), b(n), p(n), rp(n);
        for(auto &e: a) cin >> e;
        for(auto &e: b) cin >> e;
        for(auto &e: p) cin >> e, e--;

        for(ll i=0; i<n; i++)
            rp[p[i]] = i;
            

        vector<tuple<ll,ll>> aa(n);
        for(ll i=0; i<n; i++)
            aa[i] = {a[i], i};
        sort(begin(aa), end(aa));

        vector<tuple<ll,ll>> res;
        for(ll i=0; i<n; i++) {
            auto [_, j] = aa[i];
            if(p[j] == j) continue;
            ll k = rp[j];
            if(a[j] <= b[p[j]]) {
                cout << -1 << endl;
                return 0;
            }
            if(a[k] <= b[p[k]]) {
                cout << -1 << endl;
                return 0;
            }
            swap(rp[p[j]], rp[p[k]]);
            swap(p[j], p[k]);
            res.push_back({j, k});
        }

        cout << res.size() << endl;
        for(auto [x, y]: res)
            cout << x+1 << ' ' << y+1 << endl;

    }

    return 0;
}