There are two arrays of integers a and b of length n and m, respectively.
There is a chosen position in each array. Denote the chosen position in a as c and in b as d. The state is a tuple (c,d). The chosen positions are never out of bounds, i.e. 1≤c≤n and 1≤d≤m. At the start of the game both c and d are equal to 1.
Two players are playing a game taking turns alternately. On his turn each player must do one of the following:
Note that there are n⋅m states and each state appears no more than 10228−1 times. Therefore the game is finite.
The score of the game is equal to the sum of elements on the chosen positions, i.e. a_c+b_d. The player who moves first minimizes it by playing accordingly and the one who moves second maximizes it.
What is the score of the game assuming perfect play from both sides?
The first line contains two n and m (1≤n,m≤105), lengths of arrays a and b, respectively.
The second line contains n integers a_i (1≤a_i≤108), the elements of a.
The third line contains m integers b_i (1≤b_i≤108), the elements of b.
Output a single integer --- the score of the game.