#include <bits/stdc++.h>
#define pii pair<int,int>
#define S second
#define F first
using namespace std;
const int maxn=2e5+5;
struct node{
    int x,id;
}a[maxn];
bool cmp(node a,node b){
    return a.x<b.x;
}
vector<pii> ans;
int n,b[maxn],p[maxn],Id[maxn],cnt;
main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i].x,a[i].id=i;
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<=n;i++){
        cin>>p[i],Id[p[i]]=i;
        if(b[p[i]]>=a[i].x&&p[i]!=i){
            cout<<-1;
            return 0;
        }
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        if(p[a[i].id]!=a[i].id){
            int now=a[i].id;
            ans.push_back({now,Id[now]});
            p[Id[now]]=p[now];
            Id[p[now]]=Id[now];
        }
    }
    cout<<ans.size()<<'\n';
    for(auto i:ans)
        cout<<i.F<<" "<<i.S<<'\n';
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 1000000000000 //10^12:∞
#define MOD 10000000 //10^9+7:合同式の法
 
//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート

int main() {
  long long int n,m;
  cin >>n>>m;
if(n==1&&m==0){
    cout<<1<<" "<<2<<endl;
    return 0;
}
if(n==m||n==-m||n-1==m||n-1==-m){
    cout<<-1<<endl;
    return 0;
}

if(m==0){
rep(i,1,n+1){
    cout<<i<<" "<<n*2-i+1<<endl;
}
}

if(m>0){
    cout<<1<<" "<<MOD<<endl;
rep(i,2,m+2){
    cout<<i*2<<" "<<i*2+1<<endl;
}
    cout<<MOD-1<<" "<<MOD+1<<endl;
rep(i,0,n-m-2){
    cout<<i*2+MOD+2<<" "<<i*2+1+MOD+2<<endl;
}
}

if(m<0){
   cout<<-1<<endl;
}

return 0;
}