[HomeTrainingProblemsContestsC Language]  [LoginRegister] 
Problems Status Rank 
Problem 1375
Restoring Table
Time Limit: 1000ms
Memory Limit: 65536kb Description
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of nonnegative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation. For that Polycarpus came to school a little earlier and wrote on the board a sequence of nonnegative integers a_{1}, a_{2}, ..., a_{n}. He also wrote a square matrix b of size n × n. The element of matrix b that sits in the ith row in the jth column (we'll denote it as b_{ij}) equals:
Having written out matrix b, Polycarpus got very happy and wiped a off the blackboard. But the thing is, the teacher will want this sequence to check whether Polycarpus' calculations were correct. Polycarus urgently needs to restore the removed sequence of integers, or else he won't prove that he can count correctly. Help Polycarpus, given matrix b, restore the sequence of numbers a_{1}, a_{2}, ..., a_{n}, that he has removed from the board. Polycarpus doesn't like large numbers, so any number in the restored sequence mustn't exceed 10^{9}. Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the size of square matrix b. Next n lines contain matrix b. The ith of these lines contains n spaceseparated integers: the jth number represents the element of matrix b_{ij}. It is guaranteed, that for all i (1 ≤ i ≤ n)the following condition fulfills: b_{ii} = 1. It is guaranteed that for all i, j (1 ≤ i, j ≤ n; i ≠ j) the following condition fulfills: 0 ≤ b_{ij} ≤ 10^{9}, b_{ij} = b_{ji}. Output
Print n nonnegative integers a_{1}, a_{2}, ..., a_{n} (0 ≤ a_{i} ≤ 10^{9}) — the sequence that Polycarpus wiped off the board. Separate the numbers by whitespaces. It is guaranteed that there is sequence a that satisfies the problem conditions. If there are multiple such sequences, you should print the one which has minimum sum. Sample Input
4 1 128 128 128 128 1 148 160 128 148 1 128 128 160 128 1 4 1 128 128 128 128 1 148 160 128 148 1 128 128 160 128 1 Sample Output
128 180 148 160 128 180 148 160 Hint
思考：对于给定的矩阵b，其对应的数字序列是唯一的么？如果不唯一，那怎样找出所有解呢？注意：有多个输入实例。 Source
CodeForces 245D
