CF1206A.Choose Two Numbers

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Choose Two Numbers

You are given an array AA, consisting of nn positive integers a1,a2,,ana_1, a_2, \dots, a_n, and an array BB, consisting of mm positive integers b1,b2,,bmb_1, b_2, \dots, b_m.

Choose some element aa of AA and some element bb of BB such that a+ba+b doesn't belong to AA and doesn't belong to BB.

For example, if A=[2,1,7]A = [2, 1, 7] and B=[1,3,4]B = [1, 3, 4], we can choose 11 from AA and 44 from BB, as number 5=1+45 = 1 + 4 doesn't belong to AA and doesn't belong to BB. However, we can't choose 22 from AA and 11 from BB, as 3=2+13 = 2 + 1 belongs to BB.

It can be shown that such a pair exists. If there are multiple answers, print any.

Choose and print any such two numbers.

Input

The first line contains one integer nn (1n1001\le n \le 100) — the number of elements of AA.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai2001 \le a_i \le 200) — the elements of AA.

The third line contains one integer mm (1m1001\le m \le 100) — the number of elements of BB.

The fourth line contains mm different integers b1,b2,,bmb_1, b_2, \dots, b_m (1bi2001 \le b_i \le 200) — the elements of BB.

It can be shown that the answer always exists.

Output

Output two numbers aa and bb such that aa belongs to AA, bb belongs to BB, but a+ba+b doesn't belong to nor AA neither BB.

If there are multiple answers, print any.

Note

In the first example, we can choose 2020 from array [20][20] and 2020 from array [10,20][10, 20]. Number 40=20+2040 = 20 + 20 doesn't belong to any of those arrays. However, it is possible to choose 1010 from the second array too.

In the second example, we can choose 33 from array [3,2,2][3, 2, 2] and 11 from array [1,5,7,7,9][1, 5, 7, 7, 9]. Number 4=3+14 = 3 + 1 doesn't belong to any of those arrays.

In the third example, we can choose 11 from array [1,3,5,7][1, 3, 5, 7] and 11 from array [7,5,3,1][7, 5, 3, 1]. Number 2=1+12 = 1 + 1 doesn't belong to any of those arrays.

Samples

1
20
2
10 20
20 20
3
3 2 2
5
1 5 7 7 9
3 1
4
1 3 5 7
4
7 5 3 1
1 1

在线编程 IDE

建议全屏模式获得最佳体验