#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
int main() {
	int N;
	scanf("%d", &N);
	int A[N], B[N], P[N], Q[N];
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	for (int i = 0; i < N; ++i) scanf("%d", &B[i]);
	for (int i = 0; i < N; ++i) scanf("%d", &P[i]), --P[i];
	for (int i = 0; i < N; ++i) Q[P[i]] = i;
	priority_queue<ii> pq;
	for (int i = 0; i < N; ++i) pq.push(ii(B[P[i]], P[i]));
	vector<ii> ans;
	for (int i = 0; i < N; ++i) {
		ii hv = pq.top();
		pq.pop();
		int x = Q[hv.second], y = hv.second;
		if (x == y) continue;
		if (B[P[x]] >= A[x] || B[P[y]] >= A[y]) {
			printf("-1");
			return 0;
		}
		ans.push_back(ii(x + 1, y + 1));
		swap(Q[P[x]], Q[P[y]]);
		swap(P[x], P[y]);
	}
	printf("%lu\n", ans.size());
	for (ii i: ans) printf("%d %d\n", i.first, i.second);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define ll  long long
#define ull  long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn =5e5+5;
const ll mod=998242361 ;
const ll base=1e18;
bool dd[maxn];
pll b[maxn];
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("t.inp","r"))
    {
        freopen("test.inp","r",stdin);
        freopen("test.out","w",stdout);
    }
    ll n;
     cin>>n ;
     n*=2;
     for (int i=1;i<=n;i++)
     {
         cin>>a[i];
         b[i]=make_pair(a[i],i);
     }
     sort(b+1,b+n+1);
     for (int i=1;i<=n/2;i++) dd[b[i].ss]=1;
     bool chk=false;
     ll cnt=0;
     string ans;
     for (int i=1;i<=n;i++)
     {
          if (cnt==0)
          {
              chk=dd[i];
              ans.pb('(');
              cnt++;
          }
          else
          {
               if (dd[i]!=chk)
               {
                   cnt--;
                   ans.pb(')');
               }
               else
               {
                   cnt++;
                   ans.pb('(');
               }
          }
     }
     cout <<ans;

}
