Given an chess board, how many knights can we place on it so that no two knights threaten each other? For instance, we can place six knights on a board:
Input consists of several cases, each with and , both between 1 and .
For every case, print the maximum number of knights that we can place on an chess board without any threats.
Input
2 5 1 1 4 1 3 5
Output
6 1 4 8