#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include<cctype>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<time.h>
#include<iterator>
#include <deque>
#include <sstream>
#include<queue>
#include<stdlib.h>
#include<bitset>
#include <utility>

#define fn(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define f1n(i,n) for(int (i) = 1;(i) <= (n);(i)++)
#define mk(f,s) make_pair((f),(s))

#define defV(dp,e) memset(dp,e,sizeof dp)

#define ri(n) scanf("%d",&n)
#define rl(n) scanf("%lld",&n)
#define rs(s) scanf("%s",s)

#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef pair<int ,int > pp;

typedef vector<int  > v1;
typedef vector<ll  > vl;
typedef vector<pp  > vpp;
typedef vector<bool  > vb;
typedef vector<char > vc;
typedef vector<v1 > v2;

typedef map<int ,int > mf;
typedef map<int ,vpp > mv;
typedef map<int ,v1 > ad;

int const siz = 1e9,bound = 7e5,mod = siz+9;
ll const oo=1e18;

map<int ,int > lang;
int aud[bound],n;

int main() {
//	freopen("o.txt","w",stdout);
//	freopen("in.txt","r",stdin);
//	ios::sync_with_stdio(0);cin.tie();
	ri(n);
	fn(i,n){
		int a;
		ri(a);
		lang[a]++;
	}
	int m;
	ri(m);
	fn(i,m)ri(aud[i]);
	int mx=0,pl=0,idx=1;
	fn(i,m){
		int sub;
		ri(sub);
		if(lang[aud[i]]>mx||lang[aud[i]]==mx&&lang[sub]>pl){
			mx=lang[aud[i]];
			idx=i+1;
			pl=lang[sub];
		}
	}
	printf("%d\n",idx);
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
const int N = (int)2e5 + 113;

int n, m, ind;
map <int, int> mp;
pair <int, int> f[N], c;
pair <int, int> ans;
int main() {
	//freopen("input.txt", "r", stdin);

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> m;
		mp[m] ++;
	}
	cin >> m;

	for (int i = 1; i <= m; i++)
		cin >> f[i].first;

	for (int i = 1; i <= m; i++)
		cin >> f[i].second;

	for (int i = 1; i <= m; i++) {
		cin >> f[i].first >> f[i].second;
		c.first = mp[f[i].first];
		c.second = mp[f[i].second];

		if (c > ans) {
			ans = c;
			ind = i;
		}

	}
	cout << ind;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
const int N = (int)2e5 + 113;

int n, m, ind = 1;
map <int, int> mp;
pair <int, int> f[N], c;
pair <int, int> ans;
int main() {
	//freopen("input.txt", "r", stdin);

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> m;
		mp[m] ++;
	}
	cin >> m;

	for (int i = 1; i <= m; i++)
		cin >> f[i].first;

	for (int i = 1; i <= m; i++)
		cin >> f[i].second;

	for (int i = 1; i <= m; i++) {
		cin >> f[i].first >> f[i].second;
		c.first = mp[f[i].first];
		c.second = mp[f[i].second];

		if (c > ans) {
			ans = c;
			ind = i;
		}

	}
	cout << ind;
	return 0;
}


// 351A.cpp: определяет точку входа для консольного приложения.
//

#include <iostream>
#include <map>

using namespace std;

int main()
{

	int n;
	cin>>n;

	map <int, int> ls;

	for (int i=0; i<n; i++)
	{
		int a;
		cin>>a;
		ls[a]++;
	}

	int m;
	cin>>m;

	int x=0, z=0;

	int *o=new int[m];
	int *s=new int[m];

	for (int i=0; i<m; i++)
	{
		int a;
		cin>>a;
		o[i]=ls[a];
	}

	for (int i=0; i<m; i++)
	{
		int a;
		cin>>a;
		s[i]=ls[a];
	}

	int omax=0, smax=0;
	int num=-1;

	for (int i=0; i<n; i++)
	{
		if (o[i]>omax)
		{
			omax=o[i];
			smax=s[i];
			num=i;
		}
		else if (o[i]==omax && s[i]>smax)
		{
			omax=o[i];
			smax=s[i];
			num=i;
		}
	}

	cout<<(num+1);

	return 0;
}


#include <iostream>
#include <map>

using namespace std;

int main()
{

	int n;
	cin>>n;

	map <int, int> ls;

	for (int i=0; i<n; i++)
	{
		int a;
		cin>>a;
		ls[a]++;
	}

	int m;
	cin>>m;

	int x=0, z=0;

	int *o=new int[m];
	int *s=new int[m];

	for (int i=0; i<m; i++)
	{
		int a;
		cin>>a;
		o[i]=ls[a];
	}

	for (int i=0; i<m; i++)
	{
		int a;
		cin>>a;
		s[i]=ls[a];
	}

	int omax=0, smax=0;
	int num=0;

	for (int i=0; i<m; i++)
	{
		if (o[i]>omax)
		{
			omax=o[i];
			smax=s[i];
			num=i;
		}
		else if (o[i]==omax && s[i]>smax)
		{
			omax=o[i];
			smax=s[i];
			num=i;
		}
	}

	cout<<(num+1);

	return 0;
}


#include <iostream>
#include <map>

using namespace std;

int main()
{

	int n;
	cin>>n;

	map <int, int> ls;

	for (int i=0; i<n; i++)
	{
		int a;
		cin>>a;
		ls[a]++;
	}

	int m;
	cin>>m;

	int x=0, z=0;

	int *o=new int[m];
	int *s=new int[m];

	for (int i=0; i<m; i++)
	{
		int a;
		cin>>a;
		o[i]=ls[a];
	}

	for (int i=0; i<m; i++)
	{
		int a;
		cin>>a;
		s[i]=ls[a];
	}

	int omax=0, smax=0;
	int num=-1;

	for (int i=0; i<m; i++)
	{
		if (o[i]>omax)
		{
			omax=o[i];
			smax=s[i];
			num=i;
		}
		else if (o[i]==omax && s[i]>smax)
		{
			omax=o[i];
			smax=s[i];
			num=i;
		}
	}

	cout<<(num+1);

	return 0;
}


#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b); i++)
const int N = 200005;

int a[200000], b[200000], c[200000], B[200000];
void main()
{
	int n, m, VeryGood = -1, Number;
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cout << fixed << setprecision(15);
	cin >> n;
	map<int, int> VeryG;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		VeryG[a[i]]++;
	}
	cin >> m;
	for (int j = 0; j < m; j++)
		cin >> b[j];
	for (int j = 0; j < m; j++)
		cin >> c[j];
	for (int i = 0; i < n; i++)
	{
		B[i] = VeryG[b[i]];
		if (VeryGood < B[i])
		{
			VeryGood = B[i];
			Number = i;
		}
	}
	for (int i = 0; i < n; i++)
		if (VeryGood == B[i])
			if (VeryG[c[Number]] < VeryG[c[i]])
				Number = i;
	cout << Number + 1;
}


#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b); i++)
const int N = 200005;

int a[200000], b[200000], c[200000];
void main()
{
	int n, m, VeryGood = -1, Number;
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cout << fixed << setprecision(15);
	cin >> n;
	map<int, int> VeryG;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		VeryG[a[i]]++;
	}
	cin >> m;
	for (int j = 0; j < m; j++)
		cin >> b[j];
	for (int j = 0; j < m; j++)
		cin >> c[j];
	for (int i = 0; i < n; i++)
		if (VeryGood <= VeryG[b[i]])
		{
			VeryGood = VeryG[b[i]];
			Number = i;
		}
	for (int i = 0; i < n; i++)
		if ((VeryGood == VeryG[b[i]]) && (i != Number))
			if (VeryG[c[Number]] <= VeryG[c[i]])
			{
				VeryG[c[Number]] = VeryG[c[i]];
				Number = i;
			}
	cout << Number + 1;
}


#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b); i++)
const int N = 200005;

int a[200000], b[200000], c[200000], B[200000];
void main()
{
	int n, m, VeryGood = -1, Number;
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cout << fixed << setprecision(15);
	cin >> n;
	map<int, int> VeryG;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		VeryG[a[i]]++;
	}
	cin >> m;
	for (int j = 0; j < m; j++)
		cin >> b[j];
	for (int j = 0; j < m; j++)
		cin >> c[j];
	for (int i = 0; i < m; i++)
	{
		B[i] = VeryG[b[i]];
		if (VeryGood < B[i])
		{
			VeryGood = B[i];
			Number = i;
		}
	}
	for (int i = 0; i < m; i++)
		if (VeryGood == B[i])
			if (VeryG[c[Number]] < VeryG[c[i]])
				Number = i;
	cout << Number + 1;
}


#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b); i++)
const int N = 200005;

int a[200000], b[200000], c[200000];
void main()
{
	int n, m, VeryGood = -1, Good = -1, Number;
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cout << fixed << setprecision(15);
	cin >> n;
	map<int, pair<int, int>> Films;
	map<int, pair<int, int>> VeryG;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	for (int j = 0; j < m; j++)
		cin >> b[j];
	for (int j = 0; j < m; j++)
	{
		cin >> c[j];
		Films[j + 1].first = b[j];
		Films[j + 1].second = c[j];
	}
	for (auto it = Films.begin(); it != Films.end(); it++)
		for (int i = 0; i < n; i++)
		{
			if (a[i] == it->second.first)
				VeryG[it->first].first++;
			if (a[i] == it->second.second)
				VeryG[it->first].second++;
		}
	for (auto it = VeryG.begin(); it != VeryG.end(); it++)
		if (VeryGood <= it->second.first)
		{
			VeryGood = it->second.first;
			Number = it->first;
		}
	for (auto it = VeryG.begin(); it != VeryG.end(); it++)
		if (VeryGood == it->second.first)
			if (Good <= it->second.second)
			{
				Good = it->second.second;
				Number = it->first;
			}
	cout << Number;
}


#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;
#define int long long
#define fi(i,a,b) for(int i = a; i < (b); i++)
const int N = 200005;

struct Films {
	int NumberFilm;
	int LanguageOne;
	int LanguageTwo;
	int VeryGood;
	int Good;
};
struct VeryGoodEqual {
	int NumberFilm;
	int VeryGood;
	int Good;
};

