Go Back

##### Consistent brand (100)

Description

**Problem Author: Kaustubh Badrike**

As always, Raju the marketing coordinator is looking for sponsors to the upcoming fest. This time, he’s set his sights on notebook brands. To compare brands, he’s collected **N** notebooks from all over the campus. However, he doesn’t want just any brand, he’s looking for a brand with the longest consistent streak.

A brand is said to have a consistent streak if the number of pages of the brand’s **i**^{th} occurrence is the same as the number of pages of the brand’s **(i+1)**^{th} occurrence. If two brands have the same length of the longest consistent streak, the brand with more number of pages in it’s longest consistent streak is preferred. If the number of pages in the longest consistent streak is also the same for two brands, the brand appearing earlier in the dictionary is preferred.

Input

The first line of input contains an integer **T** denoting the number of test cases. Each test case consists of three lines.

The first line of each test case consists of a single integer, **N**.

The second line consists of **N** space-separated strings, where the **n**^{th} string denotes the brand of the **n**^{th} notebook.

The third line consists of **N** space-separated integers, where the **n**^{th} integer denotes the number of pages of the **n**^{th} notebook.

Output

For each test case, output a single line with the brand having the longest consistent streak.

Constraints

1 <= **T**, **N**, **pages of notebook** <= 100

1<= **|brand name|** <=10

Example

Copy Input

**Input**:

1

9

A C B C B A B C A

2 6 7 4 5 4 5 6 8**Output**:

B

Explanation

The 2^{nd} and 3^{rd} occurrences of B have the same number of pages (5). Hence the brand B has the longest consistent streak (length 2).