CF245D.Restoring Table

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative 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 non-negative integers a1,a2,...,ana_{1},a_{2},...,a_{n} . He also wrote a square matrix bb of size n×nn×n . The element of matrix bb that sits in the ii -th row in the jj -th column (we'll denote it as bijb_{ij} ) equals:

  • the "bitwise AND" of numbers aia_{i} and aja_{j} (that is, b_{ij}=a_{i} & a_{j} ), if iji≠j ;
  • -1, if i=ji=j .

Having written out matrix bb , Polycarpus got very happy and wiped aa 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 bb , restore the sequence of numbers a1,a2,...,ana_{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 10910^{9} .

输入格式

The first line contains a single integer nn (1<=n<=100)(1<=n<=100) — the size of square matrix bb . Next nn lines contain matrix bb . The ii -th of these lines contains nn space-separated integers: the jj -th number represents the element of matrix bijb_{ij} . It is guaranteed, that for all ii (1<=i<=n)(1<=i<=n) the following condition fulfills: biib_{ii} = -1. It is guaranteed that for all i,ji,j (1<=i,j<=n; ij)(1<=i,j<=n; i≠j) the following condition fulfills: 0<=bij<=1090<=b_{ij}<=10^{9} , bij=bjib_{ij}=b_{ji} .

输出格式

Print nn non-negative integers a1,a2,...,ana_{1},a_{2},...,a_{n} (0<=ai<=109)(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 aa that satisfies the problem conditions. If there are multiple such sequences, you are allowed to print any of them.

输入输出样例

  • 输入#1

    1
    -1
    

    输出#1

    0 
  • 输入#2

    3
    -1 18 0
    18 -1 0
    0 0 -1
    

    输出#2

    18 18 0 
  • 输入#3

    4
    -1 128 128 128
    128 -1 148 160
    128 148 -1 128
    128 160 128 -1
    

    输出#3

    128 180 148 160 

说明/提示

If you do not know what is the "bitwise AND" operation please read: http://en.wikipedia.org/wiki/Bitwise_operation.

首页