int a[200000];
void main()
{
	int n, m, MaxVeryGood = 0, MaxGood = 0, k = 0, g;
#if defined(_DEBUG)
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
	cout << fixed << setprecision(15);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	Films *StFilms = new Films[200000];
	map<int, VeryGoodEqual> EqualVeryGood;
	for (int i = 0; i < m; i++)
		cin >> StFilms[i].LanguageOne;
	for (int i = 0; i < m; i++)
		cin >> StFilms[i].LanguageTwo;
	for (int i = 0; i < m; i++)
		StFilms[i].NumberFilm = i + 1;
	for (int i = 0; i < m; i++)
	{
		StFilms[i].VeryGood = 0;
		StFilms[i].Good = 0;
	}
	for (int j = 0; j < m; j++)
		for (int i = 0; i < n; i++)
		{
			if (a[i] == StFilms[j].LanguageOne)
				StFilms[j].VeryGood++;
			if (a[i] == StFilms[j].LanguageTwo)
				StFilms[j].Good++;
		}
	for (int i = 0; i < m; i++)
	{
		if (MaxVeryGood <= StFilms[i].VeryGood)
		{
			MaxVeryGood = StFilms[i].VeryGood;
			g = i;
		}
	}
	int j = 0;
	for (int i = 0; i < m; i++)
	{
		if (MaxVeryGood == StFilms[i].VeryGood)
		{
			k++;
			EqualVeryGood[j].NumberFilm = StFilms[i].NumberFilm;
			EqualVeryGood[j].VeryGood = StFilms[i].VeryGood;
			EqualVeryGood[j].Good = StFilms[i].Good;
			j++;
		}
	}
	if (k == 1)
		cout << StFilms[g].NumberFilm;
	else
	{
		for (int i = 0; i < k; i++)
		{
			if (MaxGood <= EqualVeryGood[i].Good)
			{
				MaxGood = EqualVeryGood[i].Good;
				g = i;
			}
		}
		cout << EqualVeryGood[g].NumberFilm;
	}
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <assert.h>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <map>

using namespace std;

const int N = 200001;

map < int, int > cnt;
int n, m;
int b[N], c[N];

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		int a; scanf("%d", &a);
		cnt[a]++;
	}
	scanf("%d", &m);
	int ans = -1;
	pair < int, int > c1;
	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)
	{
		pair < int , int > p(0, 0);
		if (cnt.find(b[i]) != cnt.end())
			p.first = cnt[b[i]];
		if (cnt.find(c[i]) != cnt.end())
			p.second = cnt[c[i]];
		if (ans == -1 || (c1.first < p.first || (c1.first == p.first && c1.second < p.second)))
		{
			c1 = p;
			ans = i;
		}
	}
	cout << ans + 1 << endl;

    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <assert.h>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <map>

using namespace std;

const int N = 200001;

map < int, int > cnt;
int n, m;

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		int a; scanf("%d", &a);
		cnt[a]++;
	}
	scanf("%d", &m);
	int ans = -1;
	pair < int, int > c1;
	for (int i = 0; i < m; ++i)
	{
		int b, c; scanf("%d%d", &b, &c);
		pair < int , int > p(0, 0);
		if (cnt.find(b) != cnt.end())
			p.first = cnt[b];
		if (cnt.find(c) != cnt.end())
			p.second = cnt[c];
		if (ans == -1 || (c1.first < p.first || (c1.first == p.first && c1.second < p.second)))
		{
			c1 = p;
			ans = i;
		}
	}
	cout << ans + 1 << endl;

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
using namespace std;

typedef long long ll;

struct state {
	int b, c, idx;
	state(int b, int c, int idx) :b(b), c(c), idx(idx) {}
	bool operator<(const state&e)const {
		if (e.b != b)
			return e.b < b;
		return e.c < c;
	}
};

const int N = 2e5 + 1;
int n, a[N], m, b[N], c[N];
vector<state> v;

int main(int argc, char **argv) {
//	freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	sort(a, a + n);
	scanf("%d", &m);
	for (int i = 0; i < m; ++i)
		scanf("%d%d", &b[i], &c[i]);
	int l, r;
	for (int i = 0; i < m; ++i) {
		l = lower_bound(a, a + n, b[i]) - a;
		r = upper_bound(a, a + n, b[i]) - a;
		int canA = r - l;
		l = lower_bound(a, a + n, c[i]) - a;
		r = upper_bound(a, a + n, c[i]) - a;
		int canS = r - l;
		v.push_back(state(canA, canS, i));
	}
	sort(v.begin(), v.end());
	assert(res != -1);
	printf("%d\n", v[0].idx + 1);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
using namespace std;

typedef long long ll;

struct state {
	int b, c, idx;
	state(int b, int c, int idx) :b(b), c(c), idx(idx) {}
	bool operator<(const state&e)const {
		if (e.b != b)
			return e.b < b;
		return e.c < c;
	}
};

const int N = 2e5 + 1;
int n, a[N], m, b[N], c[N];
vector<state> v;

int main(int argc, char **argv) {
//	freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	sort(a, a + n);
	scanf("%d", &m);
	for (int i = 0; i < m; ++i)
		scanf("%d%d", &b[i], &c[i]);
	int l, r;
	for (int i = 0; i < m; ++i) {
		l = lower_bound(a, a + n, b[i]) - a;
		r = upper_bound(a, a + n, b[i]) - a;
		int canA = r - l;
		l = lower_bound(a, a + n, c[i]) - a;
		r = upper_bound(a, a + n, c[i]) - a;
		int canS = r - l;
		v.push_back(state(canA, canS, i));
	}
	sort(v.begin(), v.end());
	printf("%d\n", v[0].idx + 1);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
using namespace std;

typedef long long ll;

const int N = 2e5 + 1;
int n, a[N], m, b[N], c[N];

int main(int argc, char **argv) {
//	freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	sort(a, a + n);
	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]);
	int A = -1, S = -1, l, r, res = -1;
	for (int i = 0; i < m; ++i) {
		l = lower_bound(a, a + n, b[i]) - a;
		r = upper_bound(a, a + n, b[i]) - a;
		int canA = r - l;
		l = lower_bound(a, a + n, c[i]) - a;
		r = upper_bound(a, a + n, c[i]) - a;
		int canS = r - l;
		if (canA > A || (canA == A && canS > S)) {
			res = i + 1;
			A = canA;
			S = canS;
		}
	}
	assert(res != -1);
	printf("%d\n", res);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 200500;
int a[N], b[N], c[N];
int sat[N], ple[N];
int n, m;
void init()
{
	memset(sat, 0, sizeof(sat));
	memset(ple, 0, sizeof(ple));
}
int search(int num)
{
	int sum = 1;
	for (int i = num+1; i <= n; i++)
	{
		if (a[i] == a[num]) sum++;
	}
	for (int i = num-1; i >= 1; i--)
	{
		if (a[i] == a[num]) sum++;
	}
	return sum;
}
int binary(int num)
{
	int l = 1, r = m;
	while (r > l)
	{
		int mid = (l + r) / 2;
		if (a[mid] > num)
			r = mid;
		else if (a[mid] < num)
			l = mid + 1;
		else
		{
			return search(mid);
		}
	}
	return 0;
}
int main()
{
#ifdef glx
	freopen("in.txt", "r", stdin);
#endif
	while (~scanf("%d", &n))
	{
		init();
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &a[i]);
		}
		sort(a + 1, a + n + 1);
		scanf("%d", &m);
		int maxn1=0, maxn2=0, pos1=0;
		for (int i = 1; i <= m; i++)
		{
			scanf("%d%d", &b[i],&c[i]);
		}
		for (int i = 1; i <= m; i++)
		{
			ple[i] += binary(b[i]);
			sat[i] += binary(c[i]);
			if (ple[i] >= maxn1)
			{
				if (ple[i] > maxn1)
				{
					maxn1 = ple[i];
					pos1 = i;
					maxn2 = sat[i];
				}
				else
				{
					if (sat[i] > maxn2)
					{
						pos1 = i;
						maxn2 = sat[i];
					}
				}
			}
		}
		cout << pos1 << endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 200500;
int a[N], b[N], c[N];
int sat[N], ple[N];
int n, m;
void init()
{
	memset(sat, 0, sizeof(sat));
	memset(ple, 0, sizeof(ple));
}
int search(int num)
{
	int sum = 0;
	for (int i = num+1; i <= n; i++)
	{
		if (a[i] == a[num]) sum++;
	}
	for (int i = num-1; i >= 1; i--)
	{
		if (a[i] == a[num]) sum++;
	}
	return sum;
}
int binary(int num)
{
	int l = 1, r = m;
	while (r > l)
	{
		int mid = (l + r) / 2;
		if (a[mid] > num)
			r = mid;
		else if (a[mid] < num)
			l = mid + 1;
		else
		{
			return search(mid);
		}
	}
	return 0;
}
int main()
{
#ifdef glx
	freopen("in.txt", "r", stdin);
#endif
	while (~scanf("%d", &n))
	{
		init();
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &a[i]);
		}
		sort(a + 1, a + n + 1);
		scanf("%d", &m);
		int maxn1=0, maxn2=0, pos1=0;
		for (int i = 1; i <= m; i++)
		{
			scanf("%d%d", &b[i],&c[i]);
		}
		for (int i = 1; i <= m; i++)
		{
			ple[i] += binary(b[i]);
			sat[i] += binary(c[i]);
			if (ple[i] >= maxn1)
			{
				if (ple[i] > maxn1)
				{
					maxn1 = ple[i];
					pos1 = i;
					maxn2 = sat[i];
				}
				else
				{
					if (sat[i] > maxn2)
					{
						pos1 = i;
						maxn2 = sat[i];
					}
				}
			}
		}
		cout << pos1 << endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 200500;
int a[N], b[N], c[N];
int len[N];
int sat[N], ple[N];
int n, m;
void init()
{
	memset(len, 0, sizeof(len));
	memset(sat, 0, sizeof(sat));
	memset(ple, 0, sizeof(ple));
}
int binary(int num)
{
	int l = 1, r = n;
	while (r > l)
	{
		int mid = (l + r) / 2;
		if (a[mid] > num)
			r = mid;
		else if (a[mid] < num)
			l = mid + 1;
		else
		{
			return len[mid];
		}
	}
	if (a[l] == num) return len[l];
	return 0;
}
void search()
{
	int sum = 1;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == a[i+1]) sum++;
		if (a[i] != a[i+1])
		{
			len[i] = sum;
			for (int j = i - 1; a[j] == a[j + 1] && j >= 1; j--)
				len[j] = sum;
			sum = 1;
		}
	}
}
int main()
{
#ifdef glx
	freopen("in.txt", "r", stdin);
#endif
	while (~scanf("%d", &n))
	{
		init();
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &a[i]);
		}
		sort(a + 1, a + n + 1);
		a[n + 1] = 0;
		search();
		scanf("%d", &m);
		int maxn1=0, maxn2=0, pos1=1;
		for (int i = 1; i <= m; i++)
		{
			scanf("%d", &b[i]);
		}
		for (int i = 1; i <= m; i++)
		{
			scanf("%d", &c[i]);
		}
		for (int i = 1; i <= m; i++)
		{
			ple[i] += binary(b[i]);
			sat[i] += binary(c[i]);
			if (ple[i] >= maxn1)
			{
				if (ple[i] > maxn1)
				{
					maxn1 = ple[i];
					pos1 = i;
					maxn2 = sat[i];
				}
				else
				{
					if (sat[i] > maxn2)
					{
						pos1 = i;
						maxn2 = sat[i];
					}
				}
			}
		}
		cout << pos1 << endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 200500;
int a[N], b[N], c[N];
int len[N];
int sat[N], ple[N];
int n, m;
void init()
{
	memset(len, 0, sizeof(len));
	memset(sat, 0, sizeof(sat));
	memset(ple, 0, sizeof(ple));
}
int binary(int num)
{
	int l = 1, r = m;
	while (r > l)
	{
		int mid = (l + r) / 2;
		if (a[mid] > num)
			r = mid;
		else if (a[mid] < num)
			l = mid + 1;
		else
		{
			return len[mid];
		}
	}
	return 0;
}
void search()
{
	int sum = 1;
	a[n + 1] = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == a[i+1]) sum++;
		if (a[i] != a[i+1])
		{
			len[i] = sum;
			for (int j = i - 1; a[j] == a[j + 1] && j >= 1; j--)
				len[j] = sum;
			sum = 1;
		}
	}
}
int main()
{
#ifdef glx
	freopen("in.txt", "r", stdin);
#endif
	while (~scanf("%d", &n))
	{
		init();
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &a[i]);
		}
		sort(a + 1, a + n + 1);
		search();
		scanf("%d", &m);
		int maxn1=0, maxn2=0, pos1=0;
		for (int i = 1; i <= m; i++)
		{
			scanf("%d%d", &b[i],&c[i]);
		}
		for (int i = 1; i <= m; i++)
		{
			ple[i] += binary(b[i]);
			sat[i] += binary(c[i]);
			if (ple[i] >= maxn1)
			{
				if (ple[i] > maxn1)
				{
					maxn1 = ple[i];
					pos1 = i;
					maxn2 = sat[i];
				}
				else
				{
					if (sat[i] > maxn2)
					{
						pos1 = i;
						maxn2 = sat[i];
					}
				}
			}
		}
		if (!pos1)
			cout << 1 << endl;
		else
			cout << pos1 << endl;
	}
	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		int tot = m.begin()->second;
		vector<int> au;
		au.push_back(audio);
		map<int, int>::iterator it;
		for (it = ++m.begin(); it != m.end(); ++it) {
			if (it->second == tot) au.push_back(it->first);
			else if (it->second > tot) {
				au.clear();
				tot = it->second;
				au.push_back(it->first);
			}
			else break;
		}
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = -1;
		for (int j = 0; j < au.size(); ++j) {
			audio = au[j];
			for (int i = 1; i <= t; ++i) {
				if (movie[i][0] == audio) {
					int cnt = m[movie[i][1]];
					if (cnt > maxx) {
						maxx = cnt;
						index = i;
					}
				}
			}
		}
		cout << index << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
map<int, int> m;
int movie[maxn][2];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}
		int t;
		cin >> t;

		for (int i = 0; i < t; ++i)
			cin >> movie[i][0];

		for (int i = 0; i < t; ++i)
			cin >> movie[i][1];

		int au, title, a, b;
		int index = 0;
		int au_maxx = -1, title_maxx = -1;
		for (int i = 0; i < t; ++i) {
			au = m[movie[i][0]], title = m[movie[i][1]];
			if (au > au_maxx) {
				title_maxx = title;
				au_maxx = au;
				index = i;
			}
			else if (au == au_maxx && title > title_maxx) {
				title_maxx = title;
				index = i;
			}
		}
		cout << index+1 << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = 0;

		map<int, int>::iterator it;
		int dis = 1;
		for (it = m.begin(); it != m.end(); ++it,++dis) {
			if (it->first == audio) {
				int cnt = it->second;
				if (cnt > maxx) {
					maxx = cnt;
					index = dis;
				}
			}
		}
		cout << index << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		int tot = m.begin()->second;
		vector<int> au;
		au.push_back(audio);
		map<int, int>::iterator it;
		for (it = ++m.begin(); it != m.end(); ++it) {
			if (it->second == tot) au.push_back(it->first);
			else if (it->second > tot) {
				au.clear();
				tot = it->second;
				au.push_back(it->first);
			}
		}
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = -1;
		for (int j = 0; j < au.size(); ++j) {
			audio = au[j];
			for (int i = 1; i <= t; ++i) {
				if (movie[i][0] == audio) {
					int cnt = m[movie[i][1]];
					if (cnt > maxx) {
						maxx = cnt;
						index = i;
					}
				}
			}
		}
		cout << index << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		int tot = m.begin()->second;
		vector<int> au;
		au.push_back(audio);
		map<int, int>::iterator it;
		for (it = ++m.begin(); it != m.end(); ++it) {
			if (it->second == tot) au.push_back(it->first);
			else break;
		}
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = -1;
		for (int j = 0; j < au.size(); ++j) {
			audio = au[j];
			for (int i = 1; i <= t; ++i) {
				if (movie[i][0] == audio) {
					int cnt = m[movie[i][1]];
					if (cnt > maxx) {
						maxx = cnt;
						index = i;
					}
				}
			}
		}
		cout << index << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		int tot = m.begin()->second;
		vector<int> au;
		au.push_back(audio);
		map<int, int>::iterator it;
		for (it = ++m.begin(); it != m.end(); ++it) {
			if (it->second == tot) au.push_back(it->first);
			else break;
		}
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = 0;

		for (int i = 1; i <= t; ++i) {
			for (int j = 0; j < au.size(); ++j) {
				audio = au[j];
				if (movie[i][0] == audio) {
					int cnt = m[movie[i][1]];
					if (cnt > maxx) {
						maxx = cnt;
						index = i;
					}
				}
			}
		}
		cout << index << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = 0;

		for (int i = 1; i <= t; ++i) {
			if (movie[i][0] == audio) {
				int cnt = movie[i][1];
				if (cnt > maxx) {
					maxx = cnt;
					index = i;
				}
			}
		}
		cout << index << endl;
	}

	return 0;
}


#include<iostream>
#include<memory.h>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<limits.h>
#include<functional>
#include<map>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

const int maxn = 200005;
const int maxp = 1e9 + 5;
int movie[maxn][2];

map<int, int> m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while (cin >> n) {
		m.clear();
		for (int i = 0; i < n; ++i) {
			int temp;
			cin >> temp;
			m[temp]++;
		}

		int audio = m.begin()->first;
		int tot = m.begin()->second;
		vector<int> au;
		au.push_back(audio);
		map<int, int>::iterator it;
		for (it = ++m.begin(); it != m.end(); ++it) {
			if (it->second == tot) au.push_back(it->first);
			else if (it->second > tot) {
				au.clear();
				tot = it->second;
				au.push_back(it->first);
			}
		}
		//cout << audio << endl;

		int t;
		cin >> t;
		for (int i = 1; i <= t; ++i)
			cin >> movie[i][0];

		for (int i = 1; i <= t; ++i)
			cin >> movie[i][1];

		int index = 1;
		int maxx = -1;
		for (int j = 0; j < au.size(); ++j) {
			audio = au[j];
			for (int i = 1; i <= t; ++i) {
				if (movie[i][0] == audio) {
					int cnt = m[movie[i][1]];
					if (cnt > maxx) {
						maxx = cnt;
						index = i;
					}
				}
			}
		}
		if (maxx == -1) {
			for (int i = 1; i <= t; ++i) {
				int cnt = m[movie[i][1]];
				if (cnt > maxx) {
					maxx = cnt;
					index = i;
				}
			}
		}

		cout << index << endl;
	}

	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	int x = 0;
	int mark;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 3;
			if (a[j] == b[i].subtitle) b[i].weight++;
			if (b[i].weight>x){
				x = b[i].weight;
				mark = i + 1;
			}
		}
	}
	return 0;
}


#include <map>
#include <iostream>
using namespace std;
int main(){
	int n, m, a[200000], audio, subtitle, sum, max = -1, ans = 0;
	map<int, int> num;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> m; num[m]++;
	}
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++){
		audio = num[a[i]];
		cin >> m;
		subtitle = num[m];
		if ((audio>max) || ((audio == max) && (audio + subtitle>sum))) {
			ans = i + 1;
			sum = audio + subtitle;
			max = audio;
		}
	}
	cout << ans;
	return 0;
}


#include <map>
#include <iostream>
using namespace std;
int main(){
	int n, m, a[100000], audio, subtitle, sum, max = -1, ans = 0;
	map<int, int> num;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> m; num[m]++;
	}
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++){
		audio = num[a[i]];
		cin >> m;
		subtitle = num[m];
		if ((audio>max) || ((audio == max) && (audio + subtitle>sum))) {
			ans = i + 1;
			sum = audio + subtitle;
			max = audio;
		}
	}
	cout << ans;
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 2;
			if (a[j] == b[i].subtitle) b[i].weight++;
		}
	}
	int x = b[0].weight;
	for (int i = 0; i < m; i++){
		if (b[i].weight>x) x = b[i].weight;
	}
	for (int i = 0; i < m; i++){
		if (x == b[i].weight) cout << i + 1;
	}
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	int x = 0;
	int mark;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 3;
			if (a[j] == b[i].subtitle) b[i].weight++;
			if (b[i].weight>x){
				x = b[i].weight;
				mark = i + 1;
			}
		}
	}
	if (mark == 0) cout << 1;
	else cout << mark;
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 3;
			if (a[j] == b[i].subtitle) b[i].weight++;
		}
	}
	int x = b[0].weight;
	for (int i = 0; i < m; i++){
		if (b[i].weight>x) x = b[i].weight;
	}
	for (int i = 0; i < m; i++){
		if (x == b[i].weight){
			cout << i + 1;
			break;
		}
	}
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 2;
			if (a[j] == b[i].subtitle) b[i].weight++;
		}
	}
	int x = b[0].weight;
	for (int i = 0; i < m; i++){
		if (b[i].weight>x) x = b[i].weight;
	}
	for (int i = 0; i < m; i++){
		if (x == b[i].weight){
			cout << i + 1;
			break;
		}
	}
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	int x = 0;
	int mark;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 3;
			if (a[j] == b[i].subtitle) b[i].weight++;
			if (b[i].weight>x){
				x = b[i].weight;
				mark = i + 1;
			}
		}
	}
	cout << mark;
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	int x = 0;
	int mark;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 3;
			if (a[j] == b[i].subtitle) b[i].weight++;
			if (b[i].weight>x){
				x = b[i].weight;
				mark = i + 1;
			}
		}
	}
	if (mark == 0) cout << 1;
	cout << mark;
	return 0;
}


