#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p){
  REP(N){
    if(i!=p[i]&&a[i]<=b[p[i]]){
      cout<<-1<<endl;
      return;
    }
  }
  auto cmp=[&](ll x,ll y){
    if(b[p[x]]>b[p[y]]){
      return true;
    }else if(b[p[x]]<b[p[y]]){
      return false;
    }else{
      return p[x]>p[y];
    }
  };
  set<ll,decltype(cmp)> notyet(cmp);
  REP(N){
    if(i!=p[i]){
      if(i==12660)dump(i);
      notyet.insert(i);
      if(notyet.count(i)==0)abort();
    }
  }
  vector<pll> ans;
  while(!notyet.empty()){
    ll cur1=*(notyet.begin());notyet.erase(cur1);
    if(cur1==12660)dump(cur1);
    ll cur2=p[cur1];
    if(cur2==12660)dump(cur2);
    if(notyet.count(cur2)==0)abort();
    notyet.erase(cur2);
    ans.push_back(pll(cur1,cur2));
    swap(p[cur1],p[cur2]);
    if(cur2!=p[cur2])abort();
    if(p[cur1]!=cur1){
      if(cur1==12660)dump(cur1);
      notyet.insert(cur1);
    }
  }
  REP(N){
    if(p[i]!=i)abort();
  }
  cout<<ans.size()<<endl;
  REP(ans.size()){
    cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
        --p[i];
    }
    solve(N, std::move(a), std::move(b), std::move(p));
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define efo(i,u,v) for(int i=BB[u],v=B[BB[u]][1];i;v=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
int main()
{
	//freopen("a.in","r",stdin);
	int a,b,x,y;
	a=read(),b=read(),x=read(),y=read();
	y=min(y,x+x);
	int t=a>b?a-b-1:b-a;
	printf("%d\n",t*y+x);
	return 0;
}
