#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define endl '\n'
#define sf(x) scanf("%lld",&x)
#define pf(x) printf("%lld\n",x)
int main()
{
LL i,j,k,l,m,n,p,q,aud=0,ans=0,pos=0,a;
unordered_map<LL,LL>cnt1;
sf(n);
LL v[n+10];
LL s[n+10];
for(i=0; i<n; i++)
sf(a),cnt1[a]++;
sf(m);
for(i=0; i<m; i++)
sf(v[i]);
for(i=0; i<m; i++)
sf(s[i]);
for(i=0; i<m; i++)
{
if(cnt1.find(v[i])==cnt1.end() && cnt1.find(s[i])==cnt1.end())continue;
p = cnt1[v[i]];
if(p>aud)
{
aud=p;
ans=i+1;
pos=i;
}
else if(p==aud)
{
if(cnt1.find(s[i])==cnt1.end())continue;
if(cnt1.find(s[pos])==cnt1.end())
{
ans=i+1;
pos=i;
continue;
}
if(cnt1[s[i]]>=cnt1[s[pos]])
{
ans=i+1;
pos=i;
}
}
}
pf(ans);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgTEw7CiNkZWZpbmUgZW5kbCAnXG4nCiNkZWZpbmUgIHNmKHgpIHNjYW5mKCIlbGxkIiwmeCkKI2RlZmluZSAgcGYoeCkgcHJpbnRmKCIlbGxkXG4iLHgpCmludCBtYWluKCkKewogICAgTEwgaSxqLGssbCxtLG4scCxxLGF1ZD0wLGFucz0wLHBvcz0wLGE7CiAgICB1bm9yZGVyZWRfbWFwPExMLExMPmNudDE7CiAgICBzZihuKTsKCiAgICBMTCB2W24rMTBdOwogICAgTEwgc1tuKzEwXTsKICAgIGZvcihpPTA7IGk8bjsgaSsrKQogICAgICAgIHNmKGEpLGNudDFbYV0rKzsKICAgIHNmKG0pOwogICAgZm9yKGk9MDsgaTxtOyBpKyspCiAgICAgICAgc2YodltpXSk7CiAgICBmb3IoaT0wOyBpPG07IGkrKykKICAgICAgICBzZihzW2ldKTsKICAgIGZvcihpPTA7IGk8bTsgaSsrKQogICAgewogICAgICAgIGlmKGNudDEuZmluZCh2W2ldKT09Y250MS5lbmQoKSAmJiBjbnQxLmZpbmQoc1tpXSk9PWNudDEuZW5kKCkpY29udGludWU7CiAgICAgICAgcCA9IGNudDFbdltpXV07CiAgICAgICAgaWYocD5hdWQpCiAgICAgICAgewogICAgICAgICAgICBhdWQ9cDsKICAgICAgICAgICAgYW5zPWkrMTsKICAgICAgICAgICAgcG9zPWk7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYocD09YXVkKQogICAgICAgIHsKICAgICAgICAgICAgaWYoY250MS5maW5kKHNbaV0pPT1jbnQxLmVuZCgpKWNvbnRpbnVlOwogICAgICAgICAgICBpZihjbnQxLmZpbmQoc1twb3NdKT09Y250MS5lbmQoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYW5zPWkrMTsKICAgICAgICAgICAgICAgIHBvcz1pOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGlmKGNudDFbc1tpXV0+PWNudDFbc1twb3NdXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYW5zPWkrMTsKICAgICAgICAgICAgICAgIHBvcz1pOwogICAgICAgICAgICB9CgogICAgICAgIH0KICAgIH0KICAgIHBmKGFucyk7Cn0K