Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to 10^9.

In the evening after the conference, all n scientists decided to go to the cinema. There are m movies in the cinema they came to. Each of the movies is characterized by two distinct numbers — the index of audio language and the index of subtitles language. The scientist, who came to the movie, will be very pleased if he knows the audio language of the movie, will be almost satisfied if he knows the language of subtitles and will be not satisfied if he does not know neither one nor the other (note that the audio language and the subtitles language for each movie are always different). 

Scientists decided to go together to the same movie. You have to help them choose the movie, such that the number of very pleased scientists is maximum possible. If there are several such movies, select among them one that will maximize the number of almost satisfied scientists.


-----Input-----

The first line of the input contains a positive integer n (1 ≤ n ≤ 200 000) — the number of scientists.

The second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is the index of a language, which the i-th scientist knows.

The third line contains a positive integer m (1 ≤ m ≤ 200 000) — the number of movies in the cinema. 

The fourth line contains m positive integers b_1, b_2, ..., b_{m} (1 ≤ b_{j} ≤ 10^9), where b_{j} is the index of the audio language of the j-th movie.

The fifth line contains m positive integers c_1, c_2, ..., c_{m} (1 ≤ c_{j} ≤ 10^9), where c_{j} is the index of subtitles language of the j-th movie.

It is guaranteed that audio languages and subtitles language are different for each movie, that is b_{j} ≠ c_{j}. 


-----Output-----

Print the single integer — the index of a movie to which scientists should go. After viewing this movie the number of very pleased scientists should be maximum possible. If in the cinema there are several such movies, you need to choose among them one, after viewing which there will be the maximum possible number of almost satisfied scientists. 

If there are several possible answers print any of them.


-----Examples-----
Input
3
2 3 2
2
3 2
2 3

Output
2

Input
6
6 3 1 1 3 7
5
1 2 3 4 5
2 3 4 5 1

Output
1



-----Note-----

In the first sample, scientists must go to the movie with the index 2, as in such case the 1-th and the 3-rd scientists will be very pleased and the 2-nd scientist will be almost satisfied.

In the second test case scientists can go either to the movie with the index 1 or the index 3. After viewing any of these movies exactly two scientists will be very pleased and all the others will be not satisfied.

Difficulty: EASY
Tags: Sorting

Implementation
Skill types: Sorting

Starter code:

Solutions:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = Counter()
for language in a:
	d[language] += 1
scores = [None] * m
for i in range(m):
	scores[i] = (d[b[i]], d[c[i]], i + 1)
scores.sort(reverse=True)
print(scores[0][2])


n = int(input())
L = list(map(int, input().split()))
m = int(input())
A = list(map(int, input().split()))
S = list(map(int, input().split()))
D = {}
for i in range(n):
	if L[i] in list(D.keys()):
		D[L[i]] += 1
	else:
		D[L[i]] = 1
M = [[0, 0, i + 1] for i in range(m)]
for i in range(m):
	if A[i] in list(D.keys()):
		M[i][0] += D[A[i]]
	if S[i] in list(D.keys()):
		M[i][1] += D[S[i]]

def ct(a):
	return (a[0], a[1])
M.sort(key=ct, reverse=True)
print(M[0][2])


def main():
	from collections import Counter
	input()
	aa = Counter(map(int, input().split()))
	m = int(input())
	bb = list(map(aa.__getitem__, map(int, input().split())))
	cc = list(map(aa.__getitem__, map(int, input().split())))
	print(max(range(m), key=lambda i: (bb[i], cc[i])) + 1)
main()


import traceback
import os
import sys
from io import BytesIO, IOBase
import math
from collections import defaultdict, Counter
from functools import lru_cache
from itertools import accumulate
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def geti():
	return int(input())

def gets():
	return input()

def getil():
	return list(map(int, input().split()))

def getsl():
	return input().split()

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]

def get_acc(a):
	return list(accumulate(a))

def get_ncr(n, r):
	if n < r:
		return 0
	return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

def get_npr(n, r):
	if n < r:
		return 0
	return math.factorial(n) // math.factorial(r)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
	N = geti()
	a = getil()
	M = geti()
	b = getil()
	c = getil()
	d = Counter(a)
	p = max(range(M), key=lambda x: (d[b[x]], d[c[x]]))
	return p + 1
try:
	ans = main()
	print(ans)
except Exception as e:
	print(e)
	traceback.print_exc()


read = lambda : map(int, input().split())
n = int(input())
a = list(read())
m = int(input())
b = list(read())
c = list(read())
from collections import Counter as C
d = C()
for i in a:
	d[i] += 1
mb = mc = ind = -1
for i in range(m):
	if d[b[i]] > mb:
		mb = d[b[i]]
		mc = d[c[i]]
		ind = i + 1
	elif d[b[i]] == mb and d[c[i]] > mc:
		mc = d[c[i]]
		ind = i + 1
print(ind)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
lanquage = array()
C = Counter(lanquage)
m = Int()
audio = array()
subtitle = array()
movie = -1
pleased = -1
satisfied = -1
for i in range(m):
	now_pleased = C[audio[i]]
	now_satisfied = C[subtitle[i]]
	if now_pleased > pleased:
		pleased = now_pleased
		satisfied = now_satisfied
		movie = i + 1
	if now_pleased == pleased and satisfied < now_satisfied:
		movie = i + 1
		satisfied = now_satisfied
print(movie)


n = int(input())
d = {}
for i in list(map(int, input().split())):
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
m = int(input())
res = [(0, 0)] * m
b = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(m):
	if b[i] not in d:
		d[b[i]] = 0
	if c[i] not in d:
		d[c[i]] = 0
	res[i] = (d[b[i]], i)
res.sort()
idx = res[m - 1][1]
for i in range(m - 1, -1, -1):
	if res[i][0] == res[m - 1][0] and d[c[res[i][1]]] > d[c[idx]]:
		idx = res[i][1]
print(idx + 1)


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
freq = defaultdict(int)
for i in arr:
	freq[i] += 1
m = int(input())
brr = list(map(int, input().split()))
crr = list(map(int, input().split()))
ans = []
for i in range(m):
	x = freq[brr[i]]
	y = freq[crr[i]]
	ans.append([x, y, i])
ans.sort()
ind = ans[m - 1][2]
print(ind + 1)


import sys, math
n = int(input())
uch = list(map(int, sys.stdin.readline().split()))
dic = dict()
for x in uch:
	if x in list(dic.keys()):
		dic[x] += 1
	else:
		dic[x] = 1
m = int(input())
langf = list(map(int, sys.stdin.readline().split()))
subf = list(map(int, sys.stdin.readline().split()))
maxl = 0
maxs = 0
ans = 1
for i in range(m):
	if langf[i] not in list(dic.keys()):
		dic[langf[i]] = 0
	if subf[i] not in list(dic.keys()):
		dic[subf[i]] = 0
	if maxl < dic[langf[i]]:
		maxl = dic[langf[i]]
		maxs = dic[subf[i]]
		ans = i + 1
	elif maxl == dic[langf[i]] and maxs < dic[subf[i]]:
		maxs = dic[subf[i]]
		ans = i + 1
print(ans)


import sys
n = int(sys.stdin.readline())
langs = str(sys.stdin.readline())[:-1].split(' ')
allLangs = {}
for lang in langs:
	try:
		allLangs[lang] += 1
	except:
		allLangs[lang] = 1
m = int(sys.stdin.readline())
sound = str(sys.stdin.readline())[:-1].split(' ')
subs = str(sys.stdin.readline())[:-1].split(' ')
allAns = []
for i in range(m):
	try:
		snd = allLangs[sound[i]]
	except:
		snd = 0
	try:
		sbs = allLangs[subs[i]]
	except:
		sbs = 0
	allAns.append([i, snd, sbs])
allAns = sorted(allAns, key=lambda ans: (ans[1], ans[2]))
print(allAns[-1][0] + 1)


R = lambda : map(int, input().split())
n = int(input())
a = list(R())
m = int(input())
(b, c) = (list(R()), list(R()))
from collections import Counter
ac = Counter(a)
mx_mb = -1
mx_mc = -1
res = -1
for i in range(m):
	(tmb, tmc) = (ac.get(b[i], 0), ac.get(c[i], 0))
	if tmb > mx_mb:
		(mx_mb, mx_mc, res) = (tmb, tmc, i)
	elif tmb == mx_mb and tmc > mx_mc:
		(mx_mb, mx_mc, res) = (tmb, tmc, i)
print(res + 1)


R = input
P = lambda x, a: x.get(a, 0)
I = lambda : list(map(int, R().split()))
R()
d = {}
for i in I():
	d[i] = P(d, i) + 1
m = I()[0]
b = I()
c = I()
r = 0
for i in range(m):
	l = P(d, b[i]) - P(d, b[r])
	if l > 0 or (l == 0 and P(d, c[i]) > P(d, c[r])):
		r = i
print(r + 1)


from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
ac = Counter(a)
m = int(input())
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = []
for i in range(0, m):
	(very_pleased, satisfied) = (0, 0)
	if b[i] in ac:
		very_pleased = ac[b[i]]
	if c[i] in ac:
		satisfied = ac[c[i]]
	ans.append((very_pleased, satisfied, i + 1))
ans = sorted(ans)[::-1]
final_ans = ans[0][2]
print(final_ans)


from collections import *
d = Counter()
n = int(input())
for x in input().split():
	d[int(x)] += 1
m = int(input())
ls = sorted(((d[int(l[0])], d[int(l[1])], z + 1) for (z, l) in enumerate(zip(input().split(), input().split()))))
print(ls[-1][2])


from collections import Counter
n = int(input())
k = Counter(map(int, input().split()))
m = int(input())
(ls1, ls2) = (list(map(int, input().split())), list(map(int, input().split())))
(cntr, cntr2, j) = (0, 0, 1)
for i in range(m):
	if k[ls1[i]] > cntr:
		(cntr, cntr2, j) = (k[ls1[i]], k[ls2[i]], i + 1)
	elif k[ls1[i]] == cntr and k[ls2[i]] > cntr2:
		(cntr2, j) = (k[ls2[i]], i + 1)
print(j)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
cnt = Counter()
for v in arr:
	cnt[v] += 1
audio = list(map(int, input().split()))
subs = list(map(int, input().split()))
scores = list()
for i in range(m):
	scores.append((cnt[audio[i]], cnt[subs[i]], i + 1))
scores.sort()
print(scores[-1][2])


from collections import defaultdict as dd
n = int(input())
a = [int(_) for _ in input().split()]
m = int(input())
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
db = dd(int)
dc = dd(int)
for i in a:
	db[i] += 1
	dc[i] += 1
ans = []
for (x, y, z) in zip(b, c, range(1, m + 1)):
	ans.append((db[x], dc[y], z))
print(max(ans)[-1])


for t in range(1):
	n = int(input())
	arr = list(map(int, input().split()))
	counter = dict()
	for i in arr:
		if i in counter:
			counter[i] += 1
		else:
			counter[i] = 1
	happy = 0
	satis = 0
	ans = 1
	q = int(input())
	arr_lang = list(map(int, input().split()))
	arr_sub = list(map(int, input().split()))
	for i in range(q):
		(lang, sub) = (arr_lang[i], arr_sub[i])
		count_lang = 0
		count_sub = 0
		if lang in counter:
			count_lang = counter[lang]
		if sub in counter:
			count_sub = counter[sub]
		if count_lang > happy:
			happy = count_lang
			satis = count_sub
			ans = i + 1
		elif count_lang == happy and count_sub > satis:
			satis = count_sub
			ans = i + 1
		else:
			continue
	print(ans)


n = int(input())
A = list(map(int, input().split()))
g = {}
for i in A:
	if i not in g:
		g[i] = 0
	g[i] += 1
m = int(input())
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sas = [0, 0, 0]
for i in range(m):
	if B[i] not in g:
		g[B[i]] = 0
	if C[i] not in g:
		g[C[i]] = 0
	lol = [g[B[i]], g[C[i]], i + 1]
	sas = max(sas, lol)
print(sas[2])


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = dict()
for a in A:
	if a not in D:
		D[a] = 1
	else:
		D[a] += 1
P = [0] * m
S = [0] * m
for i in range(m):
	key = B[i]
	if key in D:
		P[i] += D[key]
for i in range(m):
	key = C[i]
	if key in D:
		S[i] += D[key]
ans = 0
for i in range(1, m):
	if P[i] > P[ans] or (P[i] == P[ans] and S[i] > S[ans]):
		ans = i
ans += 1
print(ans)


import sys
n = int(sys.stdin.readline())
a = [int(i) for i in sys.stdin.readline().strip().split()]
m = int(sys.stdin.readline())
b = [int(i) for i in sys.stdin.readline().strip().split()]
c = [int(i) for i in sys.stdin.readline().strip().split()]
lang_cnt = {}
for lang in a:
	if lang in lang_cnt:
		lang_cnt[lang] += 1
	else:
		lang_cnt[lang] = 1