#include <iostream>
using namespace std;
typedef struct movie{
	int audio;
	int subtitle;
	int weight;
}*Movie;
int main(){
	int n, m;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	movie *b = new movie[m];
	for (int i = 0; i < m; i++){
		cin >> b[i].audio;
		b[i].weight = 0;
	}
	for (int i = 0; i < m; i++)
		cin >> b[i].subtitle;
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			if (a[j] == b[i].audio) b[i].weight += 2;
			if (a[j] == b[i].subtitle) b[i].weight++;
		}
	}
	int x = b[0].weight;
	for (int i = 0; i < m; i++){
		if (b[i].weight>x) x = b[i].weight;
	}
	for (int i = 0; i < m; i++){
		if (x == b[i].weight) cout << i + 1;
		break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	int n, m;
	cin >> n;
	map<int,int> uchs;

	for (int i = 0; i < n;i++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			(uchs.at(x))++;
		}
		else
			uchs.insert(pair<int, int>(x, 1));
	}
	cin >> m;
	vector<int> films;
	films.reserve(m);
	int max = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			if (uchs.at(x)>max){
				films.clear();
				max = uchs.at(x);
				films.push_back(j);
			}
			else if (uchs.at(x) == max){
				films.push_back(j);
			}
		}
		else if (max == 0){
			films.push_back(j);
		}
	}
	int kinco = films[0] + 1;
	int newmax=0;
	int r = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (films[r] == j){
			r++;
			if (uchs.find(x) != uchs.end()){
				if (uchs.find(x)->second>newmax){
					kinco = j + 1;
					newmax = uchs.find(x)->second;
				}
			}
			if (r == films.size())
				break;
		}
	}
	cout << kinco;
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	int n, m;
	cin >> n;
	map<int,int> uchs;
	vector<int> films;
	for (int i = 0; i < n;i++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			(uchs.find(x)->second)++;
		}
		else
			uchs.insert(pair<int, int>(x, 1));
	}
	cin >> m;
	int max = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			if (uchs.find(x)->second>max){
				films.clear();
				max = uchs.find(x)->second;
				films.push_back(j);
			}
			else if (uchs.find(x)->second == max){
				films.push_back(j);
			}
		}
	}
	int kinco = films[0] + 1;
	int newmax=0;
	int r = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (films[r] == j){
			r++;
			if (uchs.find(x) != uchs.end()){
				if (uchs.find(x)->second>newmax){
					kinco = j + 1;
					newmax = uchs.find(x)->second;
				}
			}
			if (r == films.size())
				break;
		}
	}
	cout << kinco;
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	int n, m;
	cin >> n;
	map<int,int> uchs;
	vector<int> films;
	for (int i = 0; i < n;i++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			(uchs.find(x)->second)++;
		}
		else
			uchs.insert(pair<int, int>(x, 1));
	}
	cin >> m;
	int max = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			if (uchs.find(x)->second>max){
				films.clear();
				max = uchs.find(x)->second;
				films.push_back(j);
			}
			else if (uchs.find(x)->second == max){
				films.push_back(j);
			}
		}
	}
	int kinco = films[0] + 1;
	int newmax=0;
	int r = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (films[r] == j){
			r++;
			if (uchs.find(x) != uchs.end()){
				if (uchs.find(x)->second>newmax){
					kinco = j + 1;
					newmax = uchs.find(x)->second;
				}
			}
			if (r = films.size())
				break;
		}
	}
	cout << kinco;
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
int main()
{
	int n, m;
	cin >> n;
	map<int,int> uchs;

	for (int i = 0; i < n;i++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			(uchs.at(x))++;
		}
		else
			uchs.insert(pair<int, int>(x, 1));
	}
	cin >> m;
	vector<int> films;
	films.reserve(m);
	int max = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (uchs.find(x) != uchs.end()){
			if (uchs.find(x)->second>max){
				films.clear();
				max = uchs.find(x)->second;
				films.push_back(j);
			}
			else if (uchs.find(x)->second == max){
				films.push_back(j);
			}
		}
	}
	int kinco = films[0] + 1;
	int newmax=0;
	int r = 0;
	for (int j = 0; j < m; j++){
		int x; cin >> x;
		if (films[r] == j){
			r++;
			if (uchs.find(x) != uchs.end()){
				if (uchs.find(x)->second>newmax){
					kinco = j + 1;
					newmax = uchs.find(x)->second;
				}
			}
			if (r == films.size())
				break;
		}
	}
	cout << kinco;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cstdint>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
map<int, int> a;
pair<int, int> b[300000] = {};
int main() {
	int n;
	scanf("%d", &n);
	REP(i, n) {
		int aa;
		scanf("%d", &aa);
		a[aa]++;
	}
	int m;
	scanf("%d", &m);
	REP(i, m) {
		scanf("%d", &b[i].first);
	}
	REP(i, m) {
		scanf("%d", &b[i].second);
	}
	int ans_max = -1;
	int ans_now = -1;
	for (int i = 0;i < m;++i) {
		if (ans_now < a[b[i].first] + a[b[i].second]) {
			ans_max = i + 1;
			ans_now = a[b[i].first] + a[b[i].second];
		}
	}
	cout << ans_max << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cstdint>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
map<int, int> a;
pair<int, int> b[300000] = {};
int main() {
	int n;
	scanf("%d", &n);
	REP(i, n) {
		int aa;
		scanf("%d", &aa);
		a[aa]++;
	}
	int m;
	scanf("%d", &m);
	REP(i, m) {
		scanf("%d", &b[i].first);
	}
	REP(i, m) {
		scanf("%d", &b[i].second);
	}
	int ans_now = -1;
	for (int i = 0;i < m;++i) {
		if (ans_now < a[b[i].first]) {
			ans_now = a[b[i].first];
		}
	}
	int final_ans = -1;
	int ans_nowmax = -1;
	for (int i = 0; i < m;++i) {
		if (ans_now == a[b[i].first]) {
			if (ans_nowmax < a[b[i].second]) {
				ans_nowmax = a[b[i].second];
				final_ans = i + 1;
			}
		}
	}
	cout << final_ans << endl;
}


//
// Created by Acka on 5/6/16.
//

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <memory.h>
using namespace std;

int size;

bool myfunction(int i, int j){
    return i == j;
}

int get_idx(vector<int> &v, int x){
    int l = 0, r = size - 1, m;
    while(l <= r){
        m = (l + r) / 2;
        if(v[m] == x) return m;
        else if(v[m] < x) l = m + 1;
        else r = m - 1;
    }
    return -1;
}

int main()
{
    int N; scanf("%d", &N);
    int a[200000];
    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &v[i]);
        a[i] = v[i];
    }
    sort(v.begin(), v.end());
    vector<int>::iterator it;
    it = unique(v.begin(), v.end());
    v.resize(distance(v.begin(), it));
    unique(v.begin(), v.end(), myfunction);

    size = v.size();

    vector<int> cnt(size, 0);
    for(int i = 0; i < N; i++) {
        cnt[get_idx(v, a[i])]++;
    }

    int M; scanf("%d", &M);
    int b[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &b[i]);
    int c[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &c[i]);

    long long int sum = 0, ans = -1;
    for(int i = 0; i < M; i++){
        int idx1 = get_idx(v, b[i]), idx2 = get_idx(v, c[i]);
        long long int val = 0;
        if(0 <= idx1) val += cnt[idx1] * 1000000000L;
        if(0 <= idx2) val += cnt[idx2];
        if(sum <= val){
            sum = val; ans = i + 1;
        }
    }

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


//
// Created by Acka on 5/6/16.
//

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <memory.h>
using namespace std;

int size;

bool myfunction(int i, int j){
    return i == j;
}

int get_idx(vector<int> &v, int x){
    int l = 0, r = size - 1, m;
    while(l <= r){
        m = (l + r) / 2;
        if(v[m] == x) return m;
        else if(v[m] < x) l = m + 1;
        else r = m - 1;
    }
    return -1;
}

int main()
{
    int N; scanf("%d", &N);
    int a[200000];
    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &v[i]);
        a[i] = v[i];
    }
    sort(v.begin(), v.end());
    vector<int>::iterator it;
    it = unique(v.begin(), v.end());
    v.resize(distance(v.begin(), it));
    unique(v.begin(), v.end(), myfunction);

    size = v.size();

    vector<int> cnt(size, 0);
    for(int i = 0; i < N; i++) {
        cnt[get_idx(v, a[i])]++;
    }

    int M; scanf("%d", &M);
    int b[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &b[i]);
    int c[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &c[i]);

    long long int sum = 0, ans = -1;
    for(int i = 0; i < M; i++){
        int idx1 = get_idx(v, b[i]), idx2 = get_idx(v, c[i]);
        long long int val = 0;
        if(0 <= idx1) val += cnt[idx1] * 1000000000L;
        if(0 <= idx2) val += cnt[idx2];
        if(sum < val){
            sum = val; ans = i + 1;
        }
    }

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


//
// Created by Acka on 5/6/16.
//

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <memory.h>
using namespace std;

int size;

bool myfunction(int i, int j){
    return i == j;
}

int get_idx(vector<int> &v, int x){
    int l = 0, r = size - 1, m;
    while(l <= r){
        m = (l + r) / 2;
        if(v[m] == x) return m;
        else if(v[m] < x) l = m + 1;
        else r = m - 1;
    }
    return -1;
}

int main()
{
    int N; scanf("%d", &N);
    int a[200000];
    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &v[i]);
        a[i] = v[i];
    }
    sort(v.begin(), v.end());
    vector<int>::iterator it;
    it = unique(v.begin(), v.end());
    v.resize(distance(v.begin(), it));
    unique(v.begin(), v.end(), myfunction);

    size = v.size();

    vector<int> cnt(size, 0);
    for(int i = 0; i < N; i++) {
        cnt[get_idx(v, a[i])]++;
    }

    int M; scanf("%d", &M);
    int b[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &b[i]);
    int c[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &c[i]);

    int max1 = 0, max2 = 0, ans = -1;
    for(int i = 0; i < M; i++){
        int idx1 = get_idx(v, b[i]), idx2 = get_idx(v, c[i]);
        int m1 = (0 <= idx1 ? cnt[idx1] : -1), m2 = (0 <= idx2 ? cnt[idx2] : - 1);
        if((max1 == m1 && max2 <= m2) || max1 < m1){
           max1 = m1; max2 = m2; ans = i + 1;
        }
    }

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


//
// Created by Acka on 5/6/16.
//

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <memory.h>
using namespace std;

int size;

bool myfunction(int i, int j){
    return i == j;
}

int get_idx(vector<int> &v, int x){
    int l = 0, r = size - 1, m;
    while(l < r){
        m = (l + r) / 2;
        if(v[m] == x) return m;
        else if(v[m] < x) l = m + 1;
        else r = m - 1;
    }
    return -1;
}

int main()
{
    int N; scanf("%d", &N);
    int a[200000];
    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &v[i]);
        a[i] = v[i];
    }

    vector<int>::iterator it;
    it = unique(v.begin(), v.end());
    v.resize(distance(v.begin(), it));
    sort(v.begin(), v.end());
    size = v.size();

    vector<int> cnt(size, 0);
    for(int i = 0; i < N; i++)
        cnt[get_idx(v, a[i])]++;

    int M; scanf("%d", &M);
    int b[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &b[i]);
    int c[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &c[i]);

    long long int sum = 0, ans = -1;
    for(int i = 0; i < M; i++){
        int idx1 = get_idx(v, b[i]), idx2 = get_idx(v, c[i]);
        long long int val = 0;
        if(0 <= idx1) val += cnt[idx1] * 1000000000L;
        if(0 <= idx2) val += cnt[idx2];
        if(sum < val){
            sum = val; ans = i + 1;
        }
    }

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


//
// Created by Acka on 5/6/16.
//

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <memory.h>
using namespace std;

int size;

bool myfunction(int i, int j){
    return i == j;
}

int get_idx(vector<int> &v, int x){
    int l = 0, r = size - 1, m;
    while(l <= r){
        m = (l + r) / 2;
        if(v[m] == x) return m;
        else if(v[m] < x) l = m + 1;
        else r = m - 1;
    }
    return -1;
}

