There are two integer sequences and , each of length . The sequence satisfies . For , define .
Choose a sequence of integers such that and
Find the maximum possible value of
If , no element is taken from column .
The input is given in the following format:
For each test case, print the maximum possible value on one line.
Each case is given in the following format: