#SFJSJJZN0X05D1. Cinema

Cinema

题目描述

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

In the evening after the conference, all nn scientists decided to go to the cinema. There are mm 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(1n200000)n (1 ≤ n ≤ 200 000) — the number of scientists.

The second line contains nn positive integers a1,a2,...,an(1ai109)a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where aia_i is the index of a language, which the i-th scientist knows.

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

The fourth line contains mm positive integers b1,b2,...,bm(1bj109)b_1, b_2, ..., b_m (1 ≤ b_j \leq 10^9), where bjb_j is the index of the audio language of the j-th movie.

The fifth line contains mm positive integers c1,c2,...,cm(1cj109)c_1, c_2, ..., c_m (1 ≤ c_j ≤ 10^9), where cjc_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 bjcjb_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 last of them.

Examples

3
2 3 2
2
3 2
2 3
2

Note

In the first sample, scientists must go to the movie with the index 22, 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.

Limitation

2s, 256MiB for each test case.

Source

CodeForces 670C or acwing103

一句话题意

莫斯科正在举办一个大型国际会议,有 nn 个来自不同国家的科学家参会。

每个科学家都只懂得一种语言。

为了方便起见,我们把世界上的所有语言用 1110910^9 之间的整数编号。

在会议结束后,所有的科学家决定一起去看场电影放松一下。

他们去的电影院里一共有 mm 部电影正在上映,每部电影的语音和字幕都采用不同的语言。

对于观影的科学家来说,如果能听懂电影的语音,他就会很开心;如果能看懂字幕,他就会比较开心;如果全都不懂,他就会不开心。

现在科学家们决定大家看同一场电影。

请你帮忙选择一部电影,可以让观影很开心的人最多。

如果有多部电影满足条件,则在这些电影中挑选观影比较开心的人最多的那一部,如果比较开心的人也一样,选编号最大的。(仅本测试系统)