int main()
{
    int N; scanf("%d", &N);
    int a[200000];
    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &v[i]);
        a[i] = v[i];
    }
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());

    size = v.size();

    vector<int> cnt(size, 0);
    for(int i = 0; i < N; i++) {
        cnt[get_idx(v, a[i])]++;
    }

    int M; scanf("%d", &M);
    int b[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &b[i]);
    int c[200000];
    for(int i = 0; i < M; i++)
        scanf("%d", &c[i]);

    int max1 = -1, max2 = -1, ans = 0;
    for(int i = 0; i < M; i++){
        int idx1 = get_idx(v, b[i]), idx2 = get_idx(v, c[i]);
        int m1 = (0 <= idx1 ? cnt[idx1] : -1), m2 = (0 <= idx2 ? cnt[idx2] : - 1);
        if((max1 == m1 && max2 <= m2) || max1 < m1){
           max1 = m1; max2 = m2; ans = i + 1;
        }
    }

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


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <locale>
#include <bitset>
#pragma comment(linker, "/STACK:2560000000000")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define MP make_pair
#define eps 1e-20
#define INF 1e9
const int MAXN = 1e5 + 13;
using namespace std;
map <int,int> mp;
int main(){
	int n,m,a[MAXN],b[MAXN],c[MAXN];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		mp[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 ans,ansz=0,ansc=0;
	for(int i=1;i<=m;i++){
		if(mp[b[i]]>ansz){
			ans=i;
			ansz=mp[b[i]];
			ansc=mp[c[i]];
		}
		if(mp[b[i]]==ansz&&mp[c[i]]>ansc){
			ans=i;
			ansc=mp[c[i]];
		}
	}
	cout<<ans;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <locale>
#include <bitset>
#pragma comment(linker, "/STACK:2560000000000")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define MP make_pair
#define eps 1e-20
#define INF 1e9
const int MAXN = 2e5 + 13;
using namespace std;
map <int,int> mp;
int main(){
	int n,m,a[MAXN],b[MAXN],c[MAXN];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		mp[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 ans,ansz=0,ansc=0;
	for(int i=1;i<=m;i++){
		if(mp[b[i]]>ansz){
			ans=i;
			ansz=mp[b[i]];
			ansc=mp[c[i]];
		}
		if(mp[b[i]]==ansz&&mp[c[i]]>ansc){
			ans=i;
			ansc=mp[c[i]];
		}
	}
	cout<<ans;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int n,m,au[200010],su[200010];
map<int,int> s;
vector<int> idx;
int main() {
//	freopen("f.txt","r",stdin);
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s[a]++;
	}
	cin >> m;
	idx.push_back(0);
	for(int i = 0; i < m; i++) {
		cin >> au[i];
		if(s[au[i]] > s[au[idx[0]]]) {
			idx.clear();
			idx.push_back(i);
		}
		else
			if(s[au[i]] == s[au[idx[0]]] && i > 0)
				idx.push_back(i);
	/*	if(s.find(au[i]) != s.end()) {
			if(idx.size() > 0 && s[au[i]] > s[au[idx[0]]]) {
				idx.clear();
				idx.push_back(i);
			}
		}
		else
			if(idx.size() > 0 && s[au[idx[0]]] == 0)
				idx.push_back(i);
			else
				if(idx.size() == 0)
					idx.push_back(i);*/
	}
	for(int i = 0; i < m; i++)
		cin >> su[i];
	int q = idx[0];
	for(int i = 1; i < idx.size(); i++) {
		if(s[su[idx[i]]] > s[su[q]]) {
			q = idx[i];
		}
	}
	cout << q + 1<< '\n';

	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int n,m,au[200010],su[200010];
map<int,int> s;
vector<int> idx;
int main() {
	//freopen("f.txt","r",stdin);
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s[a]++;
	}
	cin >> m;
	for(int i = 0; i < m; i++) {
		cin >> au[i];
		if(s.find(au[i]) != s.end()) {
			if(idx.size() > 0 && s[au[i]] > s[au[*idx.begin()]]) {
				idx.clear();
				idx.push_back(i);
			}
			else
				idx.push_back(i);

		}
	}
	for(int i = 0; i < m; i++)
		cin >> su[i];
	int q = idx[0];
	for(int i = 1; i < idx.size(); i++) {
		if(s[su[idx[i]]] > s[su[q]]) {
			q = idx[i];
		}
	}
	cout << q + 1<< '\n';

	return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;
int n,m,au[200010],su[200010];
map<int,int> s;
vector<int> idx;
int main() {
	//freopen("f.txt","r",stdin);
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s[a]++;
	}
	cin >> m;
	for(int i = 0; i < m; i++) {
		cin >> au[i];
		if(s.find(au[i]) != s.end()) {
			if(idx.size() > 0 && s[au[i]] > s[au[*idx.begin()]]) {
				idx.clear();
				idx.push_back(i);
			}
			else
				idx.push_back(i);

		}
		else
			if(idx.size() > 0 && s[au[idx[0]]] == 0)
				idx.push_back(i);
			else
				if(idx.size() == 0)
					idx.push_back(i);
	}
	for(int i = 0; i < m; i++)
		cin >> su[i];
	int q = idx[0];
	for(int i = 1; i < idx.size(); i++) {
		if(s[su[idx[i]]] > s[su[q]]) {
			q = idx[i];
		}
	}
	cout << q + 1<< '\n';

	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;

int ans[200001],sist[200001],sub[200001],audi[200001];

int search(int arr[],int x,int len)
{
    int lo=0,hi=len-1;
    while(lo<=hi)
    {
        int mid=(lo+hi)/2;
        if(arr[mid]>x)
            hi=mid-1;
        else if(arr[mid]<x)
            lo=mid+1;
        else
            return mid;
    }
    return -1;
}
int main()
{
    int n,i,j=0,m,sum=0,max=-1;
        scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&sist[i]);
    scanf("%d",&m);
    for(i=0;i<m;i++)
        scanf("%d",&audi[i]);
    for(i=0;i<m;i++)
        scanf("%d",&sub[i]);
    sort(sist,sist+n);
    for(i=0;i<m;i++)
    {
        sum=0;
        int idx=search(sist,audi[i],n);
        if(idx==-1)
            continue;
        int temp=idx;
        while(sist[temp]==audi[i])
        {
            temp--;
            sum++;
            if(temp==-1)
                break;
        }
        temp=idx+1;
        while(sist[temp]==audi[i])
        {
            temp++;
            sum++;
            if(temp==n)
                break;
        }
        if(max<sum)
        {
            max=sum;
            ans[j]=i;
        }
        else if(max==sum)
        {
            ans[++j]=i;
        }
    }
    int must=ans[0];
    max=-1;
    if(j==0)
    {
        printf("%d",ans[0]+1);
        return 0;
    }
    else
    {
        for(int k=0;k<=j;k++)
        {
            i=ans[k];
            sum=0;
            int idx=search(sist,sub[i],n);
            if(idx==-1)continue;
            int temp=idx;
            while(sist[temp]==sub[i])
            {
                temp--;
                sum++;
            }
            temp=idx+1;
            while(sist[temp]==sub[i])
            {
                temp++;
                sum++;
            }
            if(max<sum)
            {
                max=sum;
                must=i;
            }

        }
    }
    printf("%d",must+1);
}


#include <stdio.h>
#include <algorithm>
using namespace std;

struct movie
{
	int cntS;
	int cntA;
	int sub;
	int audio;
	bool operator<(const movie &a)
	{
		if (a.cntA == cntA) return cntS<a.cntS;
		return cntA < a.cntA;
	}
};

int lang[200010];

movie M[200010];

int main()
{
	int n,m,tmp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &tmp);
		lang[tmp]++;
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		M[i].audio = tmp;
		M[i].cntA = lang[tmp];
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		M[i].sub = tmp;
		M[i].cntS = lang[tmp];
	}
	sort(M , M+m);
	printf("%d", M[m-1].audio);

}


#include <stdio.h>
#include <map>
#include <algorithm>
using namespace std;

struct movie
{
	int cntS;
	int cntA;
	int idx;
	bool operator<(const movie &a)
	{
		if (a.cntA == cntA) return cntS<a.cntS;
		return cntA < a.cntA;
	}
};
map<int, int> lang;

movie M[200010];

int main()
{
	int n,m,tmp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &tmp);
		lang[tmp]++;
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		M[i].idx = i+1;
		M[i].cntA = lang[tmp];
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		M[i].cntS = lang[tmp];
	}
	sort(M , M+m);
	printf("%d", M[m-1].idx);

}


#include <stdio.h>
#include <algorithm>
using namespace std;

struct movie
{
	int cntS;
	int cntA;
	int idx;
	bool operator<(const movie &a)
	{
		if (a.cntA == cntA) return cntS<a.cntS;
		return cntA < a.cntA;
	}
};

int lang[200010];

movie M[200010];

int main()
{
	int n,m,tmp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &tmp);
		lang[tmp]++;
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		M[i].idx = i+1;
		M[i].cntA = lang[tmp];
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		M[i].cntS = lang[tmp];
	}
	sort(M , M+m);
	printf("%d", M[m-1].idx);

}


//In the name of God:)
#include <iostream>
using namespace std;
long long m, n, A[200000], B[200000], C[200000], P[200000], S[200000], Sma, Pma, J;
int main()
{
    cin>> n;
    for (int i=1; i<=n; i++)
        cin>> A[i];
    cin>> m;
    for (int i=1; i<=m; i++)
        cin>> B[i];
    for (int i=1; i<=m; i++)
        cin>> C[i];
    for (int j=1; j<=m; j++)
    {
        for (int i=1; i<=n; i++)
        {
            if (A[i]==B[j])
                P[j]++;
            if (A[i]==C[j])
                S[j]++;
        }
    }
    for (int j=1; j<=m; j++)
    {
        if (P[j]>Pma)
        {
            Pma=P[j];
            Sma=S[j];
            J=j;
        }
        if (P[j]==Pma && S[j]>Sma)
        {
            Sma=S[j];
            J=j;
        }
    }
    cout<< J;
    return 0;
}


//In the name of God:)
#include <iostream>
using namespace std;
long long m, n, A[200002], B[200002], C[200002], P[200002], S[200002], Sma, Pma, J;
int main()
{
    cin>> n;
    for (int i=1; i<=n; i++)
        cin>> A[i];
    cin>> m;
    for (int i=1; i<=m; i++)
        cin>> B[i];
    for (int i=1; i<=m; i++)
        cin>> C[i];
    for (int j=1; j<=m; j++)
    {
        for (int i=1; i<=n; i++)
        {
            if (A[i]==B[j])
                P[j]++;
            if (A[i]==C[j])
                S[j]++;
        }
    }
    for (int j=1; j<=m; j++)
    {
        if (P[j]>Pma)
        {
            Pma=P[j];
            Sma=S[j];
            //cout<< j<< ' '<< Pma<< ' '<< Sma<< endl;
            J=j;
            continue;
        }
        if (P[j]==Pma && S[j]>Sma)
        {
            Sma=S[j];
            J=j;
        }
    }
    cout<< (J!=0 ? J : 1);
    return 0;
}