best_movie = 1
maximum_pleased = 0
maximum_almost_satisfied = 0
for i in range(m):
	pleased = 0
	if b[i] in lang_cnt:
		pleased = lang_cnt[b[i]]
	almost_satisfied = 0
	if c[i] in lang_cnt:
		almost_satisfied = lang_cnt[c[i]]
	if pleased > maximum_pleased or (pleased == maximum_pleased and almost_satisfied > maximum_almost_satisfied):
		maximum_pleased = pleased
		maximum_almost_satisfied = almost_satisfied
		best_movie = i + 1
print(best_movie)


many = int(input())
langscie = list(map(int, input().split(' ')))
langscienc = {}
for lang in langscie:
	try:
		langscienc[lang] += 1
	except:
		langscienc[lang] = 1
numovies = int(input())
audmovie = list(map(int, input().split(' ')))
submovie = list(map(int, input().split(' ')))
maximaud = -2
maximsub = -2
indexoffilm = -2
same = []
for (pos, index) in enumerate(audmovie):
	try:
		now = langscienc[index]
	except:
		now = 0
	if now > maximaud:
		maximaud = now
		indexoffilm = pos
		same = [indexoffilm]
	elif now == maximaud:
		same.append(pos)
if len(same) > 1:
	for filmindex in same:
		try:
			now = langscienc[submovie[filmindex]]
		except:
			continue
		if now > maximsub:
			maximsub = now
			indexoffilm = filmindex
print(indexoffilm + 1)


from sys import stdin, stdout
n = int(stdin.readline())
d = {}
languages = list(map(int, stdin.readline().split()))
for l in languages:
	if l not in d:
		d[l] = 1
	else:
		d[l] += 1
m = int(stdin.readline())
movies = []
voice = list(map(int, stdin.readline().split()))
for i in range(m):
	if voice[i] in d:
		movies.append([d[voice[i]], 0, i])
	else:
		movies.append([0, 0, i])
subtitles = list(map(int, stdin.readline().split()))
for i in range(m):
	if subtitles[i] in d:
		movies[i][1] = d[subtitles[i]]
stdout.write(str(sorted(movies)[-1][-1] + 1))


from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
n = int(input())
a_list = map(int, input().split(' '))
m = int(input())
b_list = tuple(map(int, input().split(' ')))
c_list = tuple(map(int, input().split(' ')))
a_cnt = collections.Counter(a_list)
max_pl = 0
max_st = 0
cand = None
for i in range(m):
	pl = a_cnt[b_list[i]]
	st = a_cnt[c_list[i]]
	if pl > max_pl:
		max_pl = pl
		max_st = st
		cand = i + 1
	elif pl == max_pl:
		if st > max_st:
			max_st = st
			cand = i + 1
		elif st == max_st and cand is None:
			cand = i + 1
print(cand)


import operator

class Movie:

	def __init__(self, id, very, almost):
		self.id = id
		self.very = very
		self.almost = almost
n = int(input())
a = input().split()
m = int(input())
b = input().split()
c = input().split()
set_a = set(a)
counts = {}
for ele in set_a:
	counts[ele] = 0
for i in range(n):
	counts[a[i]] += 1
movies = [None] * m
for i in range(m):
	cur_b = b[i]
	very = counts[cur_b] if cur_b in set_a else 0
	cur_c = c[i]
	almost = counts[cur_c] if cur_c in set_a else 0
	movies[i] = Movie(i, very, almost)
movies.sort(key=operator.attrgetter('very', 'almost'))
print(movies[m - 1].id + 1)


n = int(input())
languages = {}
l = list(map(int, input().split()))
for i in l:
	if i in languages:
		languages[i] += 1
	else:
		languages[i] = 1
m = int(input())
audio = list(map(int, input().split()))
subs = list(map(int, input().split()))
maxSoFar = (0, 0)
index = 1
for (i, (a, s)) in enumerate(zip(audio, subs), 1):
	current = 0
	if a in languages:
		current += 2 * languages[a]
	if current < maxSoFar[0]:
		continue
	subt = 0
	if current == maxSoFar[0]:
		if s in languages:
			subt = languages[s]
		if subt > maxSoFar[1]:
			maxSoFar = (current, subt)
			index = i
	elif current > maxSoFar[0]:
		if s in languages:
			subt = languages[s]
		maxSoFar = (current, subt)
		index = i
print(index)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
nF = int(input())
lang = list(map(int, input().split()))
sub = list(map(int, input().split()))
cnt = defaultdict(int)
for v in a:
	cnt[v] += 1
print(max(range(nF), key=lambda x: (cnt[lang[x]], cnt[sub[x]])) + 1)


from collections import Counter
n = int(input())
lang = Counter(list(map(int, input().split())))
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = list()
for i in range(m):
	res.append((lang[a[i]], lang[b[i]], i))
print(sorted(sorted(res, key=lambda x: x[1], reverse=True), key=lambda x: x[0], reverse=True)[0][2] + 1)


