Algorithm


A. Choose Two Numbers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array A">A, consisting of n">n positive integers a1,a2,…,an">a1,a2,,an�1,�2,…,��, and an array B">B, consisting of m">m positive integers b1,b2,…,bm">b1,b2,,bm�1,�2,…,��.

Choose some element a">a of A">A and some element b">b of B">B such that a+b">a+b�+� doesn't belong to A">A and doesn't belong to B">B.

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

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 n">n (1≤n≤100">1n1001≤�≤100) — the number of elements of A">A.

The second line contains n">n integers a1,a2,…,an">a1,a2,,an�1,�2,…,�� (1≤ai≤200">1ai2001≤��≤200) — the elements of A">A.

The third line contains one integer m">m (1≤m≤100">1m1001≤�≤100) — the number of elements of B">B.

The fourth line contains m">m different integers b1,b2,…,bm">b1,b2,,bm�1,�2,…,�� (1≤bi≤200">1bi2001≤��≤200) — the elements of B">B.

It can be shown that the answer always exists.

Output

Output two numbers a">a and b">b such that a">a belongs to A">Ab">b belongs to B">B, but a+b">a+b�+� doesn't belong to nor A">A neither B">B.

If there are multiple answers, print any.

Examples
input
Copy
1
20
2
10 20
output
Copy
20 20
input
Copy
3
3 2 2
5
1 5 7 7 9
output
Copy
3 1
input
Copy
4
1 3 5 7
4
7 5 3 1
output
Copy
1 1
Note

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

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

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

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n, m, maxx = 0, maxy = 0;
  cin>>n;
  int x;
  for(int i = 0; i  <  n; i++){
    cin>>x;
    maxx = x > maxx ? x : maxx;
  }
  cin>>m;
  for(int i = 0; i  <  m; i++){
    cin>>x;
    maxy = x > maxy ? x : maxy;
  }
  cout<<maxx<<" "<<maxy<<endl;
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1
20
2
10 20

Output

x
+
cmd
20 20
Advertisements

Demonstration


Codeforcess solution 1206-A A. Choose Two Numbers C++, Java, Js and Python,1206-A, Codeforcess solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+