#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; } template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector> A(N, vector(5)); rep(i,N)rep(j,5) cin >> A[i][j]; vector I; rep(S,1<<5) { vector sgn(5); rep(j,5) sgn[j] = (S & (1 << j) ? +1 : -1); vector J(N); iota(J.begin(), J.end(), 0); sort(J.begin(), J.end(), [&](int L, int R) { ll sumL = 0, sumR = 0; rep(j,5) { sumL += sgn[j] * A[L][j]; sumR += sgn[j] * A[R][j]; } return sumL < sumR; }); I.push_back(J[0]); I.push_back(J[N - 1]); } rep(k,N) { ll ans = 0; for(int i : I) if(i != k) { ll sum = 0; rep(j,5) sum += abs(A[k][j] - A[i][j]); chmax(ans, sum); } cout << ans << "\n"; } }