n = int(input())
l = sorted(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = {}
for x in l:
	d[x] = d.get(x, 0) + 1
ans = (0, 0, 0)
for i in range(m):
	cob = d.get(b[i], 0)
	coc = d.get(c[i], 0)
	if cob > ans[1]:
		ans = (i, cob, coc)
	if cob == ans[1] and coc > ans[2]:
		ans = (i, cob, coc)
print(ans[0] + 1)


import sys
sys.stderr = sys.stdout
from collections import Counter

def cinema(n, A, m, B, C):
	L = Counter(A)
	return max(range(m), key=lambda i: (L[B[i]], L[C[i]])) + 1

def main():
	n = readint()
	A = readintl()
	m = readint()
	B = readintl()
	C = readintl()
	print(cinema(n, A, m, B, C))

def readint():
	return int(input())

def readinti():
	return map(int, input().split())

def readintt():
	return tuple(readinti())

def readintl():
	return list(readinti())

def readinttl(k):
	return [readintt() for _ in range(k)]

def readintll(k):
	return [readintl() for _ in range(k)]

def log(*args, **kwargs):
	print(*args, **kwargs, file=sys.__stderr__)
main()


import math
from collections import Counter
n = int(input())
A = [int(x) for x in input().split()]
D = Counter(A)
m = int(input())
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
L = [(D[B[i]], D[C[i]], i) for i in range(m)]
L.sort()
print(L[-1][2] + 1)


from sys import stdin
from collections import *
from operator import itemgetter

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return [str(x) for x in stdin.readline().split()]
(n, a, m, b, c) = (int(input()), arr_inp(1), int(input()), arr_inp(1), arr_inp(1))
(mem, ans) = (defaultdict(int, Counter(a)), [])
for i in range(m):
	ans.append([mem[b[i]], mem[c[i]], i + 1])
ans.sort(key=itemgetter(0, 1), reverse=True)
print(ans[0][2])


parse_int = lambda : list(map(int, input().split()))
scientists = int(input())
sc_langs = parse_int()
films = int(input())
film_voice = parse_int()
film_sub = parse_int()
lang_decoder = dict()
lang_decoder.setdefault(0)
for _ in sc_langs:
	if _ in list(lang_decoder.keys()):
		lang_decoder[_] += 1
	else:
		lang_decoder[_] = 1
(film_good, film_ok) = ([0] * films, [0] * films)
for _ in range(films):
	try:
		film_good[_] += lang_decoder[film_voice[_]] or 0
	except KeyError:
		pass
	try:
		film_ok[_] += lang_decoder[film_sub[_]] or 0
	except KeyError:
		pass
best = 0
for _ in range(films):
	if film_good[_] > film_good[best]:
		best = _
	if film_good[_] == film_good[best] and film_ok[_] > film_ok[best]:
		best = _
print(best + 1)


from collections import deque as dq
n = int(input())
lis = sorted(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = {}
d[lis[0]] = 1
for i in range(1, n):
	if lis[i] == lis[i - 1]:
		d[lis[i]] += 1
	else:
		d[lis[i]] = 1
ans = []
for i in range(m):
	aa = bb = 0
	if b[i] in d:
		aa = d[b[i]]
	if c[i] in d:
		bb = d[c[i]]
	ans.append([aa, bb, i + 1])
ans.sort(reverse=True)
print(ans[0][2])


from collections import *
n = int(input())
d = Counter(map(int, input().split()))
m = int(input())
print(sorted(((d[l[0]], d[l[1]], z + 1) for (z, l) in enumerate(zip(list(map(int, input().split())), list(map(int, input().split()))))))[-1][2])


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
lang = {}
for i in iia():
	lang.setdefault(i, [0])[0] += 1
m = ii1()
audio = iia()
sub = iia()
res = []
for (k, (i, j)) in enumerate(zip(audio, sub)):
	res.append([lang.get(i, [0])[0], lang.get(j, [0])[0], k])
res.sort(reverse=True)
print(res[0][2] + 1)


n = int(input())
men = list(map(int, input().split()))
d = dict()
for i in men:
	now = d.get(i, 0)
	d[i] = now + 1
m = int(input())
f1 = list(map(int, input().split()))
f2 = list(map(int, input().split()))
mx = 0
mx2 = 0
num = 0
for i in range(m):
	now = d.get(f1[i], 0)
	if now > mx:
		mx = now
		mx2 = d.get(f2[i], 0)
		num = i
	elif now == mx:
		now2 = d.get(f2[i], 0)
		if now2 > mx2:
			mx2 = d.get(f2[i], 0)
			num = i
print(num + 1)


from collections import Counter
n = int(input())
x = list(map(int, input().split()))
c = Counter(x)
m = int(input())
audio = list(map(int, input().split()))
sub = list(map(int, input().split()))
aa = 0
ss = 0
index = 1
for i in range(m):
	a = c[audio[i]]
	s = c[sub[i]]
	if a > aa or (a == aa and s > ss):
		aa = a
		ss = s
		index = i + 1
print(index)


def which_movie(n, m, langs_ix, audio_ix, subs_ix):
	langs = {}
	for l in langs_ix:
		if l in langs:
			langs[l] += 1
		else:
			langs[l] = 1
	scores = []
	for i in range(m):
		vp = langs[audio_ix[i]] if audio_ix[i] in langs else 0
		asp = langs[subs_ix[i]] if subs_ix[i] in langs else 0
		scores.append((i + 1, vp, asp))
	scores = sorted(scores, key=lambda x: (x[1], x[2], -x[0]))
	return scores[-1][0]

def main():
	n = int(input().strip())
	lang_ix = [int(i) for i in input().strip().split()]
	m = int(input().strip())
	audiolang_ix = [int(i) for i in input().strip().split()]
	subtitle_ix = [int(i) for i in input().strip().split()]
	ans = which_movie(n, m, lang_ix, audiolang_ix, subtitle_ix)
	print(ans)
main()


n = int(input())
languages = {}
s = input().split()
for i in s:
	if i in languages:
		languages[i] += 1
	else:
		languages[i] = 1
m = int(input())
audio = input().split()
subtitles = input().split()
bestm = 1
besta = 0
bests = 0
for i in range(m):
	ad = audio[i]
	sb = subtitles[i]
	ac = 0
	if ad in languages:
		ac = languages[ad]
	sc = 0
	if sb in languages:
		sc = languages[sb]
	if ac > besta or (ac == besta and sc > bests):
		bestm = i + 1
		besta = ac
		bests = sc
print(bestm)


n = int(input())
slov = {}
mas = list(map(int, input().split()))
mas.sort()
kek = {}
i = 1
for b in range(1, n):
	if mas[b] == mas[b - 1]:
		i += 1
	else:
		kek[mas[b - 1]] = i
		i = 1
kek[mas[n - 1]] = i
m = int(input())
mas = list(map(int, input().split()))
mas2 = list(map(int, input().split()))
mi1 = -1
mi2 = -1
otv = 0
for i in range(m):
	try:
		a = kek[mas[i]]
	except:
		a = 0
	try:
		b = kek[mas2[i]]
	except:
		b = 0
	if a > mi1:
		mi1 = a
		mi2 = b
		otv = i + 1
	elif a == mi1:
		if mi2 < b:
			mi2 = b
			otv = i + 1
print(otv)


n = int(input())
a = [int(i) for i in input().split()]
m = int(input())
audio = [int(i) for i in input().split()]
subtitle = [int(i) for i in input().split()]
from collections import Counter
c = Counter(a)
sat = -1
almost_sat = -1
for i in range(m):
	aud = c[audio[i]]
	sub = c[subtitle[i]]
	if aud > sat:
		sat = aud
		almost_sat = sub
		ans = i + 1
	elif aud == sat:
		if sub > almost_sat:
			almost_sat = sub
			ans = i + 1
print(ans)


import sys
import math
import itertools as it
import operator as op
import fractions as fr
n = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().split()))
m = int(sys.stdin.readline().strip())
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
D = dict()
D.update(list(zip(A, [0] * len(A))))
D.update(list(zip(B, [0] * len(B))))
D.update(list(zip(C, [0] * len(C))))
for a in A:
	D[a] += 1
