#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fir first
#define sec second
using namespace std;
signed main(){
int n, x; cin>>n;
n--;
int cb[n+1]={0};
map<int, int> mp;
int tmp; cin>>tmp;
mp[tmp]++;
vector<int> a(n+1, 0), b(n+1, 0);
for(int i=1; i<=n; i++){
cin>>x;
a[i]=max(a[i-1], x);
mp[x]++;
}
cin>>tmp;
for(int i=1; i<=n; i++){
cin>>x;
b[i]=max(b[i-1], x);
mp[x]++;
}
for(int i=1; i<=n; i++){
//a için b'ye lower bound atcaz
auto it=lower_bound(b.begin(), b.end(), a[i]);
int cnt=it-b.begin();
cnt--;
mp[a[i]]+=cnt;
cb[cnt]++;
}
int add=cb[0];
for(int i=1; i<=n; i++){
mp[b[i]]+=add;
add+=cb[i];
}
int col=0, mx=0;
for(auto it=mp.begin(); it!=mp.end(); it++){
int ccol=(*it).fir, cval=(*it).sec;
//cout<<ccol<<" "<<cval<<"\n";
if(mx<cval){
mx=cval;
col=ccol;
}
else if(mx==cval){
col=max(col, ccol);
}
}
cout<<col<<" "<<mx<<"\n";
return 0;
}