#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int aa[2*n];
int bb[2*n];
for(int i=0;i<2*n;i++){
cin>>aa[i];
}
for(int i=0;i<2*n;i++){
cin>>bb[i];
}
pair<int,int> dp[2*n][2];
dp[0][0]={1,1};
dp[0][1]={0,0};
for(int i=1;i<2*n;i++){
int st=0;
dp[i][0]={-1,-1};
dp[i][1]={-1,-1};
if(aa[i]>=aa[i-1]){
if(dp[i-1][0].a!=-1){
dp[i][0]={dp[i-1][0].a+1,dp[i-1][0].b+1};
st=1;
}
}
if(aa[i]>=bb[i-1]){
if(dp[i-1][1].a!=-1){
if(st==0){
dp[i][0]={dp[i-1][1].a+1,dp[i-1][1].b+1};
st=1;
}
else{
dp[i][0].a=min(dp[i][0].a,dp[i-1][1].a+1);
dp[i][0].b=max(dp[i][0].b,dp[i-1][1].b+1);
st=1;
}
}
}
int stt=0;
if(bb[i]>=aa[i-1]){
if(dp[i-1][0].a!=-1){
dp[i][1]=dp[i-1][0];
stt=1;
}
}
if(bb[i]>=bb[i-1]){
if(dp[i-1][1].a!=-1){
if(stt==0){
dp[i][1]=dp[i-1][1];
}
else{
dp[i][1].a=min(dp[i][1].a,dp[i-1][1].a);
dp[i][1].b=max(dp[i][1].b,dp[i-1][1].b);
}
}
}
}
int ans[2*n];
int so=-1;
if(dp[2*n-1][0].a<=n and dp[2*n-1][0].b>=n){
so=0;
}
if(dp[2*n-1][1].a<=n and dp[2*n-1][1].b>=n){
so=1;
}
if(so==-1){
cout<<-1;
return 0;
}
ans[2*n-1]=so;
int co=n-(1-so);
for(int i=2*n-2;i>=0;i--){
int soo;
int x=aa[i+1];
if(ans[i+1]==1){
x=bb[i+1];
}
if( dp[i][0].a<=co and dp[i][0].b>=co and aa[i]<=x and co>0){
soo=0;
co-=1;
}
else if(dp[i][1].a<=co and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