#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int **a = new int*[n];
for (int i=0;i<n;i++)
a[i] = new int [n];
int *b = new int [n];
for(int i = 0; i < n; i++){
a[i] = new int [n];
b[i] = 0;
for(int j = 0; j < n; j++){
cin>>a[i][j];
}
}
for(int i = 0; i < n; i++){
if(a[i][i] < 0){
for(int j = 0; j < i; j++){
if(a[i][j] < 0) break;
b[i]+=a[i][j];
}
}
else{
int k;
for(k = 0; k < n; k++){
if(a[i][k] >= 0) break;
}
for(int j = k; j < n; j++){
b[i]+=a[i][j];
}
}
}
for(int i = 0; i < n; i++){
cout<<b[i]<<" ";
}
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkKewoJCWludCBuOwoJCWNpbj4+bjsKCQlpbnQgKiphID0gbmV3IGludCpbbl07IAogICAgICAgIGZvciAoaW50IGk9MDtpPG47aSsrKQogICAgICAgICAgIGFbaV0gPSBuZXcgaW50IFtuXTsKICAgICAgICAKCQlpbnQgKmIgPSBuZXcgaW50IFtuXTsKCQkKCQlmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKCQkJYVtpXSA9IG5ldyBpbnQgW25dOwoJCQliW2ldID0gMDsKCQkJZm9yKGludCBqID0gMDsgaiA8IG47IGorKyl7CgkJCQljaW4+PmFbaV1bal07CgkJCX0KCQl9CgkJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CgkJCWlmKGFbaV1baV0gPCAwKXsKCQkJCWZvcihpbnQgaiA9IDA7IGogPCBpOyBqKyspewoJCQkJCWlmKGFbaV1bal0gPCAwKSBicmVhazsKCQkJCQliW2ldKz1hW2ldW2pdOwoJCQkJfQoJCQl9IAoJCQllbHNlewoJCQkJaW50IGs7CgkJCQlmb3IoayA9IDA7IGsgPCBuOyBrKyspewoJCQkJCWlmKGFbaV1ba10gPj0gMCkgYnJlYWs7CgkJCQl9CQoJCQkJZm9yKGludCBqID0gazsgaiA8IG47IGorKyl7CgkJCQkJYltpXSs9YVtpXVtqXTsKCQkJCX0KCQkJfQkKCQl9CiAJCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogCQkJY291dDw8YltpXTw8IiAiOyAKCQl9Cgl9Cg==