max_val = -1
l = []
for idx in range(len(B)):
	b = B[idx]
	if D[b] > max_val:
		max_val = D[b]
		l = [idx]
	elif D[b] == max_val:
		l.append(idx)
max_idx = 0
max_val = -1
for idx in l:
	c = C[idx]
	if D[c] > max_val:
		max_val = D[c]
		max_idx = idx
print(max_idx + 1)


import collections as cl
(n, a) = (input(), cl.Counter(map(int, input().split())))
(m, b, c) = (input(), list(map(int, input().split())), list(map(int, input().split())))
f = [(a[x[0]] if x[0] in a else 0, a[x[1]] if x[1] in a else 0) for x in zip(b, c)]
print(f.index(max(f)) + 1)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	L = {}
	for language in a:
		if language not in L:
			L[language] = 1
		else:
			L[language] += 1
	m = int(input())
	audio = list(map(int, input().split()))
	subs = list(map(int, input().split()))
	satisfaction = [(0, 0)] * m
	for i in range(m):
		satisfaction[i] = (L.get(audio[i], 0), L.get(subs[i], 0))
	print(satisfaction.index(max(satisfaction)) + 1)
main()


n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
C = list(map(int, input().split()))
S = {}
L = []
maxim = 0
for i in range(n):
	try:
		S[A[i]] += 1
	except KeyError:
		S[A[i]] = 1
	maxim = max(maxim, S[A[i]])
for i in range(m):
	try:
		a = S[B[i]]
	except KeyError:
		a = 0
	try:
		b = S[C[i]]
	except KeyError:
		b = 0
	L.append((a, b, i + 1))
L.sort()
f = L[-1]
print(f[2])


import sys
input = lambda : sys.stdin.readline()
MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
d = dict()
n = ii()
l = il()
for i in l:
	d[i] = d.get(i, 0) + 1
m = ii()
lang = il()
sub = il()
l = []
for (i, j) in zip(lang, sub):
	l.append([d.get(i, 0), d.get(j, 0)])
l2 = sorted(l, reverse=True)
for i in range(m):
	if l[i] == l2[0]:
		print(i + 1)
		break


import itertools as it
import functools
import operator
import collections
import math
import sys

def solve(n, m, xs, ys, zs):
	cnt = collections.Counter(xs)
	result = max(((cnt[y], cnt[z], -i) for (i, (y, z)) in enumerate(zip(ys, zs), 1)))
	pp('result:', result)
	(_, _, neg) = result
	return -neg

def pp(*args, **kwargs):
	return print(*args, file=sys.stderr, **kwargs)

def main():
	n = int(input().strip())
	xs = [int(i) for i in input().strip().split()]
	m = int(input().strip())
	ys = [int(i) for i in input().strip().split()]
	zs = [int(i) for i in input().strip().split()]
	assert len(xs) == n
	assert len(ys) == len(zs) == m
	result = solve(n, m, xs, ys, zs)
	print(result)
main()


n = int(input())
a = map(int, input().split())
d = dict()
for i in a:
	d[i] = d.get(i, 0) + 1
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = [-1, -1]
ind = -1
for i in range(m):
	x = [d.get(b[i], 0), d.get(c[i], 0)]
	if ans < x:
		ans = x
		ind = i
print(ind + 1)


import string
import math

def main():
	n = int(input())
	tab = list(map(int, input().split()))
	inc = {}
	for x in range(n):
		if tab[x] in inc:
			inc[tab[x]] += 1
		else:
			inc[tab[x]] = 1
	m = int(input())
	movv = list(map(int, input().split()))
	mova = list(map(int, input().split()))
	maxv = 0
	maxa = 0
	maxi = 0
	for x in range(m):
		(v, a) = (movv[x], mova[x])
		if v in inc and a in inc and (inc[v] == maxv) and (maxa < inc[a]):
			maxa = inc[a]
			maxi = x
		elif maxv == 0 and (not v in inc) and (a in inc) and (maxa < inc[a]):
			maxa = inc[a]
			maxi = x
		elif v in inc and inc[v] > maxv:
			maxv = inc[v]
			if a in inc:
				maxa = inc[a]
			else:
				maxa = 0
			maxi = x
	print(maxi + 1)
main()


from collections import Counter

def make_pair(film, scients):
	return (scients.get(film[0], 0), scients.get(film[1], 0))
scientist_count = int(input())
scientists_languages = Counter(input().split())
films_count = int(input())
films_languages = list(map(lambda x: (x[0], x[1]), zip(input().split(), input().split())))
best = make_pair(films_languages[0], scientists_languages)
best = (best[0], best[1], 1)
for (i, pair) in enumerate(films_languages[1:]):
	new_pair = make_pair(pair, scientists_languages)
	if best[0] < new_pair[0]:
		best = (new_pair[0], new_pair[1], i + 2)
	elif best[0] == new_pair[0] and best[1] < new_pair[1]:
		best = (new_pair[0], new_pair[1], i + 2)
print(best[2])


input()
from collections import defaultdict
languages = defaultdict(lambda : 0)
for language in input().split():
	if language in languages:
		languages[language] += 1
	else:
		languages[language] = 1
m = int(input())
voice_languages = input().split()
sub_languages = input().split()
max_voice = languages[max(voice_languages, key=lambda language: languages[language])]
variants = (i for i in range(m) if languages[voice_languages[i]] == max_voice)
result = max(variants, key=lambda i: languages[sub_languages[i]])
print(result + 1)


from operator import itemgetter
from collections import defaultdict
_ = input()
lang = defaultdict(int)
for l in input().split(' '):
	lang[l] += 1
_ = input()
audio = input().split(' ')
subtitle = input().split(' ')
movie = []
for (i, t) in enumerate(zip(audio, subtitle)):
	(a, s) = t
	movie.append([lang[a], lang[s], i])
movie.sort(key=itemgetter(0, 1))
print(movie[-1][-1] + 1)


from collections import Counter
n = int(input())
C = Counter(map(int, input().split()))
m = int(input())
audio = list(map(int, input().split()))
subs = list(map(int, input().split()))
merge = [(C.get(a, 0), C.get(b, 0)) for (a, b) in zip(audio, subs)]
print(merge.index(max(merge)) + 1)


