#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF  = 1e9;
constexpr llong  LINF = 1e18;
constexpr double EPS  = 1e-12;
constexpr int    MOD  = 1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a)cerr<<(cnt++?' ':'>')<<elem;cerr<<endl;}

/*エラトステネスの篩*/
class Sieve{
	int size;					//size:=(要素数).
	std::vector<int> max_fact;	//max_fac[n]:=(nの最大の素因数（max_fact[n]=nのとき,iは素数）). 
	std::vector<int> primes;	//primes:=([0,size)間の素数の集合).
	
public:
	//constructor.
	Sieve():Sieve(51e4){}
	Sieve(size_t n):size(n+1),max_fact(n+1,-1){//n以下の自然数を篩にかける. O(N*loglogN).
		for(int i=2;i<size;++i){
			if(max_fact[i]==-1){
				max_fact[i]=i;
				primes.push_back(i);
				for(int j=i+i;j<size;j+=i) max_fact[j]=i;
			}
		}
	}
	
	bool is_prime(int n) const{//素数判定. O(1).
		assert(0<=n and n<size);
		return max_fact[n]==n;
	}
	std::vector<int> get_primes() const{return primes;}
	std::map<int,int> prime_factorize(int n) const{//高速素因数分解.　O(logN).
		assert(0<=n and n<size);
		std::map<int,int> res;
		while(n>1){
			res[max_fact[n]]++;
			n/=max_fact[n];
		}
		return res;
	}
	std::vector<int> divisors(int n) const{//約数列挙.
		std::vector<int> res({1});
		auto pf=prime_factorize(n);
		for(auto [p,cnt]:pf){
			int sz=res.size();
			for(int i=0;i<sz;++i){
				int v=1;
				for(int j=0;j<cnt;++j){
					v*=p;
					res.push_back(res[i]*v);
				}
			}
		}
		return res;
	}
};

int main(){//I refer to other commentaries.
	int n;
	cin>>n;
	
	Sieve ob;
	for(int i=1;i<=n;++i){
		auto mp=ob.prime_factorize(i);
		
		int tmp=0;
		for(auto [ignore,cnt]:mp) tmp+=cnt;
		
		cout<<tmp+1<<endl;
	}
}
#include <bits/stdc++.h>
#pragma GCC optimize(3)
#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
using namespace std; const int N=200010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
	return s*w;
}
int n,a[N],b[N],p[N],to[N];
vector<pair<int,int> > w;
vector<pair<int,int> > Ans;
signed main()
{
	n=read();
	for(ri int i=1;i<=n;i++) a[i]=read(), w.eb(mk(a[i],i));
	for(ri int i=1;i<=n;i++) b[i]=read();
	for(ri int i=1;i<=n;i++) p[i]=read(), to[p[i]]=i;
	sort(w.begin(),w.end());
	for(ri int i=0;i<(int)w.size();i++)
	{
		int x=w[i].second;
		int y=to[x];
		if(x==y) continue;
		if(a[x]>b[p[x]] && a[y]>b[p[y]])
		{
			Ans.eb(mk(x,y));
			swap(p[x],p[y]);
			to[p[x]]=x, to[p[y]]=y;
		}
		else return puts("-1")&0;
	}
	printf("%lld\n",(int)Ans.size());
	for(auto i:Ans) printf("%lld %lld\n",i.first,i.second);
	return 0;
}