Peaceful Horses
Consider the following problem: You have a standard chessboard with dimensions 8×8. Your task is to place N knights on the board such that no two knights can attack each other. Additionally, you must ensure that exactly r_i knights are placed in the i-th row, and exactly c_j knights are placed in the j-th column. The total number of knights, N, is equal to the sum of all r_i and also equal to the sum of all c_j. A knight moves in an "L" shape: two squares in one direction and then one square perpendicular, or one square in one direction and then two squares perpendicular. A knight attacks all squares where it can potentially move. No square can have more than one knight.
Your goal is to determine the values of c_j given the values of r_i such that the problem has exactly one solution.
Input
The first line of the input contains eight integers: r_1, r_2, ..., r_8 (0 ≤ r_i ≤ 8).
Output
Output eight integers: c_1, c_2, ..., c_8 (0 ≤ c_j ≤ 8). If it is impossible to determine these numbers as required, output eight -1s. If multiple solutions exist, provide the lexicographically smallest one (i.e., the smallest possible value for c_1; if there are ties, then the smallest possible value for c_2, and so on).