n = int(input())
langs = list(map(int, input().split()))
m = int(input())
aud = list(map(int, input().split()))
sub = list(map(int, input().split()))
res = []
d = {}
for i in langs:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in range(m):
	x = 0
	y = 0
	if aud[i] in d:
		x = d[aud[i]]
	if sub[i] in d:
		y = d[sub[i]]
	res.append((x, y, i + 1))
print(max(res)[2])


n = int(input())
a = list(map(int, input().split()))
lang = dict()
cnt = [0] * n
count = 0
for l in a:
	if l not in lang:
		lang[l] = count
		count += 1
	cnt[lang[l]] += 1
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bestfilm = 0
bestsat = 0 if b[0] not in lang else cnt[lang[b[0]]]
bestpartsat = 0 if c[0] not in lang else cnt[lang[c[0]]]
for i in range(m):
	sat = 0 if b[i] not in lang else cnt[lang[b[i]]]
	partsat = 0 if c[i] not in lang else cnt[lang[c[i]]]
	if sat > bestsat or (sat == bestsat and bestpartsat < partsat):
		bestfilm = i
		bestsat = sat
		bestpartsat = partsat
print(bestfilm + 1)


n = int(input())
a = input().split()
m = int(input())
b = input().split()
c = input().split()
languages = {}
for i in a:
	languages[i] = 0
for i in a:
	languages[i] += 1
films_sound = []
for i in b:
	if i in languages:
		films_sound.append(languages[i])
	else:
		films_sound.append(0)
films_sub = []
for i in c:
	if i in languages:
		films_sub.append(languages[i])
	else:
		films_sub.append(0)
films = []
for i in range(0, m):
	films.append([films_sound[i], films_sub[i], i])
films.sort()
num = 1 + int(films.pop()[2])
print(str(num))


n = int(input())
s = list(map(lambda x: int(x), input().split()))
a = {}
for i in range(n):
	if s[i] in a:
		a[s[i]] += 1
	else:
		a[s[i]] = 1
m = int(input())
b = list(map(lambda x: int(x), input().split()))
c = list(map(lambda x: int(x), input().split()))
ans = -1
d = -1
pd = -1
for i in range(m):
	if b[i] in a:
		cd = a[b[i]]
	else:
		cd = 0
	if c[i] in a:
		cpd = a[c[i]]
	else:
		cpd = 0
	if cd > d or (cd == d and cpd > pd):
		ans = i
		d = cd
		pd = cpd
print(ans + 1)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
lngCnt = {}
for sc in a:
	lngCnt[sc] = lngCnt.get(sc, 0) + 1
for sc in b:
	lngCnt[sc] = lngCnt.get(sc, 0)
for sc in c:
	lngCnt[sc] = lngCnt.get(sc, 0)
bestMovie = 0
for i in range(m):
	if lngCnt[b[i]] > lngCnt[b[bestMovie]]:
		bestMovie = i
	elif lngCnt[b[i]] == lngCnt[b[bestMovie]]:
		if lngCnt[c[i]] > lngCnt[c[bestMovie]]:
			bestMovie = i
print(bestMovie + 1)


def main():
	from collections import Counter
	input()
	aa = Counter(map(int, input().split()))
	m = int(input())
	(bb, cc) = (list(map(aa.__getitem__, map(int, input().split()))) for _ in (0, 1))
	print(max(zip(bb, cc, range(m)))[2] + 1)
main()


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
nbyLang = {}
for lang in a:
	if lang in nbyLang.keys():
		nbyLang[lang] += 1
	else:
		nbyLang[lang] = 1
maxb = 0
maxc = 0
film = 0
for i in range(m):
	bb = nbyLang.get(b[i], 0)
	cc = nbyLang.get(c[i], 0)
	if maxb < bb:
		maxb = bb
		maxc = cc
		film = i
	elif maxb == bb and maxc < cc:
		maxc = cc
		film = i
print(film + 1)


n = int(input())
langs = list(map(int, input().split(' ')))
m = int(input())
audio = list(map(int, input().split(' ')))
subs = list(map(int, input().split(' ')))
lang_count = {}
for lang in langs:
	lang_count[lang] = lang_count.get(lang, 0) + 1
movies = list(range(0, m))
movies.sort(key=lambda x: (lang_count.get(audio[x], 0), lang_count.get(subs[x], 0)), reverse=True)
print(movies[0] + 1)


n = int(input())
s = [int(i) for i in input().split()]
m = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = dict()
r = []
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in a:
	if i not in d:
		d[i] = 0
for i in b:
	if i not in d:
		d[i] = 0
films = []
for i in range(m):
	films.append((i + 1, (d[a[i]], d[b[i]])))
films.sort(key=lambda i: i[1], reverse=True)
print(films[0][0])


I = lambda : list(map(int, input().split()))
(n, a, m, b, c, q) = (int(input()), I(), int(input()), I(), I(), {})
for i in a:
	if i not in q:
		q[i] = 1
	else:
		q[i] += 1
r = [0] * m
for i in range(m):
	if c[i] not in q:
		q[c[i]] = 0
	if b[i] not in q:
		q[b[i]] = 0
	r[i] = [q[b[i]], q[c[i]]]
print(r.index(max(r)) + 1)


import bisect
from collections import defaultdict, Counter
import math

def solve(a, m, s):
	mp = Counter(a)
	pos = set()
	Max = -1
	for i in range(len(m)):
		if m[i] in mp and mp[m[i]] > Max:
			Max = mp[m[i]]
			pos = {i}
		elif m[i] in mp and mp[m[i]] == Max:
			pos.add(i)
		else:
			continue
	if len(pos) == 1:
		for i in pos:
			return i + 1
	ans = 0
	if len(pos) == 0:
		Max = -1
		for i in range(len(s)):
			if mp[s[i]] > Max:
				Max = mp[s[i]]
				ans = i
	else:
		Max = -1
		for i in pos:
			if mp[s[i]] > Max:
				Max = mp[s[i]]
				ans = i
	return ans + 1
n = int(input(''))
a = list(map(int, input('').split()))
_ = int(input(''))
m = list(map(int, input('').split()))
s = list(map(int, input('').split()))
print(solve(a, m, s))


x = int(input())
a = input()
mmap = [int(i) for i in a.split()]
dic = {}
for i in mmap:
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
x = int(input())
mmax = 0
a = input()
remember = []
cnt = 1
lista = [int(i) for i in a.split()]
for i in lista:
	if i in dic:
		if dic[i] > mmax:
			remember = [cnt]
			mmax = dic[i]
			cnt += 1
		elif dic[i] == mmax:
			remember.append(cnt)
			cnt += 1
		else:
			cnt += 1
	else:
		cnt += 1
