Genetic Engineering
Genetic engineering - an area of biology dealing with development of new species of animals and plants. Recently, geneticists conducted experiments to create cutlet tree, ie tree, which, instead of apples will grow cutlets. New models created in the laboratory "XX", where they handed over for investigation in two other laboratories. Each sample is complex and costly experiments in each of these laboratories: one analyzed the possibility of chops on crisp, and the second - the productivity of the trees. Results of experiments in each laboratory, placed on a special magazine:
In the first laboratory in the magazine consistently carry the number of samples that have consistently appeared crisp,
In the second laboratory in its journal consistently carry the number of samples, the yield of which was at least a hundred hamburgers a year.
Experiments were long and complex. In the end, each of the laboratories said that the observations in journals contain the numbers of successful samples. But people need trees, and have those and other property! As a result, there was the task of finding some of the numbers of the sample, which is in the list of successful experiments, each of the laboratories. Vascha task - to write such a program.
Input In the first line write the number N (0 ≤ N ≤ 100000) - number of records in the first journal. After a given N numbers arranged in ascending order (a number of good samples from the journal of the first lab). On the next line is given by M, not exceeding 100,000, followed by M numbers, ordered in ascending order. The numbers in the array does not exceed 10^9 in absolute value (a number of good samples from the magazine a second laboratory). Output Display the maximum required number of possible, if it exists. If it's not, then print out the number of -1.