#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll MAX_N = 2e5; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll N; cin >> N; vector> X(N, vector(5)); rep(i, N) rep(j, 5) cin >> X[i][j]; vector> sum(32, vector(N, 0)); for(ll bit=0; bit<32; bit++){ rep(i, N){ rep(j, 5){ if((bit>>j)&1){ sum[bit][i] += X[i][j]; }else{ sum[bit][i] -= X[i][j]; } } } } vector> sum_sort(32, vector(N, 0)); rep(bit, 32) rep(i, N) sum_sort[bit][i] = sum[bit][i]; rep(bit, 32) sort(all(sum_sort[bit])); ll MASK = 31; rep(k, N){ ll ans = 0; rep(bit, 32){ ans = max(ans, sum[bit][k] + sum_sort[bit^MASK].back()); } cout << ans << endl; } }