//In the name of God:)
#include <iostream>
using namespace std;
long long m, n, A[200002], B[200002], C[200002], P[200002], S[200002], Sma, Pma, J;
int main()
{
    cin>> n;
    for (int i=1; i<=n; i++)
        cin>> A[i];
    cin>> m;
    for (int i=1; i<=m; i++)
        cin>> B[i];
    for (int i=1; i<=m; i++)
        cin>> C[i];
    for (int j=1; j<=m; j++)
    {
        for (int i=1; i<=n; i++)
        {
            if (A[i]==B[j])
                P[j]++;
            if (A[i]==C[j])
                S[j]++;
        }
    }
    for (int j=1; j<=m; j++)
    {
        if (P[j]>Pma)
        {
            Pma=P[j];
            Sma=S[j];
            J=j;
            continue;
        }
        if (P[j]==Pma && S[j]>Sma)
        {
            Sma=S[j];
            J=j;
        }
    }
    cout<< J;
    return 0;
}


//In the name of God:)
#include <iostream>
using namespace std;
long long m, n, A[200002], B[200002], C[200002], P[200002], S[200002], Sma, Pma, J;
int main()
{
    cin>> n;
    for (int i=1; i<=n; i++)
        cin>> A[i];
    cin>> m;
    for (int i=1; i<=m; i++)
        cin>> B[i];
    for (int i=1; i<=m; i++)
        cin>> C[i];
    for (int j=1; j<=m; j++)
    {
        for (int i=1; i<=n; i++)
        {
            if (A[i]==B[j])
                P[j]++;
            if (A[i]==C[j])
                S[j]++;
        }
    }
    for (int j=1; j<=m; j++)
    {
        if (P[j]>=Pma)
        {
            Pma=P[j];
            Sma=S[j];
            J=j;
            continue;
        }
        if (P[j]==Pma && S[j]>=Sma)
        {
            Sma=S[j];
            J=j;
        }
    }
    cout<< J;
    return 0;
}


//In the name of God:)
#include <iostream>
using namespace std;
int m, n, A[200000], B[200000], C[200000], P[200000], S[200000], Sma, Pma, J;
int main()
{
    cin>> n;
    for (int i=1; i<=n; i++)
        cin>> A[i];
    cin>> m;
    for (int i=1; i<=m; i++)
        cin>> B[i];
    for (int i=1; i<=m; i++)
        cin>> C[i];
    for (int j=1; j<=m; j++)
    {
        for (int i=1; i<=n; i++)
        {
            if (A[i]==B[j])
                P[j]++;
            if (A[i]==C[j])
                S[j]++;
        }
    }
    for (int j=1; j<=m; j++)
    {
        if (P[j]>Pma)
        {
            Pma=P[j];
            Sma=S[j];
            J=j;
        }
        if (P[j]==Pma && S[j]>Sma)
        {
            Sma=S[j];
            J=j;
        }
    }
    cout<< J;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int a[200001], b[200001];
map<int, int>oo;
int main()
{
	int n, i, m, j, k, l, z ;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		scanf("%d", &l);
		if(!oo.count(l))
		oo[l] = 0;
		oo[l]++;
	}
	cin >> m;
	for(j = 1; j <= m; j++)
	scanf("%d", &a[i]);
	for(j = 1; j <= m; j++)
	scanf("%d", &b[i]);
	l = 1;
	k = 0;
	for(i = 1; i <= m; i++)
	{
		z = 0;
		if(!oo.count(a[i]))
		z+=0;
		else
		z+=oo[a[i]];
		if(!oo.count(b[i]))
		z+=0;
		else
		z+=oo[b[i]];
		if(z > k)
		{
			k = z;
			l = i;
		}
	}
	cout << l << endl;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200000];
struct node{
	int b, x;
};
node st[200000];
bool cmp(node A, node B)
{
	return A.b < B.b;
}
int main()
{
	int n, m, i, j, k, l, z, y;
	cin >> n;
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	cin >> m;
	for(i = 0; i < m; i++)
	{
	scanf("%d", &st[i].b);
	st[i].x = i+1;}
	sort(a, a+n);
	sort(st, st+m, cmp);
	for(i = 1; i <= m; i++)
	scanf("%d", &l);
	l = i = j = 0;
	z = 1;
	while(i<n && j<m)
	{
		if(a[i] == st[j].b)
		{
			k = 1;
			for(i=i+1; i < n; i++)
			if(a[i] == a[i-1])
			k++;
			else
			break;
			if(k > l)
				{
					z = st[j].x;
					l = k;
				}
		}
		else if(a[i] < st[j].b)
		i++;
		else if(a[i] > st[j].b)
		j++;
	}
	cout << z << endl;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200000];