if len(remember) != 0:
	ans = remember[0]
	cnt = 1
	mmax = 0
	a = input()
	lista = [int(i) for i in a.split()]
	for i in remember:
		if lista[i - 1] in dic:
			if dic[lista[i - 1]] >= mmax:
				mmax = dic[lista[i - 1]]
				ans = i
else:
	ans = 1
	cnt = 1
	mmax = 0
	a = input()
	lista = [int(i) for i in a.split()]
	for i in lista:
		if i in dic:
			if dic[i] >= mmax:
				ans = cnt
				mmax = dic[i]
				cnt += 1
			elif dic[i] == mmax:
				remember.append(cnt)
				cnt += 1
			else:
				cnt += 1
		else:
			cnt += 1
print(ans)


import sys
n = int(input())
s = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
vp = [0] * m
p = [0] * m
d = dict()
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in range(m):
	if b[i] in d:
		vp[i] += d[b[i]]
	if c[i] in d:
		p[i] += d[c[i]]
m1 = 0
m2 = 0
ind = 0
for i in range(m):
	if vp[i] > m1:
		m1 = vp[i]
		m2 = p[i]
		ind = i
	elif vp[i] == m1 and p[i] > m2:
		m1 = vp[i]
		m2 = p[i]
		ind = i
print(ind + 1)


n = int(input())
a = [int(i) for i in input().split(' ')]
m = int(input())
b = [int(i) for i in input().split(' ')]
c = [int(i) for i in input().split(' ')]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 1
	else:
		d[a[i]] += 1
p = [(d[b[i]] if b[i] in d else 0, d[c[i]] if c[i] in d else 0) for i in range(m)]
ans = 0
for i in range(1, m):
	if p[ans] < p[i]:
		ans = i
print(ans + 1)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
good = {}
for i in range(n):
	if a[i] in good:
		good[a[i]] += 1
	else:
		good[a[i]] = 1
res = (0, 0)
maxi = 0
for i in range(m):
	g = 0
	p = 0
	if b[i] in good:
		g = good[b[i]]
	if c[i] in good:
		p = good[c[i]]
	if g > res[0]:
		maxi = i
		res = (g, p)
	elif g == res[0] and p > res[1]:
		maxi = i
		res = (g, p)
print(maxi + 1)


n = int(input())
v = input().split(' ')
m = int(input())
a = input().split(' ')
b = input().split(' ')
mp = dict()
for i in v:
	if i in mp:
		mp[i] += 1
	else:
		mp[i] = 1
bigA = 0
bigB = 0
pos = 1
i = 0
while i < m:
	if a[i] not in mp:
		mp[a[i]] = 0
	if b[i] not in mp:
		mp[b[i]] = 0
	if mp[a[i]] > bigA:
		bigA = mp[a[i]]
		bigB = mp[b[i]]
		pos = i + 1
	elif mp[a[i]] == bigA:
		if mp[b[i]] > bigB:
			bigB = mp[b[i]]
			pos = i + 1
	i += 1
print(pos)


from collections import Counter
n = int(input())
li = list(map(int, input().split()))
lang = Counter()
ans = []
for i in li:
	lang[i] += 1
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(m):
	ans.append([lang[b[i]], lang[c[i]], i + 1])
ans.sort()
print(ans[-1][2])


