/ spv / 题库 /

Cinema

Cinema

Description

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 \le n \le 2 \times 10^5)\) — the number of scientists.

The second line contains n positive integers \(a_1, a_2, \cdots, a_n (1 \le ai \le 109)\), where \(a_i\) is the index of a language, which the i-th scientist knows.

The third line contains one positive integer \(m (1 \le m \le 2\times 10^5)\) — the number of movies in the cinema.

The fourth line contains \(m\) positive integers \(b_1, b_2, \cdots, b_m (1 \le b_j \le 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, \cdots, c_m (1 \le cj \le 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 \not= 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.

Simplified

莫斯科在举办一场重要的有 \(n\) 个不同国家的科学家参与的国际会议,每个科学家都只会一种语言。为了方便起见,我们规定一种语言用 \(1\) 到 \(10^9\) 的数来描述。

在会议之后的晚上,科学家们决定去看电影。他们去的电影院有 \(m\) 场电影,每场有两个不同的数字,分别代表配音的语言和字幕的语言。

  • 如果一个科学家能听懂配音,他会非常愉悦;
  • 如果能看懂字幕,他会比较满意。
  • 如果既看不懂也听不懂,他会很生气。

科学家们决定去看同一场电影,你必须帮助他们选择一场电影,让愉悦的人最多的前提下,比较满意的人最多。

输出一个整数表示安排哪一场电影。 如果有多种情况,选择编号最大的输出。

输入格式: 第一行一个整数 \(n(1 \leq n \leq 200000)\) , 第二行 \(n\) 个整数 \(a_1, a_2, ..., a_n(1 \leq a_i \leq 10^9)\) 表示科学家们会的语言, 第三行一个整数 \(m(1 \leq m \leq 200000)\), 第四行 \(m\) 个整数 \(b_1, b_2, ..., b_n(1 \leq b_j \leq 10^9)\) 表示电影的配音用的语言, 第五行 \(m\) 个整数 \(c_1, c_2, ..., c_n(1 \leq c_j \leq 10^9)\) 表示电影的字幕用的语言。

Samples

Sample #1

Input

3
2 3 2
2
3 2
2 3

Output

2

Sample #2

Input

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

Output

3

Source

算法竞赛进阶指南 Codeforces

信息

ID
1015
难度
9
分类
(无)
标签
(无)
递交数
4
已通过
2
通过率
50%
上传者