//10/12/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll int
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

vector<ll>v;
ll a[200005],b[200005];
unordered_map<ll,ll>mp;

int main(){
    _fastio
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ll x;
        cin>>x;
        mp[x]++;
    }
    ll ans=1,aud=0,sub=0;
    ll m;
    cin>>m;
    for(ll i=1;i<=m;i++) cin>>a[i];
    for(ll i=1;i<=m;i++) cin>>b[i];
    for(ll i=1;i<=m;i++){
        ll x,y;
        x=a[i];
        y=b[i];
        ll x1=mp[x];
        ll y1=mp[y];
        if(x1>aud){
            ans=i;
            aud=x1;
            sub=y1;
        }
        else if(x1==aud){
            if(y1>sub){
                ans=i;
                aud=x1;
                sub=y1;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


//10/12/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll int
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

vector<ll>v;
ll a[200005],b[200005];
map<ll,ll>mp;

int main(){
    _fastio
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ll x;
        cin>>x;
        mp[x]++;
    }
    ll ans=1,aud=0,sub=0;
    ll m;
    cin>>m;
    for(ll i=1;i<=m;i++) cin>>a[i];
    for(ll i=1;i<=m;i++) cin>>b[i];
    for(ll i=1;i<=m;i++){
        ll x,y;
        x=a[i];
        y=b[i];
        ll x1=mp[x];
        ll y1=mp[y];
        if(x1>aud){
            ans=i;
            aud=x1;
            sub=y1;
        }
        else if(x1==aud){
            if(y1>sub){
                ans=i;
                aud=x1;
                sub=y1;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(v.size()){
        pt<T>(v[i]);
    }
}

/*********************************asserting****************************/

template <class T>
void asserty(T in,T out){

    if(in != out){
        ps("Test not passed:");
        pt<T>(in);
        ps("expected :");
        pt<T>(out);
    }
}

void assertv(vi in,vi out){
    bool equals = true;
    if( in.size()!=out.size()){
        equals = false;
    }else{
        loop(in.size()){
            if(in[i]!=out[i]){
                equals = false;
                break;
            }

        }

    }

    if(!equals){
        ps("Test not passed:");
        pv<int>(in);
        ps("expected :");
        pv<int>(in);
    }
}

/*********************************reused****************************/
int n,m;
const int N = 200009;
lli a[N],b[N],c[N],f[N],l[N];

bool compare(int i,int j){
    return l[a[i]]>l[a[j]] || (l[a[i]]==l[a[j]] && l[b[i]]>l[b[j]]);

}
int main()
{
   cin>>n;
   loop(N){
    l[i]=0;
   }
   loop(n){
    cin>>a[i];
    l[a[i]]++;
   }
   cin>>m;
   loop(m){
    cin>>b[i];
   }

   loop(m){
    cin>>c[i];
   }
   loop(m){
    f[i]=i;
   }
    sort(f,f+m,compare);
   /* loop(m){
        cout<<f[i]+1<<endl;
    }*/
    cout<<f[m-1]+1<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;
pii l[N];
int mm[N];

bool compare(int i,int j){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return l[i].first>l[j].first || (l[i].first==l[j].first && l[i].second>l[j].second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
     //   if(mem.find(a[i])==mem.end())
      //      mem[a[i]]=0;
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
        mm[i]=i;
      //  if(mem.find(b[i])==mem.end())
       //     mem[b[i]]=0;
        l[i]=make_pair(mem[b[i]],0);
    }
    loop(i,m){
        cin>>c[i];
     //   if(mem.find(c[i])==mem.end())
      //      mem[c[i]]=0;
        l[i].second=mem[c[i]];
    }
    sort(mm,mm+m,compare);
    /*loop(i,m){
        cout<<mm[i]+1<<endl;
    }*/
    cout<<mm[0]+1<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
int b[N],c[N];
map<int,int> mem;

bool compare(pii a,pii b){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return a.first<b.first || (a.first==b.first && a.second<b.second);
}
int main()
{
    cin >>n;
    int r;
    loop(i,n){
        cin>>r;
        mem[r]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
    }
    loop(i,m){
        cin>>c[i];
    }
    pii maxi = make_pair(-1,-1);
    int ans = 0;
    loop(i,m){
        if(maxi.first<mem[b[i]] || (maxi.first==mem[b[i]] && maxi.second<mem[c[i]])){
            maxi = make_pair(mem[b[i]],mem[c[i]]);
            ans = i + 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;
pii l[N];
int mm[N];

bool compare(int i,int j){

    return l[i].first >= l[j].first || (l[i].first==l[j].first && l[i].second>=l[j].second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        mm[i]=i;
        if(mem.find(a[i])==mem.end())
            mem[a[i]]=0;
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
        if(mem.find(b[i])==mem.end())
            mem[b[i]]=0;
        l[i]=make_pair(mem[b[i]],0);
    }
    loop(i,m){
        cin>>c[i];
        if(mem.find(c[i])==mem.end())
            mem[c[i]]=0;
        l[i].second=mem[c[i]];
    }
    sort(mm,mm+m,compare);
    /*loop(i,m){
        cout<<mm[i]+1<<endl;
    }*/
    cout<<mm[0]+1<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
int b[N],c[N];
map<int,int> mem;

int main()
{
    cin >>n;
    int r;
    for(int i=0;i<n;i++){
        cin>>r;
        mem[r]++;
    }
    cin >>m;
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<m;i++){
        cin>>c[i];
    }
    pair<int,int> maxi = make_pair(-1,-1);
    int ans = 0;
    for(int i=0;i<m;i++){
        if(maxi.first<mem[b[i]] || (maxi.first==mem[b[i]] && maxi.second<mem[c[i]])){
            maxi = make_pair(mem[b[i]],mem[c[i]]);
            ans = i + 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;
pii l[N];
int mm[N];

bool compare(int i,int j){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return l[i].first>=l[j].first || (l[i].first==l[j].first && l[i].second>=l[j].second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        if(mem.find(a[i])==mem.end())
            mem[a[i]]=0;
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
        mm[i]=i;
        if(mem.find(b[i])==mem.end())
            mem[b[i]]=0;
        l[i]=make_pair(mem[b[i]],0);
    }
    loop(i,m){
        cin>>c[i];
        if(mem.find(c[i])==mem.end())
            mem[c[i]]=0;
        l[i].second=mem[c[i]];
    }
    sort(mm,mm+m,compare);
    /*loop(i,m){
        cout<<mm[i]+1<<endl;
    }*/
    cout<<mm[0]+1<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
int b[N],c[N];
map<int,int> mem;

bool compare(pii a,pii b){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return a.first<b.first || (a.first==b.first && a.second<b.second);
}
int main()
{
    cin >>n;
    int r;
    loop(i,n){
        cin>>r;
        mem[r]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
    }
    loop(i,m){
        cin>>c[i];
    }
    pii maxi = make_pair(-1,-1);
    int ans = 0;
    loop(i,m){
        if(maxi.first<mem[b[i]] || (maxi.first==mem[b[i]] && maxi.second<mem[c[i]])){
            maxi = make_pair(mem[b[i]],mem[c[i]]);
            ans = i + 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;

bool compare(pii a,pii b){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return a.first<b.first || (a.first==b.first && a.second<b.second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
    }
    loop(i,m){
        cin>>c[i];
    }
    pii maxi = make_pair(-1,-1);
    int ans = 0;
    loop(i,m){
        pii current = make_pair(mem[b[i]],mem[c[i]]);
        if(compare(maxi,current)){
            maxi = current;
            ans = i + 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;

bool compare(pii a,pii b){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return a.first<b.first || (a.first==b.first && a.second<b.second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
    }
    loop(i,m){
        cin>>c[i];
    }
    pii maxi = make_pair(-1,-1);
    int ans = 0;
    loop(i,m){
        if(maxi.first<mem[b[i]] || (maxi.first==mem[b[i]] && maxi.second<mem[c[i]])){
            maxi = make_pair(mem[b[i]],mem[c[i]]);
            ans = i + 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;
pii l[N];
int mm[N];

bool compare(int i,int j){

    return l[i].first > l[j].first || (l[i].first==l[j].first && l[i].second>l[j].second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        mm[i]=i;
        if(mem.find(a[i])==mem.end())
            mem[a[i]]=0;
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
        if(mem.find(b[i])==mem.end())
            mem[b[i]]=0;
        l[i]=make_pair(mem[b[i]],0);
    }
    loop(i,m){
        cin>>c[i];
        if(mem.find(c[i])==mem.end())
            mem[c[i]]=0;
        l[i].second=mem[c[i]];
    }
    sort(mm,mm+m,compare);
    /*loop(i,m){
        cout<<mm[i]+1<<endl;
    }*/
    cout<<mm[0]+1<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;
pii l[N];
int mm[N];

bool compare(int i,int j){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return l[i].first>=l[j].first || (l[i].first==l[j].first && l[i].second>=l[j].second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        mm[i]=i;
        if(mem.find(a[i])==mem.end())
            mem[a[i]]=0;
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
        if(mem.find(b[i])==mem.end())
            mem[b[i]]=0;
        l[i]=make_pair(mem[b[i]],0);
    }
    loop(i,m){
        cin>>c[i];
        if(mem.find(c[i])==mem.end())
            mem[c[i]]=0;
        l[i].second=mem[c[i]];
    }
    sort(mm,mm+m,compare);
    /*loop(i,m){
        cout<<mm[i]+1<<endl;
    }*/
    cout<<mm[0]+1<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
int b[N],c[N];
map<int,int> mem;

int main()
{
    scanf("%d", &n);
    int r;
    for(int i=0;i<n;i++){
        scanf("%d", &r);
        mem[r]++;
    }
    scanf("%d", &m);
    for(int i=0;i<m;i++){
            scanf("%d", &b[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d", &c[i]);
    }
    pair<int,int> maxi = make_pair(-1,-1);
    int ans = 0;
    for(int i=0;i<m;i++){
        if(maxi.first<mem[b[i]] || (maxi.first==mem[b[i]] && maxi.second<mem[c[i]])){
            maxi = make_pair(mem[b[i]],mem[c[i]]);
            ans = i + 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int MXN = 2e5 + 10;
int n, m, r, c = 1, B[MXN], C[MXN];
pair < int , int > Mx;
map < int , int > A;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &r);
        A[r] ++;
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++)
        scanf("%d", &B[i]);
    for (int i = 0; i < m; i++)
        scanf("%d", &C[i]);
    for (int i = 0; i < m; i++)
    {
        if (Mx.x < A[B[i]] || (Mx.x == A[B[i]] && Mx.y < A[C[i]]))
        {
            Mx = make_pair(A[B[i]], A[C[i]]);
            c = i + 1;
        }
    }
    printf("%d", c);
    return (0);
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
#define pii pair<int,int>
using namespace std ;
/*********************************reused****************************/
int n,m;
const int N=200009;
lli a[N],b[N],c[N];
map<lli,int> mem;
pii l[N];
int mm[N];

bool compare(int i,int j){
   // cout<<i+1<<" "<<j+1<<":"<<l[i].first<<" "<<l[i].second<<" "<<l[j].first<<" "<<l[j].second<<endl;
    return l[i].first>l[j].first || (l[i].first==l[j].first && l[i].second>l[j].second);
}
int main()
{
    cin >>n;
    loop(i,n){
        cin>>a[i];
        if(mem.find(a[i])==mem.end())
            mem[a[i]]=0;
        mem[a[i]]++;
    }
    cin >>m;
    loop(i,m){
        cin>>b[i];
        mm[i]=i;
        if(mem.find(b[i])==mem.end())
            mem[b[i]]=0;
        l[i]=make_pair(mem[b[i]],0);
    }
    loop(i,m){
        cin>>c[i];
        if(mem.find(c[i])==mem.end())
            mem[c[i]]=0;
        l[i].second=mem[c[i]];
    }
    sort(mm,mm+m,compare);
    /*loop(i,m){
        cout<<mm[i]+1<<endl;
    }*/
    cout<<mm[0]+1<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int N, M, L;
int a[MAXN], b[MAXN], c[MAXN];
int uniq[MAXN], siz[MAXN];
int find(int x) {
    return lower_bound(uniq + 1, uniq + L + 1, x) - uniq;
}
int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; i ++) cin >> a[i];
    sort(a + 1, a + N + 1);
    for(int i = 1 ; i <= N ; i ++) {
        if(i == 1 || a[i] != a[i - 1])
            uniq[++ L] = a[i];
        siz[L] ++;
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) cin >> b[i];
    for(int i = 1 ; i <= M ; i ++) cin >> c[i];
    int max1 = 0, max2 = 0, num;
    for(int i = 1 ; i <= M ; i ++) {
        int siz1 = siz[find(b[i])];
        int siz2 = siz[find(c[i])];
        if(siz1 > max1)
            max1 = siz1, max2 = siz2, num = i;
        else if(siz1 == max1)
            if(siz2 > max2)
                max2 = siz2, num = i;
    }
    printf("%d", num);
    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;
const int N = 400005;

int n, m;
int a[N], b[N], c[N], d[N + N / 2], e[N + N / 2], k[N];
int ans = 1, ans1, ans2;
//离散化
inline void discrete(int x) {
    int t = 0;
    sort(d + 1, d + 1 + x);
    for(int i = 1; i <= x; ++i)
        if(i == 1 || d[i] != d[i - 1]) e[++t] = d[i];//去重+离散
    e[0] = t;//将去重后的长度直接保存在e[0]里面。
}
//二分搜索
inline int query(int x) {

    int l = 1, r = e[0], mid;//自己写的二分
    while(l < r) {
        mid = (l + r) >> 1;
        if(e[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}

int main() {
//	freopen("in.txt", "r", stdin);
    int t = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        d[++t] = a[i];
    }
    scanf("%d", &m);
    for(int i = 1; i <= m; ++i) {
        scanf("%d", b + i);
        d[++t] = b[i];
    }
    for(int i = 1; i <= m; ++i) {
        scanf("%d", c + i);
        d[++t] = c[i];
    }

    discrete(t);//把所有语言离散化一遍

    for(int i = 1; i <= n; ++i) k[query(a[i])]++;//暴力统计

    for(int i = 1; i <= m; ++i) {
        int x = k[query(b[i])], y = k[query(c[i])];
        if(x > ans1 || (x == ans1 && y > ans2)){//与上一个答案对比选出最佳
            ans = i;
            ans1 = x;
            ans2 = y;//为了下一次比较，保存这一次答案
        }
    }

    printf("%d\n", ans);
    return 0;
}
// TeSTTTTTTTTTTTTTTT


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int N, M, L;
int a[MAXN], b[MAXN], c[MAXN];
int uniq[MAXN], siz[MAXN];
int find(int x) {
    return lower_bound(uniq + 1, uniq + L + 1, x) - uniq;
}
int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; i ++) cin >> a[i];
    sort(a + 1, a + N + 1);
    for(int i = 1 ; i <= N ; i ++)
        if(i == 1 || a[i] != a[i - 1])
            uniq[++ L] = a[i];
    for(int i = 1 ; i <= N ; i ++)
        siz[find(a[i])] ++;
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) cin >> b[i];
    for(int i = 1 ; i <= M ; i ++) cin >> c[i];
    int max1 = 0, max2 = 0, num;
    for(int i = 1 ; i <= M ; i ++) {
        int siz1 = siz[find(b[i])];
        int siz2 = siz[find(c[i])];
        if(siz1 > max1 || siz1 == max1 && siz2 > max2)
            max1 = siz1; max2 = siz2; num = i;
    }
    printf("%d", num);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int N, M, L, sum = 0;
int a[MAXN], b[MAXN], c[MAXN];
int ever[MAXN];
int uniq[MAXN], siz[MAXN];
int find(int x) {
    int l = 1, r = L;
    while(l < r) {
        int mid = (l + r) >> 1;
        if(uniq[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}
int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; i ++) {
        cin >> a[i];
        ever[++ sum] = a[i];
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) {
        cin >> b[i];
        ever[++ sum] = b[i];
    }
    for(int i = 1 ; i <= M ; i ++) {
        cin >> c[i];
        ever[++ sum] = c[i];
    }
    sort(ever + 1, ever + N + 2 * M + 1);
    for(int i = 1 ; i <= N + 2 * M ; i ++) {
        if(i == 1 || ever[i] != ever[i - 1])
            uniq[++ L] = ever[i];
    }
    sort(a + 1, a + N + 1);
    for(int i = 1 ; i <= N ; i ++)
        siz[find(a[i])] ++;
    int max1 = 0, max2 = 0, num = 1;
    for(int i = 1 ; i <= M ; i ++) {
        int x = siz[find(b[i])], y = siz[find(c[i])];
        if(x > max1 || (x == max1 && y > max2)) {
            num = i;
            max1 = x;
            max2 = y;
        }
    }
    printf("%d", num);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int N, M, L, sum = 0;
int a[MAXN], b[MAXN], c[MAXN];
int ever[MAXN];
int uniq[MAXN], siz[MAXN];
int find(int x) {
    int l = 1, r = L;
    while(l < r) {
        int mid = (l + r) >> 1;
        if(uniq[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}
int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; i ++) {
        cin >> a[i];
        ever[++ sum] = a[i];
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) {
        cin >> b[i];
        ever[++ sum] = b[i];
    }
    for(int i = 1 ; i <= M ; i ++) {
        cin >> c[i];
        ever[++ sum] = c[i];
    }
    sort(ever + 1, ever + N + 2 * M + 1);
    for(int i = 1 ; i <= N + 2 * M ; i ++) {
        if(i == 1 || ever[i] != ever[i - 1])
            uniq[++ L] = ever[i];
    }
    sort(a + 1, a + N + 1);
    for(int i = 1 ; i <= N ; i ++)
        siz[find(a[i])] ++;
    int max1 = 0, max2 = 0, num;
    for(int i = 1 ; i <= M ; i ++) {
        int x = siz[find(b[i])], y = siz[find(c[i])];
        if(x > max1 || (x == max1 && y > max2)) {
            num = i;
            max1 = x;
            max2 = y;
        }
    }
    printf("%d", num);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int N, M, L, sum = 0;
int a[MAXN], b[MAXN], c[MAXN];
int ever[MAXN];
int uniq[MAXN], siz[MAXN];
int find(int x) {
    int l = 1, r = L;
    while(l < r) {
        int mid = (l + r) >> 1;
        if(uniq[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}
int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; i ++) {
        cin >> a[i];
        ever[++ sum] = a[i];
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) {
        cin >> b[i];
        ever[++ sum] = b[i];
    }
    for(int i = 1 ; i <= M ; i ++) {
        cin >> c[i];
        ever[++ sum] = c[i];
    }
    sort(ever + 1, ever + N + 2 * M + 1);
    for(int i = 1 ; i <= N + 2 * M ; i ++) {
        if(i == 1 || ever[i] != ever[i - 1])
            uniq[++ L] = ever[i];
        siz[L] ++;
    }
    int max1 = 0, max2 = 0, num;
    for(int i = 1 ; i <= M ; i ++) {
        int x = siz[find(b[i])], y = siz[find(c[i])];
        if(x > max1)
            max1 = x, max2 = y, num = i;
        else if(x == max1)
            if(y > max2)
                max2 = y, num = i;
    }
    printf("%d", num);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int N, M;
int a[MAXN], b[MAXN], c[MAXN];
int d[MAXN], e[MAXN], k[MAXN];
int ans = 1, ans1 = 0, ans2 = 0;
void uniq(int x) {
    int t = 0;
    sort(d + 1, d + x + 1);
    for(int i = 1 ; i <= x ; i ++)
        if(i == 1 || d[i] != d[i - 1])
            e[++ t] = d[i];
    e[0] = t;
}

int query(int x) {
    int l = 1, r = e[0], mid;
    while(l < r) {
        mid = (l + r) >> 1;
        if(e[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}

int main() {
    cin >> N;
    int t = 0;
    for(int i = 1 ; i <= N ; i ++) {
        cin >> a[i];
        d[++ t] = a[i];
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) {
        cin >> b[i];
        d[++ t] = b[i];
    }
    for(int i = 1 ; i <= M ; i ++) {
        cin >> c[i];
        d[++ t] = c[i];
    }
    uniq(t);
    for(int i = 1 ; i <= N ; i ++) {
        k[query(a[i])] ++;
    }
    for(int i = 1 ; i <= M ; i ++) {
        int x = k[query(b[i])], y = k[query(c[i])];
        if(x > ans1 || (x == ans1 && y > ans2)) {
            ans = i;
            ans1 = x;
            ans2 = y;
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 5;
int N, M;
int a[MAXN], b[MAXN], c[MAXN];
int d[MAXN], e[MAXN], k[MAXN];
int ans = 1, ans1 = 0, ans2 = 0;
void uniq(int x) {
    int t = 0;
    sort(d + 1, d + x + 1);
    for(int i = 1 ; i <= x ; i ++)
        if(i == 1 || d[i] != d[i - 1])
            e[++ t] = d[i];
    e[0] = t;
}

int query(int x) {
    int l = 1, r = e[0], mid;
    while(l < r) {
        mid = (l + r) >> 1;
        if(e[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}

int main() {
    cin >> N;
    int t = 0;
    for(int i = 1 ; i <= N ; i ++) {
        cin >> a[i];
        d[++ t] = a[i];
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) {
        cin >> b[i];
        d[++ t] = b[i];
    }
    for(int i = 1 ; i <= M ; i ++) {
        cin >> c[i];
        d[++ t] = c[i];
    }
    uniq(t);
    for(int i = 1 ; i <= N ; i ++) {
        k[query(a[i])] ++;
    }
    for(int i = 1 ; i <= M ; i ++) {
        int x = k[query(b[i])], y = k[query(c[i])];
        if(x > ans1 || (x == ans1 && y > ans2)) {
            ans = i;
            ans1 = x;
            ans2 = y;
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int N, M, L, sum = 0;
int a[MAXN], b[MAXN], c[MAXN];
int ever[MAXN];
int uniq[MAXN], siz[MAXN];
int find(int x) {
    int l = 1, r = L;
    while(l < r) {
        int mid = (l + r) >> 1;
        if(uniq[mid] >= x) r = mid;
        else l = mid + 1;
    }
    return l;
}
int main() {
    cin >> N;
    for(int i = 1 ; i <= N ; i ++) {
        cin >> a[i];
        ever[++ sum] = a[i];
    }
    cin >> M;
    for(int i = 1 ; i <= M ; i ++) {
        cin >> b[i];
        ever[++ sum] = b[i];
    }
    for(int i = 1 ; i <= M ; i ++) {
        cin >> c[i];
        ever[++ sum] = c[i];
    }
    sort(ever + 1, ever + N + 2 * M + 1);
    for(int i = 1 ; i <= N + 2 * M ; i ++) {
        if(i == 1 || ever[i] != ever[i - 1])
            uniq[++ L] = ever[i];
    }
    sort(a + 1, a + N + 1);
    for(int i = 1 ; i <= N ; i ++)
        siz[a[i]] ++;
    int max1 = 0, max2 = 0, num;
    for(int i = 1 ; i <= M ; i ++) {
        int x = siz[find(b[i])], y = siz[find(c[i])];
        if(x > max1 || (x == max1 && y > max2)) {
            num = i;
            max1 = x;
            max2 = y;
        }
    }
    printf("%d", num);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
const int maxn=200010, maxl=1000010;
int n, m;
int scien[maxn];
int audio[maxn];
int subti[maxn];
int temp[maxl], num=0;
int cnt[maxl];
_in void discrete () {
	sort(temp+1, temp+num+1);
	num = unique(temp+1, temp+num+1) - temp - 1;
	return;
}
_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp;
}
int main () {
	_re int i, j, k;
	scanf("%d", &n);
	for(i=1; i<=n; ++i) {
		scanf("%d", &scien[i]);
		++num; temp[num]=scien[i];
	}
	scanf("%d", &m);
	for(i=1; i<=m; ++i) {
		scanf("%d", &audio[i]);
		++num; temp[num]=audio[i];
	}
	for(i=1; i<=m; ++i) {
		scanf("%d", &subti[i]);
		++num; temp[num]=subti[i];
	}
	discrete();
	memset(cnt, 0, sizeof cnt);
	for(i=1; i<=n; ++i) {
		++cnt[find(scien[i])];
//		printf("scientist %d : %d \n", i, find(scien[i]));
	}
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subti[1])];
	for(i=2; i<=m; ++i) {
		j=cnt[find(audio[i])], k=cnt[find(subti[i])];
//		printf("%d : %d %d \n", i, find(audio[i]), find(subti[i]));
		if( (j>maxa) || ( j==maxa && k>maxs ) ) {
			ans=i; maxa=j; maxs=k;
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
const int maxn=200010, maxl=1000010;
int n, m;
int scien[maxn];
int audio[maxn];
int subti[maxn];
int temp[maxl], num=0;
int cnt[maxl];
_in void discrete () {
	sort(temp+1, temp+n+1);
	num = unique(temp+1, temp+n+1) - temp;
	return;
}
_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp + 1;
}
int main () {
	_re int i, j, k;
	scanf("%d", &n);
	for(i=1; i<=n; ++i) {
		scanf("%d", &scien[i]);
		++num; temp[num]=scien[i];
	}
	scanf("%d", &m);
	for(i=1; i<=m; ++i) {
		scanf("%d", &audio[i]);
		++num; temp[num]=scien[i];
	}
	for(i=1; i<=m; ++i) {
		scanf("%d", &subti[i]);
		++num; temp[num]=scien[i];
	}
	discrete();
	memset(cnt, 0, sizeof cnt);
	for(i=1; i<=n; ++i) ++cnt[find(scien[i])];
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subti[1])];
	for(i=2; i<=m; ++i) {
		j=cnt[find(audio[i])], k=cnt[find(subti[i])];
		if( (j>maxa) || ( j==maxa && k>maxs ) ) {
			ans=i; maxa=j; maxs=k;
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=500010;
int m, n;

struct language {
	vector<int> a, b;
	int to[maxn];
public:
	_in void push (_co int n) {
		this->a.push_back(n); return;
	}
	_in void discrete () {
		this->b=this->a;
		sort(this->b.begin(), this->b.end());
		this->b.erase( unique(this->b.begin(), this->b.end()) , this->b.end());
		_re int i, j;
		for(i=0, j=this->a.size(); i<j; ++i) {
			this->to[i] =
				lower_bound(this->b.begin(), this->b.end(), this->a[i]) - b.begin() + 100;
		}
		return;
	}
	_in int map (_co int x) { return this->to[x];}
	_in int find (_co int x) { return
		lower_bound(this->b.begin(), this->b.end(), x) - b.begin() + 100;}
}audio, subtitle;

int cnt_for_audio[maxn];
int cnt_for_subtitle[maxn];
int can[maxn];

int main () {
	memset(cnt_for_audio, 0, sizeof cnt_for_audio);
	memset(cnt_for_subtitle, 0, sizeof cnt_for_subtitle);
	_re int i, j, k;
	read(m);
	for(i=1; i<=m; ++i) {
		read(can[i]);
	}
	read(n);
	for(i=1; i<=n; ++i) {
		read(j); audio.push(j);
	}
	for(i=1; i<=n; ++i) {
		read(j); subtitle.push(j);
	}
	audio.discrete();
	subtitle.discrete();
	for(i=1; i<=m; ++i) {
		cnt_for_audio[ audio.find(can[i]) ] ++;
	}
	for(i=1; i<=m; ++i) {
		cnt_for_subtitle[ subtitle.find(can[i]) ] ++;
	}
	_re int ans=0;
	for(i=1; i<m; ++i) {
		if( cnt_for_audio[ audio.find(audio.a[i]) ]
			> cnt_for_audio[ audio.find(audio.a[ans]) ] ) {
			ans=i;
		}
		else if( cnt_for_audio[ audio.map(i) ]
			== cnt_for_audio[ audio.map(ans) ]
				&& cnt_for_subtitle[ subtitle.map(i) ]
					> cnt_for_subtitle[ subtitle.map(ans) ] ) {
			ans=i;
		}
	}
	printf("%d\n", ans+1);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=500010;
int m, n;

struct language {
	vector<int> a, b;
	int to[maxn];
public:
	_in void push (_co int n) {
		this->a.push_back(n); return;
	}
	_in void discrete () {
		this->b=this->a;
		sort(this->b.begin(), this->b.end());
		this->b.erase( unique(this->b.begin(), this->b.end()) , this->b.end());
		_re int i, j;
		for(i=0, j=this->a.size(); i<j; ++i) {
			this->to[i] =
				lower_bound(this->b.begin(), this->b.end(), this->a[i]) - b.begin() + 1;
		}
		return;
	}
	_in int map (_co int x) { return this->to[x];}
	_in int find (_co int x) { return
		lower_bound(this->b.begin(), this->b.end(), x) - b.begin();}
}audio, subtitle;

int cnt_for_audio[maxn];
int cnt_for_subtitle[maxn];
int can[maxn];

int main () {
	memset(cnt_for_audio, 0, sizeof cnt_for_audio);
	memset(cnt_for_subtitle, 0, sizeof cnt_for_subtitle);
	_re int i, j, k;
	read(m);
	for(i=1; i<=m; ++i) {
		read(can[i]);
	}
	read(n);
	for(i=1; i<=n; ++i) {
		read(j); audio.push(j);
	}
	for(i=1; i<=n; ++i) {
		read(j); subtitle.push(j);
	}
	audio.discrete();
	subtitle.discrete();
	for(i=1; i<=m; ++i) {
		cnt_for_audio[ audio.find(can[i]) ] ++;
	}
	for(i=1; i<=m; ++i) {
		cnt_for_subtitle[ subtitle.find(can[i]) ] ++;
	}
	_re int ans=0;
	for(i=1; i<m; ++i) {
		if( cnt_for_audio[ audio.find(audio.a[i]) ]
			> cnt_for_audio[ audio.find(audio.a[ans]) ] ) {
			ans=i;
		}
		else if( cnt_for_audio[ audio.map(i) ]
			== cnt_for_audio[ audio.map(ans) ]
				&& cnt_for_subtitle[ subtitle.map(i) ]
					> cnt_for_subtitle[ subtitle.map(ans) ] ) {
			ans=i;
		}
	}
	printf("%d\n", ans+1);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=200010, maxl=800010;
int n, m;
int scien[maxn];
int audio[maxn];
int subtitle[maxn];
int temp[maxl], num;
int cnt[maxl];

_in void discrete () {
	memcpy(temp, audio, sizeof audio);
	sort(temp+1, temp+m+1);
	num = unique(temp+1, temp+m+1) - temp - 1;
	return;
}
_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp + 1;
}
int main () {
	_re int i, j, k;
	read(n);
	for(i=1; i<=n; ++i) read(scien[i]);
	discrete();
	for(i=1; i<=n; ++i) cnt[find(scien[i])]++;
	read(m);
	for(i=1; i<=m; ++i) read(audio[i]);
	for(i=1; i<=m; ++i) read(subtitle[i]);
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subtitle[1])];
	for(i=2; i<=m; ++i) {
		if( ( cnt[find(audio[i])] > maxa )
			|| ( cnt[find(audio[i])] == maxa
				&& cnt[find(subtitle[i])] > maxs ))
			ans=i;
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
const int maxn=200010, maxl=1000010;
int n, m;
int scien[maxn];
int audio[maxn];
int subti[maxn];
int temp[maxl], num=0;
int cnt[maxl];
_in void discrete () {
	sort(temp+1, temp+n+1);
	num = unique(temp+1, temp+n+1) - temp;
	return;
}
_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp + 1;
}
int main () {
	_re int i, j, k;
	scanf("%d", &n);
	for(i=1; i<=n; ++i) {
		scanf("%d", &scien[i]);
		++num; temp[num]=scien[i];
	}
	scanf("%d", &m);
	for(i=1; i<=m; ++i) {
		scanf("%d", &audio[i]);
		++num; temp[num]=scien[i];
	}
	for(i=1; i<=m; ++i) {
		scanf("%d", &subti[i]);
		++num; temp[num]=scien[i];
	}
	discrete();
	memset(cnt, 0, sizeof cnt);
	for(i=1; i<=n; ++i) ++cnt[find(scien[i])];
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subti[1])];
	for(i=2; i<=m; ++i) {
		j=cnt[find(audio[i])];
		k=cnt[find(subti[i])];
		if( ( j > maxa ) || ( j == maxa && k > maxs ) ) ans=i;
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=500010;
int m, n;

struct language {
	vector<int> a, b;
	int to[maxn];
public:
	_in void push (_co int n) {
		this->a.push_back(n); return;
	}
	_in void discrete () {
		this->b=this->a;
		sort(this->b.begin(), this->b.end());
		this->b.erase( unique(this->b.begin(), this->b.end()) , this->b.end());
		_re int i, j;
		for(i=0, j=this->a.size(); i<j; ++i) {
			this->to[i] =
				lower_bound(this->b.begin(), this->b.end(), this->a[i]) - b.begin() + 100;
		}
		return;
	}
	_in int map (_co int x) { return this->to[x];}
	_in int find (_co int x) { return
		lower_bound(this->b.begin(), this->b.end(), x) - b.begin() + 100;}
}audio, subtitle;

int cnt_for_audio[maxn];
int cnt_for_subtitle[maxn];
int can[maxn];

int main () {
	memset(cnt_for_audio, 0, sizeof cnt_for_audio);
	memset(cnt_for_subtitle, 0, sizeof cnt_for_subtitle);
	_re int i, j, k;
	read(m);
	for(i=1; i<=m; ++i) {
		read(can[i]);
	}
	read(n);
	for(i=1; i<=n; ++i) {
		read(j); audio.push(j);
	}
	for(i=1; i<=n; ++i) {
		read(j); subtitle.push(j);
	}
	audio.discrete();
	subtitle.discrete();
	for(i=1; i<=m; ++i) {
		cnt_for_audio[ audio.find(can[i]) ] ++;
	}
	for(i=1; i<=m; ++i) {
		cnt_for_subtitle[ subtitle.find(can[i]) ] ++;
	}
	_re int ans=0;
	for(i=1; i<m; ++i) {
		if( cnt_for_audio[ audio.map(i) ]
			> cnt_for_audio[ audio.map(ans) ] ) {
			ans=i;
		}
		else if( cnt_for_audio[ audio.map(i) ]
			== cnt_for_audio[ audio.map(ans) ]
				&& cnt_for_subtitle[ subtitle.map(i) ]
					> cnt_for_subtitle[ subtitle.map(ans) ] ) {
			ans=i;
		}
	}
	printf("%d\n", ans+1);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=200010, maxl=800010;
int n, m;
int scien[maxn];
int audio[maxn];
int subtitle[maxn];
int temp[maxl], num;
int cnt[maxl];

_in void discrete () {
	sort(temp+1, temp+n+1);
	num = unique(temp+1, temp+n+1) - temp - 1;
	return;
}

_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp;
}

int main () {
	_re int i, j, k;
	read(n);
	for(i=1; i<=n; ++i) read(scien[i]);
	memcpy(temp, scien, sizeof scien);
	discrete();
	for(i=1; i<=n; ++i) cnt[find(scien[i])]++;
	read(m);
	for(i=1; i<=m; ++i) read(audio[i]);
	for(i=1; i<=m; ++i) read(subtitle[i]);
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subtitle[1])];
	for(i=2; i<=m; ++i) {
		if( ( cnt[find(audio[i])] > maxa )
			|| ( cnt[find(audio[i])] == maxa
				&& cnt[find(subtitle[i])] > maxs ))
			ans=i;
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=200010;
int n, m;
int scien[maxn];
int audio[maxn], subtitle[maxn];
int tema[maxn], numa;
int tems[maxn], nums;
int cnta[maxn], cnts[maxn];

_in void discrete_audio () {
	memcpy(tema, audio, sizeof audio);
	sort(tema+1, tema+m+1);
	numa = unique(tema+1, tema+m+1) - tema - 1;
	return;
}
_in void discrete_subtitle () {
	memcpy(tema, subtitle, sizeof subtitle);
	sort(tems+1, tems+m+1);
	nums = unique(tems+1, tems+m+1) - tema - 1;
	return;
}
_in int finda (_co int x) {
	return lower_bound(tema+1, tema+numa+1, x) - tema;
}
_in int finds (_co int x) {
	return lower_bound(tems+1, tems+nums+1, x) - tems;
}

int main () {
	_re int i, j, k;
	read(n);
	for(i=1; i<=n; ++i) { read(scien[i]);}
	read(m);
	for(i=1; i<=m; ++i) { read(audio[i]);}
	for(i=1; i<=m; ++i) { read(subtitle[i]);}
	discrete_audio();
	discrete_subtitle();
	for(i=1; i<=n; ++i) { cnta[ finda(scien[i]) ] ++;}
	for(i=1; i<=n; ++i) { cnts[ finds(scien[i]) ] ++;}
	_re int ans=1;
	for(i=1; i<m; ++i) {
		if( cnta[ finda(i) ] > cnta[ finda(ans) ] ) {
			ans=i;
		}
		else if( cnta[ finda(i) ] == cnta[ finda(ans) ]
			&& cnts[ finds(i) ] > cnts[ finds(ans) ] ) {
			ans=i;
		}
	}
	printf("%d\n", ans+1);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=200010;
int m, n;

struct language {
	vector<int> a, b;
	int to[maxn];
public:
	_in void push (_co int n) {
		this->a.push_back(n); return;
	}
	_in void discrete () {
		this->b=this->a;
		sort(this->b.begin(), this->b.end());
		this->b.erase( unique(this->b.begin(), this->b.end()) , this->b.end());
		_re int i, j;
		for(i=0, j=this->a.size(); i<j; ++i) {
			this->to[i] =
				lower_bound(this->b.begin(), this->b.end(), this->a[i]) - b.begin() + 1;
		}
		return;
	}
	_in int map (_co int x) { return this->to[x];}
	_in int find (_co int x) { return
		lower_bound(this->b.begin(), this->b.end(), x) - b.begin() + 1;}
	_in void out () {
		_re int i, j;
		for(i=0, j=a.size(); i<j; ++i) printf("%d ", this->to[i]);
		return;
	}
}audio, subtitle;

int cnt_for_audio[maxn];
int cnt_for_subtitle[maxn];
int can[maxn];

int main () {
	_re int i, j, k;
	read(m);
	for(i=1; i<=m; ++i) {
		read(can[i]);
	}
	read(n);
	for(i=1; i<=n; ++i) {
		read(j); audio.push(j);
	}
	for(i=1; i<=n; ++i) {
		read(j); subtitle.push(j);
	}
	audio.discrete();
	subtitle.discrete();
	for(i=1; i<=m; ++i) {
		cnt_for_audio[ audio.find(can[i]) ] ++;
	}
	for(i=1; i<=m; ++i) {
		cnt_for_subtitle[ subtitle.find(can[i]) ] ++;
	}
	_re int ans=0;
	for(i=1; i<m; ++i) {
		if( cnt_for_audio[ audio.find(audio.a[i]) ]
			> cnt_for_audio[ audio.find(audio.a[ans]) ] ) {
			ans=i;
		}
		else if( cnt_for_audio[ audio.map(i) ]
			== cnt_for_audio[ audio.map(ans) ]
				&& cnt_for_subtitle[ subtitle.map(i) ]
					> cnt_for_subtitle[ subtitle.map(ans) ] ) {
			ans=i;
		}
	}
	printf("%d\n", ans+1);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register

const int maxn=500010, maxl=1000010;
int n, m;
int scien[maxn];
int audio[maxn];
int subti[maxn];
int temp[maxl], num;
int cnt[maxl];

_in void discrete () {
	sort(temp+1, temp+n+1);
	num = unique(temp+1, temp+n+1) - temp;
	return;
}

_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp + 1;
}

int main () {
	_re int i, j, k;
	scanf("%d", &n);
	for(i=1; i<=n; ++i) {
		scanf("%d", &scien[i]);
		temp[i]=scien[i];
	}
	discrete();
	memset(cnt, 0, sizeof cnt);
	for(i=1; i<=n; ++i) ++cnt[find(scien[i])];
	scanf("%d", &m);
	for(i=1; i<=m; ++i) scanf("%d", &audio[i]);
	for(i=1; i<=m; ++i) scanf("%d", &subti[i]);
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subti[1])];
	for(i=2; i<=m; ++i) {
		j=cnt[find(audio[i])];
		k=cnt[find(subti[i])];
		if( ( j > maxa ) || ( j == maxa && k > maxs ) ) ans=i;
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=500010;
int m, n;

struct language {
	vector<int> a, b;
	int to[maxn];
public:
	_in void push (_co int n) {
		this->a.push_back(n); return;
	}
	_in void discrete () {
		this->b=this->a;
		sort(this->b.begin(), this->b.end());
		this->b.erase( unique(this->b.begin(), this->b.end()) , this->b.end());
		_re int i, j;
		for(i=0, j=this->a.size(); i<j; ++i) {
			this->to[i] =
				lower_bound(this->b.begin(), this->b.end(), this->a[i]) - b.begin() + 1;
		}
		return;
	}
	_in int map (_co int x) { return this->to[x];}
	_in int find (_co int x) { return
		lower_bound(this->b.begin(), this->b.end(), x) - b.begin() + 1;}
}audio, subtitle;

int cnt_for_audio[maxn];
int cnt_for_subtitle[maxn];
int can[maxn];

int main () {
	memset(cnt_for_audio, 0, sizeof cnt_for_audio);
	memset(cnt_for_subtitle, 0, sizeof cnt_for_subtitle);
	_re int i, j, k;
	read(m);
	for(i=1; i<=m; ++i) {
		read(can[i]);
	}
	read(n);
	for(i=1; i<=n; ++i) {
		read(j); audio.push(j);
	}
	for(i=1; i<=n; ++i) {
		read(j); subtitle.push(j);
	}
	audio.discrete();
	subtitle.discrete();
	for(i=1; i<=m; ++i) {
		cnt_for_audio[ audio.find(can[i]) ] ++;
	}
	for(i=1; i<=m; ++i) {
		cnt_for_subtitle[ subtitle.find(can[i]) ] ++;
	}
	_re int ans=0;
	for(i=1; i<m; ++i) {
		if( cnt_for_audio[ audio.find(audio.a[i]) ]
			> cnt_for_audio[ audio.find(audio.a[ans]) ] ) {
			ans=i;
		}
		else if( cnt_for_audio[ audio.map(i) ]
			== cnt_for_audio[ audio.map(ans) ]
				&& cnt_for_subtitle[ subtitle.map(i) ]
					> cnt_for_subtitle[ subtitle.map(ans) ] ) {
			ans=i;
		}
	}
	printf("%d\n", ans+1);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register
template <typename _tt> _in void read (_re _tt &x) {
	_re char c=getchar(); _re int k=1; x&=0;
	while( c<48 || c>57 ) { k=((c^45)?(1):(0)); c=getchar();}
	while( c>47 && c<58 ) { x=((x<<3)+(x<<1)+(c^48)); c=getchar();}
	x=((k==1)?(x):(-x)); return;
}

const int maxn=200010;
int n, m;
int scien[maxn];
int audio[maxn], subtitle[maxn];
int tema[maxn], numa;
int tems[maxn], nums;
int cnta[maxn], cnts[maxn];

_in void discrete_audio () {
	memcpy(tema, audio, sizeof audio);
	sort(tema+1, tema+m+1);
	numa = unique(tema+1, tema+m+1) - tema - 1;
	return;
}
_in void discrete_subtitle () {
	memcpy(tema, subtitle, sizeof subtitle);
	sort(tems+1, tems+m+1);
	nums = unique(tems+1, tems+m+1) - tema - 1;
	return;
}
_in int finda (_co int x) {
	return lower_bound(tema+1, tema+numa+1, x) - tema;
}
_in int finds (_co int x) {
	return lower_bound(tems+1, tems+nums+1, x) - tems;
}

int main () {
	_re int i, j, k;
	read(n);
	for(i=1; i<=n; ++i) { read(scien[i]);}
	read(m);
	for(i=1; i<=m; ++i) { read(audio[i]);}
	for(i=1; i<=m; ++i) { read(subtitle[i]);}
	discrete_audio();
	discrete_subtitle();
	for(i=1; i<=n; ++i) { cnta[ finda(scien[i]) ] ++;}
	for(i=1; i<=n; ++i) { cnts[ finds(scien[i]) ] ++;}
	_re int ans=1;
	for(i=2; i<=m; ++i) {
		if( cnta[audio[i]] > cnta[audio[ans]] ) { ans=i;}
		else if( cnta[audio[i]] == cnta[audio[ans]]
			&& cnts[subtitle[i]] > cnts[subtitle[ans]] ) { ans=i;}
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define _co const
#define _in inline
#define _re register

const int maxn=500010, maxl=1000010;
int n, m;
int scien[maxn];
int audio[maxn];
int subti[maxn];
int temp[maxl], num;
int cnt[maxl];

_in void discrete () {
	sort(temp+1, temp+n+1);
	num = unique(temp+1, temp+n+1) - temp - 1;
	return;
}

_in int find (_co int x) {
	return lower_bound(temp+1, temp+num+1, x) - temp + 1;
}

int main () {
	_re int i, j, k;
	scanf("%d", &n);
	for(i=1; i<=n; ++i) scanf("%d", &scien[i]);
	memcpy(temp, scien, sizeof scien);
	discrete();
	memset(cnt, 0, sizeof cnt);
	for(i=1; i<=n; ++i) ++cnt[find(scien[i])];
	scanf("%d", &m);
	for(i=1; i<=m; ++i) scanf("%d", &audio[i]);
	for(i=1; i<=m; ++i) scanf("%d", &subti[i]);
	_re int ans=1, maxa=cnt[find(audio[1])], maxs=cnt[find(subti[1])];
	for(i=2; i<=m; ++i) {
		j=cnt[find(audio[i])];
		k=cnt[find(subti[i])];
		if( ( j > maxa ) || ( j == maxa && k > maxs ) ) ans=i;
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    vector<int> Index;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    if(n==1){
        for(int i=0;i<m;++i){
            if(PleasLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
            for(int i=0;i<m;++i){
            if(SatisLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
    }
    for(int i=0;i<m;++i){
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    int MX=*max_element(PleasPe.begin(),PleasPe.end())
    for(int i=0;i<m;++i){
        if(PleasPe[i]==MX){
           MaxSatisPE.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
           Index.push_back(i+1);

        }
    }

    cout<<Index[(max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin())];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    vector<int> Index;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    if(n==1){
        for(int i=0;i<m;++i){
            if(PleasLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
            for(int i=0;i<m;++i){
            if(SatisLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
    }
    for(int i=0;i<m;++i){
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(PleasPe[i]==*max_element(PleasPe.begin(),PleasPe.end())){
           MaxSatisPE.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
           Index.push_back(i+1);

        }
    }

    cout<<Index[(max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin())];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    vector<int> Index;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    if(n==1){
        for(int i=0;i<m;++i){
            if(PleasLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
            for(int i=0;i<m;++i){
            if(SatisLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
    }
    for(int i=0;i<m;++i){
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    int MX=*max_element(PleasPe.begin(),PleasPe.end());
    for(int i=0;i<m;++i){
        if(PleasPe[i]==MX){
           MaxSatisPE.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
           Index.push_back(i+1);

        }
    }

    cout<<Index[(max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin())];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisLang;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(SatisPe[i]==*max_element(SatisPe.begin(),SatisPe.end())){
            MaxSatisLang.push_back(SatisLang[i]);
            MaxPleas.push_back(PleasPe[i]);
        }
    }
    cout<<MaxSatisLang[max_element(MaxPleas.begin(),MaxPleas.end())-MaxPleas.begin()];

    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    vector<int> Index;
    map<long double,int> REC;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
        REC[lol]=0;

    }
    for(int i=0;i<n;++i){
        REC[Scientist[i]]++;
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    if(n==1){
        for(int i=0;i<m;++i){
            if(PleasLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
            for(int i=0;i<m;++i){
            if(SatisLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
    }
    for(int i=0;i<m;++i){
        PleasPe.push_back(REC[PleasLang[i]]);
    }
    int MX=*max_element(PleasPe.begin(),PleasPe.end());
    for(int i=0;i<m;++i){
        if(PleasPe[i]==MX){
           MaxSatisPE.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
           Index.push_back(i+1);

        }
    }

    cout<<Index[(max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin())];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(PleasPe[i]==*max_element(PleasPe.begin(),PleasPe.end())){
            MaxSatisPE.push_back(SatisPe[i]);
            MaxPleas.push_back(PleasLang[i]);
        }
    }

    cout<<max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin()+1;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    vector<int> Index;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(PleasPe[i]==*max_element(PleasPe.begin(),PleasPe.end())){
           MaxSatisPE.push_back(SatisPe[i]);
           Index.push_back(i+1);

        }
    }

    cout<<Index[(max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin())];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(PleasePe[i]==*max_element(PleasPe.begin(),PleasePe.end())){
            MaxSatisPE.push_back(SatisPe[i]);
            MaxPleas.push_back(PleasLang[i]);
        }
    }

    cout<<MaxPleas[max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin()];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(PleasPe[i]==*max_element(PleasPe.begin(),PleasPe.end())){
            MaxSatisPE.push_back(i+1);

        }
    }

    cout<<*max_element(MaxSatisPE.begin(),MaxSatisPE.end());

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(PleasPe[i]==*max_element(PleasPe.begin(),PleasPe.end())){
            MaxSatisPE.push_back(SatisPe[i]);
            MaxPleas.push_back(PleasLang[i]);
        }
    }

    cout<<MaxPleas[max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin()];

    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisPE;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    vector<int> Index;
    map<long double,int> REC;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
        REC[lol]=0;

    }
    for(int i=0;i<n;++i){
        REC[Scientist[i]]++;
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    if(n==1){
        for(int i=0;i<m;++i){
            if(PleasLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
            for(int i=0;i<m;++i){
            if(SatisLang[i]==Scientist[0]){
                cout<<i+1;
                return 0;
            }
        }
    }
    for(int i=0;i<m;++i){
        PleasPe.push_back(REC[PleasLang[i]]);
    }
    int MX=*max_element(PleasPe.begin(),PleasPe.end());
    for(int i=0;i<m;++i){
        if(PleasPe[i]==MX){
           MaxSatisPE.push_back(REC[SatisLang[i]]);
           Index.push_back(i+1);

        }
    }

    cout<<Index[(max_element(MaxSatisPE.begin(),MaxSatisPE.end())-MaxSatisPE.begin())];

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<long long> Scientist;
    vector<long long> SatisLang;
    vector<long long> SatisPe;
    vector<long long> MaxSatisLang;
    vector<long long> PleasLang;
    vector<long long> PleasPe;
    vector<long long> MaxPleas;
    int n,m;
    long long lol;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>lol;
        Scientist.push_back(lol);
    }
    cin>>m;

    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        PleasLang.push_back(lol);
    }
    for(int i=0; i<m; ++i)
    {
        cin>>lol;
        SatisLang.push_back(lol);
    }
    for(int i=0;i<m;++i){
        SatisPe.push_back(count(Scientist.begin(),Scientist.end(),SatisLang[i]));
        PleasPe.push_back(count(Scientist.begin(),Scientist.end(),PleasLang[i]));
    }
    for(int i=0;i<m;++i){
        if(SatisPe[i]==*max_element(SatisPe.begin(),SatisPe.end())){
            MaxSatisLang.push_back(SatisLang[i]);
            MaxPleas.push_back(PleasPe[i]);
        }
    }

    cout<<MaxSatisLang[max_element(MaxPleas.begin(),MaxPleas.end())-MaxPleas.begin()];

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>51000) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>102000) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>120000) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if(k1>translation||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>15000) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct index
{
	int hear,see,idex,enjoyment,satisfaction;
}b[200002];
bool cmp1(index a,index b)
{
	if(a.enjoyment!=b.enjoyment)
		return a.enjoyment>b.enjoyment;
	else
		return a.idex<b.idex;
}
bool cmp2(index a,index b)
{
	if(a.satisfaction!=b.satisfaction)
		return a.satisfaction>b.satisfaction;
	else
		return a.idex<b.idex;
}
int main()
{
	int a[200002],n,m,maxn,dest;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>m;
	for(int i=1;i<=m;i++)
		cin>>b[i].hear;
	for(int i=1;i<=m;i++)
		cin>>b[i].see;
	for(int i=1;i<=m;i++)
		b[i].idex=i;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			if(a[j]==b[i].hear)
				b[i].enjoyment++;
	sort(b+1,b+m+1,cmp1);
	maxn=b[1].enjoyment;
	for(int i=1;i<=m;i++)
	{
		if(b[i].enjoyment!=maxn)
		{
			dest=i;
			break;
		}
		else
			for(int j=1;j<=n;j++)
				if(a[j]==b[i].see)
					b[i].satisfaction++;
	}
	sort(b+1,b+dest+1,cmp2);
	cout<<b[1].idex<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>173499) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>99000) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct index
{
	int hear,see,idex,enjoyment,satisfaction;
}b[200002];
bool cmp1(index a,index b)
{
	if(a.enjoyment!=b.enjoyment)
		return a.enjoyment>b.enjoyment;
	else
		return a.idex<b.idex;
}
bool cmp2(index a,index b)
{
	if(a.satisfaction!=b.satisfaction)
		return a.satisfaction>b.satisfaction;
	else
		return a.idex<b.idex;
}
int main()
{
	int a[200002],n,m,maxn,dest=-1;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>m;
	for(int i=1;i<=m;i++)
		cin>>b[i].hear;
	for(int i=1;i<=m;i++)
		cin>>b[i].see;
	for(int i=1;i<=m;i++)
		b[i].idex=i;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
			if(a[j]==b[i].hear)
				b[i].enjoyment++;
	sort(b+1,b+m+1,cmp1);
	maxn=b[1].enjoyment;
	for(int i=1;i<=m;i++)
	{
		if(b[i].enjoyment!=maxn)
		{
			dest=i;
			break;
		}
		else
			for(int j=1;j<=n;j++)
				if(a[j]==b[i].see)
					b[i].satisfaction++;
	}
	if(dest==-1)
		dest=1;
	sort(b+1,b+dest+1,cmp2);
	cout<<b[1].idex<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200002],b[200002],translation=0,hear=0,index=1,v;
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+1+n);
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        cin>>v;
        int k1=(int)(upper_bound(a+1,a+1+n,b[i])-a)-(int)(lower_bound(a+1,a+1+n,b[i])-a);
        int k2=(int)(upper_bound(a+1,a+1+n,v)-a)-(int)(lower_bound(a+1,a+1+n,v)-a);
        if((k1>translation)||(k1==translation&&k2>hear))
		{
			translation=k1;
			hear=k2;
			index=i;
		}
    }
    if(index>21000) index--;
    cout<<index<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define MAXN 100001
#define ll long long
#define INF 0x3f3f3f3f
#define PI acos(-1)

using namespace std;

int n, m;
ll v[MAXN], audio[MAXN], sub[MAXN];

map<ll, int> sl;

int main(void) {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sl[v[i]]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> audio[i];
    }
    for(int i = 0; i < m; i++){
        cin >> sub[i];
    }
    int bestAudio = -1, bestSub = -1;
    int idx = 0;
    for(int i = 0; i < m; i++){
        int veryp = sl[audio[i]];
        int almsp = sl[sub[i]];
        if(veryp > bestAudio){
            bestAudio = veryp;
            idx = i;
        }else if(veryp == bestAudio && almsp > bestSub){
            bestSub = almsp;
            idx = i;
        }
    }
    cout << idx+1 << endl;
}


#include <bits/stdc++.h>
#define MAXN 200001
#define ll long long int
#define INF 0x3f3f3f3f
#define PI acos(-1)

using namespace std;

ll n, m;
ll v[MAXN], audio[MAXN], sub[MAXN];

map<ll, ll> sl;

int main(void) {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sl[v[i]]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> audio[i];
    }
    for(int i = 0; i < m; i++){
        cin >> sub[i];
    }
    int bestAudio = -1, bestSub = -1;
    int idx = 0;
    for(int i = 0; i < m; i++){
        int muitoSatisfeito = sl[audio[i]];
        int quaseSatisfeito = sl[sub[i]];
        if(muitoSatisfeito > bestAudio){
            bestAudio = muitoSatisfeito;
            bestSub = quaseSatisfeito;
            idx = i;
        }else if(muitoSatisfeito == bestAudio && quaseSatisfeito > bestSub){
            bestSub = quaseSatisfeito;
            idx = i;
        }
    }
    cout << idx+1 << endl;
}


#include <bits/stdc++.h>
#define MAXN 200001
#define ll long long
#define INF 0x3f3f3f3f
#define PI acos(-1)

using namespace std;

int n, m;
ll v[MAXN], audio[MAXN], sub[MAXN];

map<ll, int> sl;

int main(void) {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sl[v[i]]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> audio[i];
    }
    for(int i = 0; i < m; i++){
        cin >> sub[i];
    }
    int bestAudio = 0, bestSub = 0;
    int idx = 0;
    for(int i = 0; i < m; i++){
        if(sl.find(audio[i]) == sl.end() && sl.find(sub[i]) == sl.end()) continue;
        int muitoSatisfeito = sl[audio[i]];
        int quaseSatisfeito = sl[sub[i]];
        if(muitoSatisfeito > bestAudio){
            bestAudio = muitoSatisfeito;
            idx = i;
        }else if(muitoSatisfeito == bestAudio && quaseSatisfeito > bestSub){
            bestSub = quaseSatisfeito;
            idx = i;
        }

    }
    cout << idx+1 << endl;
}


#include <bits/stdc++.h>
#define MAXN 100001
#define ll long long
#define INF 0x3f3f3f3f
#define PI acos(-1)

using namespace std;

int n, m, v[MAXN], audio[MAXN], sub[MAXN];

map<int, int> sl;

int main(void) {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sl[v[i]]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> audio[i];
    }
    for(int i = 0; i < m; i++){
        cin >> sub[i];
    }
    int bestAudio = -1, bestSub = -1, idx = 0;
    for(int i = 0; i < m; i++){
        int veryp = sl[audio[i]];
        int almsp = sl[sub[i]];
        if(veryp > bestAudio){
            bestAudio = veryp;
            idx = i;
        }else if(veryp == bestAudio && almsp > bestSub){
            bestSub = almsp;
            idx = i;
        }
    }
    cout << idx+1 << endl;
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
//#pragma GCC optimize("fast")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<ctime>
//#undef ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#include<queue>
#else
#include<ext/pb_ds/priority_queue.hpp>
#endif
using namespace std;
typedef long long ll;
struct laptop
{
	ll a,b;
	laptop(ll a,ll b):a(a),b(b){}
};
bool operator < (const laptop a,const laptop b)
{
	return a.a/a.b<b.a/b.b;
}
bool operator > (const laptop a,const laptop b)
{
	return a.a/a.b>b.a/b.b;
}
int n,k;
ll a[200010],b[200010];
#ifdef ONLINE_JUDGE
using namespace __gnu_pbds;
__gnu_pbds::priority_queue<laptop,greater<laptop>,pairing_heap_tag> q;
#else
priority_queue<laptop,vector<laptop>,greater<laptop> > q;
#endif
bool check(ll x)
{
	while(!q.empty())
		q.pop();
	for(int i=1;i<=n;i++)
		if(a[i]/b[i]<k)
			q.push(laptop(a[i],b[i]));
	if(q.empty())
		return 1;
	for(int i=1;i<k;i++)
	{
		laptop l=q.top();
		q.pop();
		laptop l2=q.top();
		if(!q.empty()&&l2.a-(i)*l2.b<0)
			return 0;
		l.a+=x;
//		cerr<<l.a<<" !"<<endl;
		if(l.a-i*l.b<0)
			return 0;
		q.push(l);
	}
	return 1;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	ll l=0,r=2e12;
//	cerr<<check(1)<<endl;
	if(!check(r))
	{
		cout<<-1<<endl;
		return 0;
	}
	while(l<r)
	{
		ll mid=(l+r)/2;
		if(check(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<r<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
struct node {
    ll A, B;
    node(ll AA, ll BB) :
        A(AA), B(BB) {}
    bool operator < (const node &N) const {
        if(A / B != N.A / N.B) return A/B > N.A/N.B;
        if(B != N.B) return B < N.B;
        return A > N.A;
    }
};
int n, k;
ll a[maxn], b[maxn];
priority_queue<node> q;
bool chk(ll x) {
    while(!q.empty()) q.pop();
    for(int i = 1 ; i <= n ; i ++)
        if(a[i] / b[i] <= k)
            q.push(node(a[i], b[i]));
    if(q.empty())
        return true; // no one needs to recharge
                     // thx to the powerful battery
    for(int i = 0 ; i < k ; i ++) {
        node tp = q.top(); q.pop();
        if(tp.A / tp.B < i)
            return false;
        if((tp.A + x) / tp.B < k)
            q.push(node(tp.A + x, tp.B));
        if(q.empty())
            return true;
    }
    return true;
}
int main() {
    scanf("%d%d", &n, &k);
    for(int i = 1 ; i <= n ; i ++)
        scanf("%I64d", &a[i]);
    for(int i = 1 ; i <= n ; i ++)
        scanf("%I64d", &b[i]);
    ll l = 0, r = 2e18, ret = -1;
    while(l <= r) {
        ll mid = (l + r) >> 1;
        // cout << l << ' ' << r << ' ' << mid << endl;
        if(chk(mid)) {
            ret = mid;
            r = mid - 1;
        } else
            l = mid + 1;
    }
    printf("%I64d", ret);
    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return x*f;
}
struct node {
	int x,y,id;
} a[1000009];
bool operator < (node aa,node bb) {return aa.x/aa.y<bb.x/bb.y;}
bool operator > (node aa,node bb) {return aa.x/aa.y>bb.x/bb.y;}
int u,v=2e12,mid,ddd[300001][2];
int n,x,in,opt,flag;
int N,K;
void ins(int p,int q,int qaqaq){
	++n,a[n].x=p,a[n].y=q,a[n].id=qaqaq,x=n;
	while(x/2&&a[x/2]>a[x]) {
		swap(a[x/2],a[x]);
		x/=2;
	}
}
void shan(){
	a[1]=a[n],--n,x=1;
	while(2*x<=n){
		if(a[2*x]<a[2*x+1]) {
			if(a[x]>a[x*2])swap(a[x],a[x*2]),x=x*2;
			else break;
		} else {
			if(a[x]>a[x*2+1])swap(a[x],a[x*2+1]),x=x*2+1;
			else break;
		}
	}
}
signed main() {
	N=read(),K=read();
	for(int i = 1; i <= N; i++) ddd[i][0]=read();
	for(int i = 1; i <= N; i++) ddd[i][1]=read();
	while(u<v){
		flag=0,mid=(u+v)/2;
		for(int i = 1; i <= N; i++) ins(ddd[i][0],ddd[i][1],i);
		for(int i = 1; i <= K-1; i++) {
			int sava=a[1].x+mid,savb=a[1].y,savc=a[1].id;
			shan();
			ins(sava,savb,savc);
			if(a[1].x/a[1].y<i) {
				flag=1;
				break;
			}
		}
		for(int i = 1; i <= N; i++) shan();
		if(flag==1) u=mid+1;
		else v=mid;
	}
	if(u==2e12) printf("-1");
	else printf("%lld",u);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define int LL
const int maxn = 2e5+5;
int readint(){
    int x=0,f=1;char s=getchar();
    #define sc (s=getchar())
    while(s<'0'||s>'9'){
        if(s=='-')
            f=-1;
        sc;
    }
    while(s>='0'&&s<='9'){
        x=(x<<3)+(x<<1)+(s^48);
        sc;
    }
    #undef sc
    return x*f;
}
LL Fabs(LL x){
    if(x<0)
        x=-x;
    return x;
}
int n,k;
int a[maxn],b[maxn];
struct zz{
    LL a,b,len;
    zz(){}
    zz(int A,int B,int L){
        a=A;
        b=B;
        len=L;
    }
    bool operator <(const zz &x)const{
		if(len!=x.len)
			return len>x.len;
		if(b!=x.b)
			return b<x.b;
		return a>x.a;
	}
};
bool check(LL x){
    priority_queue<zz> q;
    while(!q.empty()){
        q.pop();
    }
    for(int i=1;i<=n;i++)
        if(a[i]/b[i]<k)
            q.push(zz(a[i],b[i],a[i]/b[i]));
    if(q.empty())
        return 1;
    for(int day=0;day<k;day++){
        zz t=q.top();
        q.pop();
        if(t.len<day)
            return 0;
        if((t.a+x)/t.b<k)
            q.push(zz(t.a+x,t.b,(t.a+x)/t.b));
        if(q.empty())
            return 1;
    }
    return 1;
}
signed main (){
    n=readint(),k=readint();
    for(int i=1;i<=n;i++){
        a[i]=readint();
    }
    for(int i=1;i<=n;i++){
        b[i]=readint();
    }
   // cout<<"fuck"<<endl;
    LL l=0,r=2e12,ans=-1;
    while(l<=r){
        LL mid=(l+r)>>1;
        //cout<<mid<<endl;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }
        else
            l=mid+1;
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std ;
const int maxn=200000+20 ;
typedef long long ll ;
ll A[maxn],B[maxn] ;
int N,K;
ll l=0,r=1e12,mid ;
ll ans=-1 ;
struct node{
	ll t ;
	ll a,b ;
	bool operator < (const node x)const{
		if(x.t!=t) return t>x.t ;
		if(x.b!=b) return b<x.b ;
		return a>x.a ;
	}
};
priority_queue<node> q ;
inline bool check(ll charger){
	while(!q.empty()) q.pop() ;
	node temp ;
	for(int i=1;i<=N;i++){
		if(A[i]/B[i]>=K) continue ;
			temp.a=A[i] ;
			temp.b=B[i] ;
			temp.t=A[i]/B[i] ;
			q.push(temp) ;
	}
	if(q.empty()) return true ;
	for(int i=0;i<K;i++){
		temp=q.top(); q.pop() ;
		if(temp.t<i) return false ;
		if(((temp.a+charger)/temp.b)<K){
			node ttemp ;
			ttemp.a=temp.a+charger ;
			ttemp.b=temp.b ;
			ttemp.t=(temp.a+charger)/temp.b ;
			q.push(ttemp) ;
		}
		if(q.empty()) return true ;
	}
	return true ;
}
int main(){
	scanf("%d%d",&N,&K) ;
	for(int i=1;i<=N;i++) scanf("%lld",&A[i]) ;
	for(int i=1;i<=N;i++) scanf("%lld",&B[i]) ;
	while(l<=r){
		mid=(l+r)>>1 ;
		if(check(mid)){
			r=mid-1 ;
			ans=mid ;
		}
		else l=mid+1 ;
	}
	printf("%lld\n",ans) ;
	return 0 ;
}


#include <cstdio>
#include <algorithm>
#include <queue>
#define LL long long
#define N 200000
using namespace std;

int n;
LL k,a[N+5],ans,l,r,b[N+5];

inline LL read(){
	LL s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

struct Node{
	LL t,a,b;
	bool operator < (const Node &f) const{
		return a/b>f.a/f.b;
	}
};
priority_queue <Node> que;

bool check(LL mid){
	while(!que.empty())que.pop();
	for(register int i=1;i<=n;++i){
		if(a[i]/b[i]>=k+0ll)continue;
		Node p;
		p.t=a[i]/b[i];
		p.a=a[i];
		p.b=b[i];
		que.push(p);
	}
	if(que.empty())return true;
	for(register int i=0;i<k;++i){
		Node p;
		p=que.top();
		que.pop();
		if(p.t<i)return false;
		if((p.a+mid)/p.b<k+0ll){
			Node now;
			now.t=(p.a+mid)/p.b;
			now.a=p.a+mid;
			now.b=p.b;
			que.push(now);
			continue;
		}
		if(que.empty())return true;
	}
}

int main(void){
	scanf("%d",&n);
	scanf("%d",&k);
	for(register int i=1;i<=n;++i)
	a[i]=read();
	for(register int i=1;i<=n;++i)
	b[i]=read();
	ans=0x7f7f7f7f;
	l=0;
	r=0x7f7f7f7f;
	while(l<=r){
		LL mid=(l+r)/2;
		if(check(mid)==true)ans=min(ans,mid),r=mid-1;
		else l=mid+1;
	}
	if(ans==0x7f7f7f7f)printf("-1\n");
	else printf("%lld\n",ans);
}


#pragma GCC optimize(2)
#include <cstdio>
#include <queue>
#define ll long long

using namespace std;

inline ll read(){
    ll x = 0; int zf = 1; char ch = ' ';
    while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}

struct Node{
    ll c; ll b; ll a;
};

inline bool operator <(const Node &A, const Node &B){
    if(A.c != B.c)
        return (A.c > B.c);
    else if(A.b != B.b)
        return (A.b < B.b);
    else
        return (A.a > B.a);
}

int n, k;
ll a[200005], b[200005];

priority_queue<Node> que;

bool judge(ll num){
    while (!que.empty()) que.pop();
    for (register int i = 1; i <= n; ++i)
        if (a[i] / b[i] < k){
            Node _new = {a[i] / b[i], b[i], a[i]};
            que.push(_new);
        }
    if (que.empty()) return 1;
    Node u;
    for (int i = 0; i < k; ++i){
        u = que.top(), que.pop();
        if (u.c < i) return 0;
        if (((u.a + num) / u.b) < k)
            que.push((Node){(u.a + num) / u.b, u.b, u.a + num});
        if (que.empty()) return 1;
    }
    return 1;
}

int main(){
    n = read(), k = read();
    for (register int i = 1; i <= n; ++i) a[i] = read();
    for (register int i = 1; i <= n; ++i) b[i] = read();
    ll l = 0, r = 1e16, mid;
    ll ans = -1;
    while (l <= r){
        mid = (l + r) >> 1;
        if (judge(mid))
            ans = mid, r = mid - 1;
        else
            l = mid + 1;
    }
    printf("%lld", ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long n, k;

long long ta[200020];
long long tb[200020];

long long a[200020];
long long b[200020];

long long ans = 0;

int main()
{
	scanf("%lld%lld", &n, &k);

	for (long long i = 1; i <= n; i++) scanf("%lld", &ta[i]);
	for (long long i = 1; i <= n; i++)
	{
		scanf("%lld", &tb[i]);
		ans += tb[i];
	}

	long long tmp = ans;
	ans /= n;
	ans--;

	for (; ans <= tmp; ans++)
	{
		int f = 1;

		memcpy(a, ta, sizeof(ta));
		memcpy(b, tb, sizeof(tb));

		for (long long i = 1; i <= k; i++)
		{
			long long t = 0;
			long long cnt;
			long long mn = 2e16;
			for (long long j = 1; j <= n; ++j)
			{
				if(a[i] - b[i] < mn)
				{
					mn = a[j] - b[j];
					cnt = j;
				}
				if(a[j] - b[j] < 0)
				{
					t++;
				}
				if(i != 1)
				{
					a[j] -= b[j];
					if(a[j] < 0) t = 2;
				}
				if(t == 2) break;
			}

			if (t == 2)
			{
				f = 0;
				break;
			}

			a[cnt] += ans;

		}

		if(f)
		{
			printf("%lld\n", ans);
			return 0;
		}

	}

	printf("-1\n");

	return 0;
}


#include <bits/stdc++.h>
#define N 1000005
#define ll long long
using namespace std;

ll n,k;
ll a[N],b[N],c[N];

bool check(ll x)
{
	typedef pair <ll,ll> pil;
	priority_queue <pil,vector<pil>,greater<pil> > q;
	ll cnt=0;
	for(ll i=1;i<=n;i++) q.push(make_pair(a[i]/b[i],i)),c[i]=a[i];
	for(ll i=1;i<=k;i++)
	{
		ll p=q.top().first;
		ll now=q.top().second;
		q.pop();
		if(p+1<i) return 0;
		c[now]=c[now]+x;
		q.push(make_pair(c[now]/b[now],now));
	}
	ll p=q.top().first;
	if(p+1<k) return 0;
	return 1;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(ll i=1;i<=n;i++) scanf("%lld",&b[i]);
	ll l=1,r=1e18;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(check(mid)) r=mid-1;
		else l=mid+1;
	}
	if(check(r+1)) printf("%lld",r+1);
	else printf("-1");
	return 0;
}


#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#define N 200005
#define inf 1e18
#define ll long long
using namespace std;
struct cmp
{
	ll a,b,c;
	bool operator<(const cmp& oth)const
	{
        return c>oth.c;
    }
};
int n,k;
ll ans;
ll a[N],b[N];
int check(ll x)
{
	priority_queue <cmp> q;
	for(int i=1;i<=n;i++)
	q.push((cmp){a[i],b[i],a[i]/b[i]});
	for(int i=1;i<=k;i++)
	{
		cmp p=q.top();
		q.pop();
		if(p.a/p.b+1ll<i)
		return 0;
		if(p.a/p.b+1ll>=k)
		return 1;
		q.push((cmp){p.a+x,p.b,(p.a+x)/p.b});
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&k);
	ll bmax=0;
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
		bmax=max(bmax,b[i]);
	}
	ll l=0,r=(k-1)*bmax+1;
	while(l<r)
	{
		ll mid=(l+r)>>1;
		if(check(mid)==1)
		r=mid;
		else
		l=mid+1;
	}
	if(l>=(k-1)*bmax+1)
	printf("-1");
	else
	printf("%lld",l);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
#define N 200005
#define ll long long
ll n;  ll k;  ll a[N];  ll b[N];  ll mx;
struct node{
    ll a; ll b;
    bool operator<(const node &t)const{
        return (a/b)>(t.a/t.b);
    }
};
priority_queue<node>pq;

ll read(){
    ll w=1,q=0;char ch=' ';
    while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(ch>='0'&&ch<='9')q=q*10+ch-'0',ch=getchar();
    return w*q;
}

bool check(ll ans){
    while(!pq.empty())   pq.pop();
    for(ll i=1;i<=n;++i) if(a[i]<k*b[i]) pq.push((node){a[i],b[i]});
    if(pq.empty()) return true;
    for(ll i=1;i<=k;++i){
        node tmp=pq.top();      pq.pop();
        if(!pq.empty()&&(pq.top().a<pq.top().b*i)) return false;
        ll this_a=tmp.a;      ll this_b=tmp.b;
        if((this_a+ans)<this_b*i) return false;
        if((this_a+ans)<this_b*k)  pq.push((node){this_a+ans,this_b});
        if(pq.empty()) return true;
    }
    return  pq.empty();
}

int main(){
    n=read(); k=read(); --k;
    for(ll i=1;i<=n;++i) a[i]=read();
    for(ll i=1;i<=n;++i) b[i]=read();
    for(ll i=1;i<=n;++i) mx=max(mx,b[i]);
    ll ansl=0;  ll ansr=mx*k;
    while(ansl<=ansr){
        ll ansmid=(ansl+ansr)/2;
        if(check(ansmid))  ansr=ansmid-1;
        else               ansl=ansmid+1;
    }
    if(ansl>mx*k) printf("-1\n");
    else         printf("%lld\n",ansl);

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAXN = 200010;

int n, m, cnt[MAXN];
ll a[MAXN], b[MAXN];

bool ok(ll mid) {
	memset(cnt, 0, sizeof cnt);
	ll c = m;
	for(int i = 0; i < n; i++) {
		ll pos = 0, cur = a[i];
		while(pos <= m) {
			pos += cur / b[i];
			if(pos >= m) break;
			cur %= b[i];
			cnt[pos]++;
			cur += mid;
			if(c-- < 0) return false;
		}
	}
	for(int i = 1; i <= m; i++) cnt[i] += cnt[i - 1];
	for(int i = 0; i <= m; i++)
		if(cnt[i] > i + 1) return false;
	return true;
}

int main() {

	cin >> n >> m;
	m--;
	for(int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for(int i = 0; i < n; i++)
		scanf("%lld", &b[i]);
	ll l = 0, r = 1e15;
	while(l < r) {
		ll mid = (l + r) / 2;
		ok(mid) ? r = mid : l = mid + 1;
	}
	if(l == 1e15) puts("-1");
	else cout << l << '\n';

	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define LL long long
const int N=200005;
LL a[N],b[N],plp[N],plpp[N],aa[N];
LL ans=0x7f7f7f7f7f;
LL n,k;
bool jud(LL x)
{
	priority_queue<pair<LL,int> ,vector<pair<LL,int> >,greater<pair<LL,int> > > q;
	for(int i=1;i<=n;i++)
		q.push(make_pair(plpp[i],i));
	LL QAQ=k;
	LL cnt=-1;
	while(QAQ--)
	{
		LL v=q.top().first;
		int id=q.top().second;
//		cout<<cnt<<"HHH"<<v<<' '<<id<<endl;
		q.pop();
		cnt++;
		if(aa[id]-cnt*b[id]<0) return 0;
		aa[id]+=x;
		plpp[id]=ceil((double)aa[id]/b[id]);
		q.push(make_pair(plpp[id],id));
	}
	if(q.top().first<k) return 0;
	return 1;
}

void t_part(LL l,LL r)
{
	LL mid=(l+r)/2;
	if(l>r) return;
//	cout<<l<<' '<<r<<' '<<mid<<endl;
	for(int i=1;i<=n;i++) aa[i]=a[i],plpp[i]=plp[i];
	if(jud(mid))
	{
		ans=min(ans,mid);
		t_part(l,mid-1);
	}
	else t_part(mid+1,r);
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]),plp[i]=ceil((double)a[i]/b[i]);
	t_part(0,0x7f7f7f7f7f);
	if(ans==0x7f7f7f7f7f) ans=-1;
	printf("%lld",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define LL long long
const int N=200005;
LL a[N],b[N],plp[N],plpp[N],aa[N];
LL ans=0x7f7f7f7f7f;
LL n,k;
bool jud(LL x)
{
	priority_queue<pair<LL,int> ,vector<pair<LL,int> >,greater<pair<LL,int> > > q;
	for(int i=1;i<=n;i++)
		q.push(make_pair(plpp[i],i));
	LL QAQ=k;
	LL cnt=-1;
	while(QAQ--)
	{
		LL v=q.top().first;
		int id=q.top().second;
//		cout<<cnt<<"HHH"<<v<<' '<<id<<endl;
		q.pop();
		cnt++;
		if(v-cnt*b[id]<0) return 0;
		v+=x;
		q.push(make_pair(ceil((double)v+x/b[id]),id));
	}
	if(q.top().first<k) return 0;
	return 1;
}

void t_part(LL l,LL r)
{
	LL mid=(l+r)/2;
	if(l>r) return;
//	cout<<l<<' '<<r<<' '<<mid<<endl;
	for(int i=1;i<=n;i++) aa[i]=a[i],plpp[i]=plp[i];
	if(jud(mid))
	{
		ans=min(ans,mid);
		t_part(l,mid-1);
	}
	else t_part(mid+1,r);
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]),plp[i]=ceil((double)a[i]/b[i]);
	t_part(0,0x7f7f7f7f7f);
	if(ans==0x7f7f7f7f7f) ans=-1;
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
struct node {
    ll A, B;
    node(ll AA, ll BB) :
        A(AA), B(BB) {}
    bool operator < (const node &N) const {
        if(A / B != N.A / N.B) return A/B > N.A/N.B;
        if(B != N.B) return B < N.B;
        return A > N.A;
    }
};
int n, k;
ll a[maxn], b[maxn];
priority_queue<node> q;
bool chk(ll x) {
    while(!q.empty()) q.pop();
    for(int i = 1 ; i <= n ; i ++)
        if(a[i] / b[i] < k)
            q.push(node(a[i], b[i]));
    if(q.empty())
        return true; // no one needs to recharge
                     // thx to the powerful battery
    for(int i = 0 ; i < k ; i ++) {
        node tp = q.top(); q.pop();
        if(tp.A / tp.B < i)
            return false;
        if((tp.A + x) / tp.B < k)
            q.push(node(tp.A + x, tp.B));
        if(q.empty())
            return true;
    }
    return true;
}
int main() {
    scanf("%d%d", &n, &k);
    for(int i = 1 ; i <= n ; i ++)
        scanf("%I64d", &a[i]);
    for(int i = 1 ; i <= n ; i ++)
        scanf("%I64d", &b[i]);
    ll l = 0, r = 2e12, ret = -1, mid;
    while(l <= r) {
        mid = (l + r) >> 1;
        // cout << l << ' ' << r << ' ' << mid << endl;
        if(chk(mid)) {
            ret = mid;
            r = mid - 1;
        } else
            l = mid + 1;
    }
    printf("%I64d", ret);
    return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return x*f;
}
struct node {
	int x,y,id;
} a[1000009];
bool operator < (node aa,node bb) {return aa.x/aa.y<bb.x/bb.y;}
bool operator > (node aa,node bb) {return aa.x/aa.y>bb.x/bb.y;}
int u,v=2e12,mid,ddd[300001][2];
int n,x,in,opt,flag;
int N,K;
void ins(int p,int q,int qaqaq){
	++n,a[n].x=p,a[n].y=q,a[n].id=qaqaq,x=n;
	while(x/2&&a[x/2]>a[x]) {
		swap(a[x/2],a[x]);
		x/=2;
	}
}
void shan(){
	a[1]=a[n],--n,x=1;
	while(2*x<=n){
		if(a[2*x]<a[2*x+1]) {
			if(a[x]>a[x*2])swap(a[x],a[x*2]),x=x*2;
			else break;
		} else {
			if(a[x]>a[x*2+1])swap(a[x],a[x*2+1]),x=x*2+1;
			else break;
		}
	}
}
signed main() {
	N=read(),K=read();
	for(int i = 1; i <= N; i++) ddd[i][0]=read();
	for(int i = 1; i <= N; i++) ddd[i][1]=read();
	while(u<v){
		flag=0,mid=(u+v)/2;
		for(int i = 1; i <= N; i++) ins(ddd[i][0],ddd[i][1],i);
		for(int i = 1; i <= K-1; i++) {
			int sava=a[1].x+mid,savb=a[1].y,savc=a[1].id;
			shan();
			ins(sava,savb,savc);
			if(a[1].x/a[1].y<i) {
				flag=1;
				break;
			}
		}
		for(int i = 1; i <= N; i++) shan();
		if(flag==1) u=mid+1;
		else v=mid;
	}
	if(u==(1ll<<55)) printf("-1");
	else printf("%lld",u);
	return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
const long long inf = 2e12;
using namespace std;
struct node {
	long long x,y;
	inline node (){};
	inline node (int X,int Y){
		x = X,y = Y;
	}
	inline bool operator < (const node &rhs)const {
		long long x1 = x / y + 1;
		long long x2 = rhs.x / rhs.y + 1;
		return x1 > x2;
	}
};
int n,k,t;
long long a[200005],b[200005],ans1 = -1;
priority_queue<node>Q;
inline long long read(){
	long long x = 0;
	int f = 1;
	char s = getchar();
	while (s < '0' || s > '9'){
		if (s == '-')
			f = -1;
		s = getchar();
	}
	while (s >= '0' && s <= '9'){
		x = x * 10 + s - '0';
		s = getchar ();
	}
	return x * f;
}
inline bool check(long long ans){
	while (!Q.empty())
		Q.pop();
	for (int i = 1;i <= n;i ++)
		if (a[i] / b[i] + 1 < k)
			Q.push(node(a[i],b[i]));
	int xx = 0;
	while (!Q.empty() && xx < k){
		xx ++;
		node p = Q.top();
		Q.pop();
		if (p.x / p.y + 1 < xx)
			return 0;
		p.x += ans;
		if (p.x / p.y >= k)
			continue;
		Q.push(p);
	}
	return 1;
}
int main(){
	n = read();
	k = read();
	for (int i = 1;i <= n;i ++)
		a[i] = read();
	for (int i = 1;i <= n;i ++)
		b[i] = read();
	register long long l = 0,r = inf;
	while (l <= r){
		long long mid = (l + r) / 2;
		if (check(mid)){
			ans1 = mid;
			r = mid - 1;
		}
		else
			l = mid + 1;
	}
	printf("%lld\n",ans1);
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<ll,ll>
#define pll pair<int,pii>
#define F first
#define S second
#define clear(q)
using namespace std;
const int N=2e5+5;
ll l=0,r=1e18;
ll n,x[N],X[N],y[N],m;
bool check(ll mid)
{
	ll sum=0;
	priority_queue<pii,vector<pii>,greater<pii> >q;//distance to dead
	while(!q.empty())q.pop();
	for(int i=0;i<n;i++)x[i]=X[i];
	for(ll i=0;i<n;i++)
	{
		q.push(mp(x[i]/y[i],i));
	}
	for(ll i=0;i<=m;i++)
	{
		if(q.empty())return true;
		pii t=q.top();
		q.pop();
		int j=t.S;
		if(t.F<i&&i)return false;
		x[j]+=mid;
		t.F=x[j]/y[j];
		if(t.F<m)q.push(t);
	}
	return true;
}
int main()
{
	cin>>n>>m;m--;
	for(int i=0;i<n;i++)cin>>x[i],X[i]=x[i];
	for(int i=0;i<n;i++)cin>>y[i];
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	if(r>=1e18)cout<<"-1\n";
	else cout<<r+1<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
typedef long long LL;
typedef pair<LL,LL> pii;
const LL INF=0x7f7f7f7f7f7f;
LL n,k;
LL a[MAXN],b[MAXN],num[MAXN];
priority_queue<pii,vector<pii>,greater<pii> >q;
bool check(LL x){
	while(!q.empty())q.pop();LL tot=0;
	for(int i=1;i<=n;i++){
		if(a[i]/b[i]<k)
			q.push(make_pair(a[i]/b[i],i));
		num[i]=a[i];
	}
	while(!q.empty()){
		LL t=q.top().second;q.pop();
		//if(x==5)printf("%d %d %d %d\n",t,num[t],b[t],tot);
		if(num[t]/b[t]<tot)return false;num[t]+=x;tot++;
		if(num[t]/b[t]<k)q.push(make_pair(num[t]/b[t],t));
	}
	return true;
}
signed main(){
	scanf("%lld %lld",&n,&k);k--;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
	LL l=0,r=INF,ans=-1;
	while(l<=r){
		LL mid=l+(r-l>>1);
		//printf("%d %d %d\n",l,r,mid);
		if(check(mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}