#include<bits/stdc++.h>
using namespace std;
#define CI const int
#define pii pair<int, int>
#define mk_p make_pair
#define gc getchar
#define Mt(a, b) memset(a, b, sizeof a)
#define pc putchar
#define W while
#define I inline
#define int long long
namespace SlowIO{
I int read() {
int x = 0, f = 1; char ch = gc();
W(ch < '0' || ch > '9') {if(ch == '-') f = -f; ch = gc();}
W(ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = gc();
return x * f;
}
I void Read(int &x) {x = read();}
I void Read(int &x, int &y) {Read(x), Read(y);}
I void write(int x) {
if(x < 0) pc('-'), x = -x;
if(x > 9) write(x / 10);
pc(x % 10 + '0');
}
I void writeln(int x) {write(x); pc('\n');}
I void Write(int x) {write(x); pc(' ');}
} using namespace SlowIO;
namespace maths{
I int max(int a, int b) {return a > b ? a : b;}
I int min(int a, int b) {return a < b ? a : b;}
I void cmax(int &x, int y) {if(x < y) x = y;}
I void cmin(int &x, int y) {if(x > y) x = y;}
I bool is_prime(int x) {
if(x == 1) return 0;
for(int i = 2; i * i <= x; i++) if(x % i == 0) return 0;
return 1;
}
I int gcd(int a, int b) {
W(a && b) {
if(a > b) a %= b;
else b %= a;
}
return max(a, b);
}
I int lcm(int a, int b) {return a * b / gcd(a, b);}
I int S(int x) {
int sum = 0;
W(x) {
sum += x % 10;
x /= 10;
}
return sum;
}
I int fan(int x) {
int sum = 0;
W(x) {
sum = sum * 10 + x % 10;
x /= 10;
}
return sum;
}
I bool sym(int x) {return x == fan(x);}
I bool Leap(int x) {return x % 400 == 0 || x % 4 == 0 && x % 100 != 0;}
} using namespace maths;
CI N = 2010;
int n, a[N], b[N], c[N];
I void merge() {
priority_queue<pii, vector<pii>, greater<pii> > q;
for(int i = 0; i < n; i++) q.push(mk_p(b[i] + a[0], 0));
for(int i = 0; i < n; i++) {
pii t = q.top(); q.pop();
int s = t.first, p = t.second; c[i] = s;
q.push(mk_p(s - a[p] + a[p + 1], p + 1));
}
for(int i = 0; i < n; i++) a[i] = c[i];
}
signed main() {
while(cin >> n) {
for(int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n);
for(int i = 1; i < n; i++) {
for(int j = 0; j < n; j++) cin >> b[j];
merge();
}
for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << '\n';
}
return 0;
}