struct node{
	int b, x;
};
node st[200000];
bool cmp(node A, node B)
{
	return A.b < B.b;
}
int main()
{
	int n, m, i, j, k, l, z, y;
	cin >> n;
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	cin >> m;
	for(i = 0; i < m; i++)
	{
	scanf("%d", &st[i].b);
	st[i].x = i+1;}
	sort(a, a+n);
	sort(st, st+m, cmp);
	for(i = 1; i <= m; i++)
	scanf("%d", &l);
	l = i = j = 0;
	z = 1;
	while(i<n || j<m)
	{
		if(a[i] == st[j].b)
		{
			k = 1;
			for(i=i+1; i < n; i++)
			if(a[i] == a[i-1])
			k++;
			else
			break;
			if(k > l)
				{
					z = st[j].x;
					l = k;
				}
		}
		else if(a[i] < st[j].b)
		i++;
		else if(a[i] > st[j].b)
		j++;
	}
	cout << z << endl;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int a[200001], b[200001];
map<int, int>oo;
int main()
{
	int n, i, m, j, k, l, z , x, y;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		scanf("%d", &l);
		if(!oo.count(l))
		oo[l] = 0;
		oo[l]++;
	}
	cin >> m;
	for(j = 1; j <= m; j++)
	scanf("%d", &a[j]);
	for(j = 1; j <= m; j++)
	scanf("%d", &b[j]);
	l = 1;
	x = y = 0;
	for(i = 1; i <= m; i++)
	{
		z = 0;
		if(!oo.count(a[i]))
		z+=0;
		else
		z+=oo[a[i]];
		if(z > x)
		{
			l = i;
			x = z;
			if(!oo.count(b[i]))
			y = 0;
			else
			y = oo[b[i]];
			continue;
		}
		if(z == x)
		{
		z = 0;
		if(!oo.count(b[i]))
		z+=0;
		else
		z+=oo[b[i]];
		if(z > y)
		{
			y = z;
			l = i;
		}
		}
	}
	cout << l << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<pair<int, int>>vec_pair;
#define MP make_pair
#define oo 1e18
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
void ff()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

//#pragma warning (disable : 4996)
void in_out_txt()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main()
{
	ff();
	//in_out_txt();
	int n, m, x, y;
	cin >> n >> m;
	x = n, y = m;
	string str = "";
	while (n > 0)
	{
		str += '0';
		n--;
		if (m == 0 && n > 0)
		{
			cout << -1 << endl;
			return 0;
		}
		if (m == 0)
			break;
		str += '1';
		m--;
	}
	string st = "";
	for (int i = 0; i < str.size(); i++)
	{
		st += str[i];
		i++;
		if (i == str.size())
			break;
		st += str[i];
		if (m != 0)
		{
			st += '1';
			m--;
		}
	}
	if (m == 0)
		cout << st << endl;
	else
	{
		if (st[st.size() - 1] == '0')
			x = 2;
		else if (st[st.size() - 1] == '1' && st[st.size() - 2] == '1')
			x = 0;
		else if (st[st.size() - 1] == '1')
			x = 1;
		if (m > 2 + x)
			cout << -1 << endl;
		else if (m == 1)
		{
			st = '1' + st;
			cout << st << endl;
		}
		else if (m == 2)
		{
			st = "11" + st;
			cout << st << endl;
		}
		else if (m == 3)
		{
			st = "11" + st + '1';
			cout << st << endl;
		}
		else if (m == 3)
		{
			st = "11" + st + "11";
			cout << st << endl;
		}
	}
//	system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<pair<int, int>>vec_pair;
#define MP make_pair
#define oo 1e18
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
void ff()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

//#pragma warning (disable : 4996)
void in_out_txt()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}
pair<ll, ll>pr[2 * 100000];
int main()
{
	ff();
	//in_out_txt();
	int n, m, pleased = 0, satis = 0;
	cin >> n;
	vl vec(n);
	map<ll, int>mp;
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
		mp[vec[i]]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> pr[i].first;
	for (int i = 0; i < m; i++)
		cin >> pr[i].second;
	pleased = pr[0].first, satis = pr[0].second;
	for (int i = 1; i < m; i++)
	{
		if (mp[pr[i].first] > mp[pleased])
			pleased = pr[i].first, satis = pr[i].second;
		else if (mp[pr[i].first] == mp[pleased] && mp[satis] > mp[pr[i].second])
			pleased = pr[i].first, satis = pr[i].second;
	}
	cout << pleased << endl;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<pair<int, int>>vec_pair;
#define MP make_pair
#define oo 1e18
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
void ff()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

//#pragma warning (disable : 4996)
void in_out_txt()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}
pair<ll, ll>pr[2 * 100000];
int main()
{
	ff();
	//in_out_txt();
	int n, m, pleased = 0, satis = 0;
	cin >> n;
	vl vec(n);
	map<ll, int>mp;
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
		mp[vec[i]]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> pr[i].first;
	for (int i = 0; i < m; i++)
		cin >> pr[i].second;
	int in = 1;
	pleased = pr[0].first, satis = pr[0].second;
	for (int i = 1; i < m; i++)
	{
		if (mp[pr[i].first] > mp[pleased])
			pleased = pr[i].first, satis = pr[i].second, in = 1 + 1;
		else if (mp[pr[i].first] == mp[pleased] && mp[satis] > mp[pr[i].second])
			pleased = pr[i].first, satis = pr[i].second, in = i + 1;
	}
	cout << in << endl;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<pair<int, int>>vec_pair;
#define MP make_pair
#define oo 1e18
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
void ff()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

//#pragma warning (disable : 4996)
void in_out_txt()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}
pair<ll, ll>pr[2 * 100000];
int main()
{
	ff();
	//in_out_txt();
	int n, m, pleased = 0, satis = 0;
	cin >> n;
	vl vec(n);
	map<ll, int>mp;
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
		mp[vec[i]]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> pr[i].first;
	for (int i = 0; i < m; i++)
		cin >> pr[i].second;
	int in = 1;
	pleased = pr[0].first, satis = pr[0].second;
	for (int i = 1; i < m; i++)
	{
		if (mp[pr[i].first] > mp[pleased])
			pleased = pr[i].first, satis = pr[i].second, in = 1 + 1;
		else if (mp[pr[i].first] == mp[pleased] && mp[satis] < mp[pr[i].second])
			pleased = pr[i].first, satis = pr[i].second, in = i + 1;
	}
	cout << in << endl;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
typedef vector<pair<int, int>>vec_pair;
#define MP make_pair
#define oo 1e18
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
void ff()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

//#pragma warning (disable : 4996)
void in_out_txt()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}
pair<ll, ll>pr[2 * 100000];
int main()
{
	ff();
	//in_out_txt();
	int n, m, pleased = 0, satis = 0;
	cin >> n;
	vl vec(n);
	map<ll, int>mp;
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
		mp[vec[i]]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> pr[i].first;
	for (int i = 0; i < m; i++)
		cin >> pr[i].second;
	int in = 1;
	pleased = pr[0].first, satis = pr[0].second;
	for (int i = 1; i < m; i++)
	{
		if (mp[pr[i].first] > mp[pleased])
			pleased = pr[i].first, satis = pr[i].second, in = i + 1;
		else if (mp[pr[i].first] == mp[pleased] && mp[satis] < mp[pr[i].second])
			pleased = pr[i].first, satis = pr[i].second, in = i + 1;
	}
	cout << in << endl;
	//system("pause");
	return 0;
}


#include <map>
#include <stdio.h>
using namespace std;

long int film[200000][2];
int main(){
	map<long int, int> jezik;
	map<long int, int>::iterator itr;

	int N, index, jez, podn;
	long int j;
	scanf("%i", &N);
	for(int i=0; i<N; i++){
		scanf("%li", &j);
		itr = jezik.find(j);
		if(itr == jezik.end()){
			jezik.insert(pair<long int, int>(j, 1));
		}
		else itr->second ++;
	}
	//za filme
	scanf("%i", &N);
	jez = 0;
	podn = 0;
	for(int y=0; y<2; y++){
		for(int i=0; i<N; i++){
			scanf("%li", &(film[i][y]));
		}
	}
	for(int i=0; i<N; i++){
		itr = jezik.find(film[i][0]);
		if(itr != jezik.end() && itr->second > jez){
			jez = itr->second;
			itr = jezik.find(film[i][1]);
			if(itr == jezik.end()) podn = 0;
			else podn = itr->second;
			index = i+1;
		}
		else if(itr != jezik.end() && itr->second == jez){
			itr = jezik.find(film[i][1]);
			if(itr != jezik.end() && itr->second > podn){
				podn = itr->second;
				index = i+1;
			}
		}
	}
	printf("%i", index);
	return 0;
}


#include <map>
#include <stdio.h>
using namespace std;

int main(){
	map<long int, int> jezik;
	map<long int, int>::iterator itr;

	int N, index, jez, podn;
	long int a, b;
	long int j;
	scanf("%i", &N);
	for(int i=0; i<N; i++){
		scanf("%li", &j);
		itr = jezik.find(j);
		if(itr == jezik.end()){
			jezik.insert(pair<long int, int>(j, 1));
		}
		else itr->second ++;
	}
	//za filme
	scanf("%i", &N);
	jez = 0;
	podn = 0;
	for(int i=1; i<=N; i++){
		scanf("%li%li", &a, &b);
		itr = jezik.find(a);
		if(itr != jezik.end() && itr->second > jez){
			jez = itr->second;
			itr = jezik.find(b);
			if(itr == jezik.end()) podn = 0;
			else podn = itr->second;
			index = i;
		}
		else if(itr != jezik.end() && itr->second == jez){
			itr = jezik.find(b);
			if(itr != jezik.end() && itr->second > podn){
				podn = itr->second;
				index = i;
			}
		}
	}
	printf("%i", index);
	return 0;
}


#include <map>
#include <stdio.h>
using namespace std;

long int film[200000][2];
int main(){
	map<long int, int> jezik;
	map<long int, int>::iterator itr;

	int N, index, jez, podn;
	index = 1;
	long int j;
	scanf("%i", &N);
	for(int i=0; i<N; i++){
		scanf("%li", &j);
		itr = jezik.find(j);
		if(itr == jezik.end()){
			jezik.insert(pair<long int, int>(j, 1));
		}
		else itr->second ++;
	}
	//za filme
	scanf("%i", &N);
	jez = 0;
	podn = 0;
	for(int y=0; y<2; y++){
		for(int i=0; i<N; i++){
			scanf("%li", &(film[i][y]));
		}
	}
	for(int i=0; i<N; i++){
		itr = jezik.find(film[i][0]);
		if(itr != jezik.end() && itr->second > jez){
			jez = itr->second;
			itr = jezik.find(film[i][1]);
			if(itr == jezik.end()) podn = 0;
			else podn = itr->second;
			index = i+1;
		}
		else if(itr != jezik.end() && itr->second == jez){
			itr = jezik.find(film[i][1]);
			if(itr != jezik.end() && itr->second > podn){
				podn = itr->second;
				index = i+1;
			}
		}
		else if(jez == 0){
			itr = jezik.find(film[i][1]);
			if(itr != jezik.end() && itr->second > podn){
				podn = itr->second;
				index = i+1;
			}
		}
	}
	printf("%i", index);
	return 0;
}


#include <map>
#include <stdio.h>
using namespace std;

long int film[200000][2];
int main(){
	map<long int, int> jezik;
	map<long int, int>::iterator itr;

	int N, index, jez, podn;
	long int j;
	scanf("%i", &N);
	for(int i=0; i<N; i++){
		scanf("%li", &j);
		itr = jezik.find(j);
		if(itr == jezik.end()){
			jezik.insert(pair<long int, int>(j, 1));
		}
		else itr->second ++;
	}
	//za filme
	scanf("%i", &N);
	jez = 0;
	podn = 0;
	for(int y=0; y<2; y++){
		for(int i=0; i<N; i++){
			scanf("%li", &(film[i][y]));
		}
	}
	for(int i=0; i<N; i++){
		itr = jezik.find(film[i][0]);
		if(itr != jezik.end() && itr->second > jez){
			jez = itr->second;
			itr = jezik.find(film[i][1]);
			if(itr == jezik.end()) podn = 0;
			else podn = itr->second;
			index = i+1;
		}
		else if(itr != jezik.end() && itr->second == jez){
			itr = jezik.find(film[i][1]);
			if(itr != jezik.end() && itr->second > podn){
				podn = itr->second;
				index = i+1;
			}
		}
		else if(jez == 0){
			itr = jezik.find(film[i][1]);
			if(itr != jezik.end() && itr->second > podn){
				podn = itr->second;
				index = i+1;
			}
		}
	}
	printf("%i", index);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#define ll long long
#define Fori(x) for(int i=0;i<x;i++)
using namespace std;
ll a[200010];
ll b[200010];
ll c[200010];
ll d[200010];

map<ll,ll> myMap;
int main()
{
	ll n,m;
	cin>>n;
	Fori(n)
		cin>>a[i];
	cin>>m;
	Fori(m)
	{
		cin>>b[i];
		myMap[b[i]] = 0;
	}
	Fori(m)
	{
		cin>>c[i];
		myMap[c[i]] = 0;
	}
	sort(a,a+n);
	ll nowN = 0;
	ll nowL = a[0];
	Fori(n)
	{
		if(a[i]!=nowL)
		{
			myMap[nowL] = nowN;
			nowL = a[i];
			nowN = 0;
		}
		nowN++;
		if(i==n-1)
			myMap[nowL] = nowN;
	}
	/*if(n==1)
		myMap[nowL] = nowN;
	for(int i=1;i<n;i++)
	{
		if(a[i]!=nowL)
		{
			myMap[nowL] = nowN;
			nowL = a[i];
			nowN = 1;
		}
		else
			nowN++;
		if(i==n-1)
			myMap[nowL] = nowN;
	}*/

	ll maxM = 0;
	Fori(m)
	{
		if(myMap[b[i]]>myMap[b[maxM]])
			maxM = i;
		else if(myMap[b[i]]==myMap[b[maxM]]&&myMap[c[i]]>myMap[c[maxM]])
			maxM = i;
	}
	cout<<maxM+1<<endl;
	//system("pause");
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#define ll long long
#define Fori(x) for(int i=0;i<x;i++)
using namespace std;
ll a[200010];
ll b[200010];
ll c[200010];
ll d[200010];

ll nowN = 1;
ll nowLN = 0;
ll nowMN = 0;
ll cMaxM = 0;
ll cMax;
map<ll,ll> myMap;
int main()
{
	ll n,m;
	cin>>n;
	Fori(n)
		cin>>a[i];
	cin>>m;
	Fori(m)
	{
		cin>>b[i];
		myMap[b[i]] = 0;
	}
	Fori(m)
	{
		cin>>c[i];
		myMap[c[i]] = 0;
	}
	sort(a,a+n);
	ll nowL = a[0];

	for(int i=1;i<n;i++)
	{
		if(a[i]!=nowL)
		{
			myMap[nowL] = nowN;
			nowL = a[i];
			nowN = 1;
		}
		else
			nowN++;
		if(i==n-1)
			myMap[nowL] = nowN;
	}

	ll maxM = 0;
	Fori(m)
	{
		if(myMap[b[i]]>myMap[b[maxM]])
			maxM = i;
		else if(myMap[b[i]]==myMap[b[maxM]]&&myMap[c[i]]>myMap[c[maxM]])
			maxM = i;
	}
	cout<<maxM+1<<endl;
	//system("pause");
}


#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#include<vector>
#include<set>
#define ll long long
#define Fori(x) for(int i=0;i<x;i++)
using namespace std;
ll a[200010];
ll b[200010];
ll c[200010];
ll d[200010];
typedef struct sa
{
	ll langu;
	ll num;
}sa;
sa sas[200010];
ll nowN = 1;
ll nowLN = 0;
ll nowMN = 0;
ll cMaxM = 0;
ll cMax;
bool cmp(sa a,sa b)
{
	return a.num>b.num;
}
ll find(ll a)
{
	ll Lan = c[d[a]];
	for(int i=0;i<nowLN;i++)
		if(sas[i].langu == Lan)
			return sas[i].num;
	return 0;
}
int main()
{
	ll n,m;
	cin>>n;
	Fori(n)
		cin>>a[i];
	cin>>m;
	Fori(m)
		cin>>b[i];
	Fori(m)
		cin>>c[i];
	sort(a,a+n);
	ll nowL = a[0];

	for(int i=1;i<n;i++)
	{
		if(a[i]!=nowL)
		{
			sas[nowLN].langu = nowL;
			sas[nowLN++].num = nowN;
			nowL = a[i];
			nowN = 1;
		}
		else
			nowN++;
		if(i==n-1)
		{
			sas[nowLN].langu = nowL;
			sas[nowLN++].num = nowN;
		}
	}
	sort(sas,sas+nowLN,cmp);

	for(int i=0;i<nowLN;i++)
	{
		for(int j=0;j<m;j++)
			if(b[j]==sas[i].langu)
				d[nowMN++] = j;
		if(nowMN>0)
			break;
	}
	if(nowMN==0)
	{
		for(int i=0;i<200010;i++)
			d[i] = i;
	}
	cMaxM = d[0];
	cMax = find(0);
	for(int i=1;i<nowMN;i++)
	{
		ll tmp = find(i);
		if(tmp>cMax)
		{
			cMax = tmp;
			cMaxM = i;
		}
	}
	cout<<cMaxM+1<<endl;
	//system("pause");
}


#include <iostream>
#include <conio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define MP make_pair

const int MAX_VALUE = 1e9 + 7;

int bin(const vector<int> &a, int l, int r, int value) {
    if (l > r) {
        return 0;
    }
    if (l == r) {
        if (a[l] == value) {
            return l + 1;
        }
        return 0;
    }

    int m = (l + r) >> 1;

    if (a[m] > value) {
        return bin(a, l, m - 1, value);
    }
    if (a[m] == value) {
        int c = bin(a, m + 1, r, value);
        if (c == 0) {
            return m + 1;
        }
        return c;
    }
}

int main() {
//    freopen("test.in", "r", stdin);

    int n = 0;
    cin >> n;
    cout << n << endl;

    multiset<int> a;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        cin >> x;
        a.insert(x);
    }

    int m = 0;
    cin >> m;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    vector<int> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    int x = 0;
    int y = 0;
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int buf1 = a.count(b[i]);
        int buf2 = a.count(c[i]);

        /*int x1 = bin(a, 0, n - 1, b[i] - 1);
        int x2 = bin(a, 0, n - 1, b[i]);
        int buf1 = x2 - x1;

        int y1 = bin(a, 0, n - 1, c[i] - 1);
        int y2 = bin(a, 0, n - 1, c[i]);
        int buf2 = y2 - y1;*/

        if (x < buf1) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        } else if (x == buf1 && y < buf2) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define MP make_pair

const int MAX_VALUE = 1e9 + 7;

int bin(const vector<int> &a, int l, int r, int value) {
    if (l > r) {
        return 0;
    }
    if (l == r) {
        if (a[l] == value) {
            return l + 1;
        }
        return 0;
    }

    int m = (l + r) >> 1;

    if (a[m] > value) {
        return bin(a, l, m - 1, value);
    }
    if (a[m] == value) {
        int c = bin(a, m + 1, r, value);
        if (c == 0) {
            return m + 1;
        }
        return c;
    }
}

int main() {
//    freopen("test.in", "r", stdin);

    int n = 0;
    cin >> n;

    multiset<int> a;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        cin >> x;
        a.insert(x);
    }

    int m = 0;
    cin >> m;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    vector<int> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    int x = 0;
    int y = 0;
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int buf1 = a.count(b[i]);
        int buf2 = a.count(c[i]);

        /*int x1 = bin(a, 0, n - 1, b[i] - 1);
        int x2 = bin(a, 0, n - 1, b[i]);
        int buf1 = x2 - x1;

        int y1 = bin(a, 0, n - 1, c[i] - 1);
        int y2 = bin(a, 0, n - 1, c[i]);
        int buf2 = y2 - y1;*/

        if (x < buf1) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        } else if (x == buf1 && y < buf2) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define MP make_pair

const int MAX_VALUE = 1e9 + 7;

int bin(const vector<int> &a, int l, int r, int value) {
    if (l > r) {
        return 0;
    }
    if (l == r) {
        if (a[l] == value) {
            return l + 1;
        }
        return 0;
    }

    int m = (l + r) >> 1;

    if (a[m] > value) {
        return bin(a, l, m - 1, value);
    }
    if (a[m] == value) {
        int c = bin(a, m + 1, r, value);
        if (c == 0) {
            return m + 1;
        }
        return c;
    }
}

int main() {
//    freopen("test.in", "r", stdin);

    int n = 0;
    cin >> n;

    multiset<int> a;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        cin >> x;
        a.insert(x);
    }

    int m = 0;
    cin >> m;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    vector<int> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    int x = 0;
    int y = 0;
    int ans = 1;
    for (int i = 0; i < m; ++i) {
        int buf1 = a.count(b[i]);
        int buf2 = a.count(c[i]);

        /*int x1 = bin(a, 0, n - 1, b[i] - 1);
        int x2 = bin(a, 0, n - 1, b[i]);
        int buf1 = x2 - x1;

        int y1 = bin(a, 0, n - 1, c[i] - 1);
        int y2 = bin(a, 0, n - 1, c[i]);
        int buf2 = y2 - y1;*/

        if (x < buf1) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        } else if (x == buf1 && y < buf2) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define MP make_pair

const int MAX_VALUE = 1e9 + 7;

int main() {
//    freopen("test.in", "r", stdin);

    int n = 0;
    cin >> n;

    map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        cin >> x;

        map<int, int>::iterator j = cnt.find(x);
        if (j != cnt.end()) {
            j->second++;
        } else {
            cnt.insert(MP(x, 1));
        }
    }

    int m = 0;
    cin >> m;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    vector<int> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    pair<int, int> p = MP(0, 0);
    int ans = 1;
    for (int i = 0; i < m; ++i) {
        pair<int, int> p1 = MP(cnt[b[i]], cnt[c[i]]);
        if (p < p1) {
            p = p1;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define MP make_pair

const int MAX_VALUE = 1e9 + 7;

int bin(const vector<int> &a, int l, int r, int value) {
    if (l > r) {
        return 0;
    }
    if (l == r) {
        if (a[l] == value) {
            return l + 1;
        }
        return 0;
    }

    int m = (l + r) >> 1;

    if (a[m] > value) {
        return bin(a, l, m - 1, value);
    } else if (a[m] < value) {
        return bin(a, m + 1, r, value);
    } else {
        int c = bin(a, m + 1, r, value);
        if (c == 0) {
            return m + 1;
        }
        return c;
    }
}

int main() {
    freopen("test.in", "r", stdin);

    int n = 0;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    int m = 0;
    cin >> m;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    vector<int> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    int x = 0;
    int y = 0;
    int ans = 1;
    for (int i = 0; i < m; ++i) {
        int x1 = bin(a, 0, n - 1, b[i] - 1);
        int x2 = bin(a, 0, n - 1, b[i]);
        int buf1 = x2 - x1;

        int y1 = bin(a, 0, n - 1, c[i] - 1);
        int y2 = bin(a, 0, n - 1, c[i]);
        int buf2 = y2 - y1;

        if (x < buf1) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        } else if (x == buf1 && y < buf2) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <conio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define MP make_pair

const int MAX_VALUE = 1e9 + 7;

int bin(const vector<int> &a, int l, int r, int value) {
    if (l > r) {
        return 0;
    }
    if (l == r) {
        if (a[l] == value) {
            return l + 1;
        }
        return 0;
    }

    int m = (l + r) >> 1;

    if (a[m] > value) {
        return bin(a, l, m - 1, value);
    }
    if (a[m] == value) {
        int c = bin(a, m + 1, r, value);
        if (c == 0) {
            return m + 1;
        }
        return c;
    }
}

int main() {
    int n = 0;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    int m = 0;
    cin >> m;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    vector<int> c(m);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    int x = 0;
    int y = 0;
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int x1 = bin(a, 0, n - 1, b[i] - 1);
        int x2 = bin(a, 0, n - 1, b[i]);
        int buf1 = x2 - x1;

        int y1 = bin(a, 0, n - 1, c[i] - 1);
        int y2 = bin(a, 0, n - 1, c[i]);
        int buf2 = y2 - y1;

        if (x < buf1) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        } else if (x == buf1 && y < buf2) {
            x = buf1;
            y = buf2;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include <functional>

#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
map<int,int>mp;
int main()
{
    int n; cin>>n; vector<int>a;
    vector<pair<pair<int,int>,int>>movies;
    for(int i=0;i<n;i++)
    {
        int x; scanf("%d" , &x);
        mp[x]++;
    }
    int m; cin>>m;
    for(int i=0;i<m;i++)
    {
        int b; scanf("%d" , &b);
        movies.pb(pa(pa(mp[b] ,0)  , i+1));
    }
    for(int i=0;i<m;i++)
    {
        int b; scanf("%d" , &b);
        movies[i].f.s=mp[b];
    }
    sort(all(movies)); reverse(all(movies));
    int mx=movies.front().f.s; int num=0;
    int ans=movies.front().s;
    while(movies.front().f.f==movies[num].f.f)
    {
        if(mx<=movies[num].f.s){mx=movies[num].f.s; ans=movies[num].s;}
        num++; if(num==m)break;
    }
    cout<<ans;
}


#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include <functional>

#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
map<int,int>mp;
int main()
{
    int n; cin>>n; vector<int>a;
    vector<pair<pair<int,int>,int>>movies;
    for(int i=0;i<n;i++)
    {
        int x; cin>>x;
        mp[x]++;
    }
    int m; cin>>m;
    for(int i=0;i<m;i++)
    {
        int b; cin>>b;
        movies.pb(pa(pa(mp[b] ,0)  , i+1));
    }
    for(int i=0;i<m;i++)
    {
        int b; cin>>b;
        movies[i].f.s=mp[b];
    }
    sort(all(movies)); reverse(all(movies));
    int mx=movies.front().f.s; int num=0;
    int ans=movies.front().s;
    while(movies.front().f.f==movies[num].f.f)
    {
        if(mx<movies[num].f.s){mx=movies[num].f.s; ans=movies[num].s;}
        num++; if(num==m)break;
    }
    cout<<ans;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
map<int , int > mp ;
int verys=0;  int stats=0;
int main()
{
    int n ; int b[200200] , s[200200] ;
    int m;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    cin>>m;
    int ind=0;
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>s[i];
    int ans=-1 , ans2=-1;
    for(int i=0;i<m;i++)
    {
        verys=mp[b[i]];
        stats=mp[s[i]];
        if(verys>ans)
        {ind=i; ans=verys; ans2=stats;}
        else if (verys==ans) { if (stats>ans2) {ind=i ; ans=verys;  ans2=stats;}}
    }
    cout<<ind+1;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
map<int , int > mp ;
int verys=0;  int stats=0;
int main()
{
    int n ; int b[200200] , s[200200] ;
    int m;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    cin>>m;
    int ind=0;
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=0;i<m;i++) cin>>s[i];
    int ans=-1 , ans2=-1;
    for(int i=0;i<m;i++)
    {
        verys=mp[b[i]];
        stats=mp[s[i]];
        if(verys>ans)
        {ind=i; ans=verys; ans2=stats;}
        else if (verys==ans) { if (stats>ans2) {ind=i ; ans=verys;  ans2=stats;}}
    }
    cout<<ind+1;
}


#include <iostream>
#include<stdio.h>
#include <cstdlib>
using namespace std;
int main()
{
    int maxind2;
    int x[200000];
    int y[20000];
    int z[20000];
    int n,m;
    int index[200];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>y[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>z[i];
    }
int maxind=0;
int num1=0;
int num2=0;
int test=0;
int knew;
int k=0;
int j;
for(int i=0;i<n;i++)
{
for(j=0;j<m;j++)
    if(x[i]==y[j])
    {
        num1++;
    }
    if(num1>0&&num1>num2)
    {
        maxind=j;
        num2=num1;
    }
    if(num1==num2&&num2!=0)
    {test=1; index[k]=j; k++;}
    num1=0;
    knew=k;
}
 num1=0;
 k=0;
if(num2==0)
{
for(int i=0;i<n;i++)
{
for(j=0;j<m;j++)
    if(x[i]==z[j])
    {
        num1++;
    }
    if(num1>0&&num1>num2)
    {
        maxind=j;
        num2=num1;
    }

}
cout<<maxind;
exit(1);
}
num2=0;
if(test)
{
while(knew>k)
{
for(j=0;j<m;j++)
if(x[index[k]]==z[j])
    {
        num1++;
    }
    if(num1>num2)
    {
        maxind2=index[k];
        num2=num1;
    }
k++;
}
cout<<maxind2+1;
exit(1);
}
else {cout<<maxind;}
}