n = int(input())
a = sorted(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = {}
for x in a:
	d[x] = d.get(x, 0) + 1
(m1, m2, z) = (0, 0, 0)
for i in range(m):
	if d.get(b[i], 0) > m1:
		(m1, m2, z) = (d.get(b[i], 0), d.get(c[i], 0), i)
	elif d.get(b[i], 0) == m1 and d.get(c[i], 0) > m2:
		(m2, z) = (d.get(c[i], 0), i)
print(z + 1)


from collections import Counter
try:
	while True:
		langs = Counter()
		input()
		for i in input().split():
			langs[int(i)] += 1
		input()
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		result = (0, 0)
		result_index = 1
		for (i, (x, y)) in enumerate(zip(b, c), 1):
			t = (langs[x], langs[y])
			if t > result:
				result = t
				result_index = i
		print(result_index)
except EOFError:
	pass


n = int(input())
a = [int(x) for x in input().split()]
lang = {}
for i in a:
	if i not in lang:
		lang[i] = 0
	lang[i] += 1
m = int(input())
i1 = [int(x) for x in input().split()]
i2 = [int(x) for x in input().split()]
M = [(lang[i1[i]] if i1[i] in lang else 0, lang[i2[i]] if i2[i] in lang else 0, i + 1) for i in range(m)]
M.sort()
print(M[-1][2])


n = int(input())
lang_cnt = {}
for lang in input().split():
	if lang not in lang_cnt:
		lang_cnt[lang] = 0
	lang_cnt[lang] += 1
m = int(input())
best_vp_cnt = -1
best_as_cnt = -1
best_movie = 0
audio = input().split()
subtitles = input().split()
for i in range(1, m + 1):
	vp_cnt = lang_cnt.get(audio[i - 1], 0)
	as_cnt = lang_cnt.get(subtitles[i - 1], 0)
	if vp_cnt > best_vp_cnt:
		best_vp_cnt = vp_cnt
		best_as_cnt = as_cnt
		best_movie = i
	elif vp_cnt == best_vp_cnt and as_cnt > best_as_cnt:
		best_vp_cnt = vp_cnt
		best_as_cnt = as_cnt
		best_movie = i
print(best_movie)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
freq = Counter(a)
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
best_index = 1
best_score = (0, 0)
for i in range(m):
	vs = freq[b[i]]
	als = freq[c[i]]
	if vs > best_score[0] or (vs == best_score[0] and als > best_score[1]):
		best_index = i + 1
		best_score = (vs, als)
print(best_index)


from collections import Counter
n = int(input())
languages = Counter()
sc = list(map(int, input().split(' ')))
for lang in sc:
	languages[lang] += 1
m = int(input())
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
result = []
for i in range(m):
	result.append((languages[b[i]], languages[c[i]], i))
result.sort()
print(result[-1][2] + 1)


from collections import defaultdict
n = int(input())
lang = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ind = [i for i in range(m)]
movies = [list(x) for x in zip(B, C, ind)]
lcount = defaultdict(int)
for i in lang:
	lcount[i] += 1
movies.sort(key=lambda x: (lcount[x[0]], lcount[x[1]]), reverse=True)
print(movies[0][2] + 1)


from collections import Counter
a = int(input())
b = Counter(map(int, input().split()))
z = sorted(((b[j], b[k], i) for (i, j, k) in zip(range(1, int(input()) + 1), map(int, input().split()), map(int, input().split()))))[::-1]
print(z[0][2])


import sys

def binary_search(left, right, count):
	while right - left > 1:
		middle = (left + right) // 2
		if middle * (middle + 1) // 2 < count:
			left = middle
		else:
			right = middle
	if right * (right + 1) // 2 < count:
		return right
	else:
		return left
n = int(sys.stdin.readline())
a = [int(i) for i in sys.stdin.readline().strip().split()]
m = int(sys.stdin.readline())
b = [int(i) for i in sys.stdin.readline().strip().split()]
c = [int(i) for i in sys.stdin.readline().strip().split()]
lang_cnt = {}
for lang in a:
	if lang in lang_cnt:
		lang_cnt[lang] += 1
	else:
		lang_cnt[lang] = 1
best_movie = 1
maximum_pleased = 0
maximum_almost_satisfied = 0
for i in range(m):
	pleased = 0
	if b[i] in lang_cnt:
		pleased = lang_cnt[b[i]]
	almost_satisfied = 0
	if c[i] in lang_cnt:
		almost_satisfied = lang_cnt[c[i]]
	if pleased > maximum_pleased or (pleased == maximum_pleased and almost_satisfied > maximum_almost_satisfied):
		maximum_pleased = pleased
		maximum_almost_satisfied = almost_satisfied
		best_movie = i + 1
print(best_movie)


def cmppair(a, b):
	(aa, ab) = a
	(ba, bb) = b
	if aa == ba:
		return ab > bb
	return aa > ba
n = int(input())
scientist = list(map(int, input().split()))
m = int(input())
audio = list(map(int, input().split()))
subs = list(map(int, input().split()))
cnt = {}
for i in scientist:
	if i in cnt:
		cnt[i] += 1
	else:
		cnt[i] = 1
maxpair = (0, 0)
mx = 0
for i in range(m):
	vhappy = 0 if audio[i] not in cnt else cnt[audio[i]]
	semihappy = 0 if subs[i] not in cnt else cnt[subs[i]]
	if cmppair((vhappy, semihappy), maxpair):
		maxpair = (vhappy, semihappy)
		mx = i
print(mx + 1)


d = dict()
n = int(input())
arr = list(map(int, input().split()))
for a in arr:
	if a in d:
		d[a] += 1
	else:
		d[a] = 1
m = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
hh = h = k = 0
for i in range(m):
	bb = cc = 0
	if b[i] in d:
		bb = d[b[i]]
	if c[i] in d:
		cc = d[c[i]]
	if bb > hh or (bb == hh and cc > h):
		hh = bb
		h = cc
		k = i
print(k + 1)


n = int(input())
a = list(map(int, input().split()))
m = int(input())
au = list(map(int, input().split()))
su = list(map(int, input().split()))
langs = {}
for i in a:
	if i not in langs:
		langs[i] = 1
	else:
		langs[i] += 1
ans = [0, 0]
movie = 0
for i in range(1, m + 1):
	val = [langs.get(au[i - 1], 0), langs.get(su[i - 1], 0)]
	if val > ans:
		ans = val
		movie = i
print(movie if movie > 0 else 1)


from collections import defaultdict
n = int(input())
scientist_map = defaultdict(int)
arr = [int(x) for x in input().split()]
for x in arr:
	scientist_map[x] += 1
movies = int(input())
movie_audio = [int(x) for x in input().split()]
movie_subtitles = [int(x) for x in input().split()]
best_idx = -1
highest_audio = -1
highest_subtitles = -1
for i in range(0, movies):
	if scientist_map[movie_audio[i]] > highest_audio:
		highest_audio = scientist_map[movie_audio[i]]
		highest_subtitles = scientist_map[movie_subtitles[i]]
		best_idx = i + 1
	elif scientist_map[movie_audio[i]] == highest_audio:
		if scientist_map[movie_subtitles[i]] > highest_subtitles:
			highest_subtitles = scientist_map[movie_subtitles[i]]
			best_idx = i + 1
print(best_idx)


n = int(input())
sciencist = list(map(int, input().split()))
m = int(input())
ozv_lang = list(map(int, input().split()))
sub_lang = list(map(int, input().split()))
science_dict = {}
for person in sciencist:
	try:
		science_dict[person] += 1
	except KeyError:
		science_dict[person] = 1
for i in range(m):
	try:
		c = science_dict[ozv_lang[i]]
	except KeyError:
		science_dict[ozv_lang[i]] = 0
	try:
		b = science_dict[sub_lang[i]]
	except KeyError:
		science_dict[sub_lang[i]] = 0
max_hap = 0
tmp_hap = 0
max_hap_i = 0
for i in range(m):
	if science_dict[ozv_lang[i]] > max_hap:
		max_hap = science_dict[ozv_lang[i]]
		tmp_hap = science_dict[sub_lang[i]]
		max_hap_i = i
	elif science_dict[ozv_lang[i]] == max_hap:
		if science_dict[sub_lang[i]] > tmp_hap:
			tmp_hap = science_dict[sub_lang[i]]
			max_hap_i = i
print(max_hap_i + 1)


from collections import defaultdict
n = int(input())
a = [int(_) for _ in input().split()]
m = int(input())
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
mp = defaultdict(int)
for i in a:
	mp[i] += 1
ans = [(mp[b[i]], mp[c[i]], i + 1) for i in range(m)]
ans.sort()
print(ans[-1][2])


from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n,) = gil()
s = Counter(gil())
(m,) = gil()
(a, t) = (gil(), gil())
mo = [(s.get(a[i], 0), s.get(t[i], 0), i + 1) for i in range(m)]
print(max(mo)[-1])


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
import math

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def divs(n, start=2):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors
import sys
import bisect
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
c = Counter(arr)
m = int(input())
ls = list(map(int, input().split()))
l = list(map(int, input().split()))
ansb = ansc = ans = 0
for i in range(m):
	(cntb, cntc) = (c.get(ls[i], 0), c.get(l[i], 0))
	if ansb < cntb or (ansb == cntb and ansc < cntc):
		(ansb, ansc, ans) = (cntb, cntc, i)
print(ans + 1)