#include #include using namespace std; namespace my{ #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define VVL(n,m,...) vec>__VA_ARGS__;setsize({n,m},__VA_ARGS__);lin(__VA_ARGS__) #define FO(n) for(ll ij=n;ij--;) #define FOR(i,...) for(auto[i,i##stop,i##step]=range(0,__VA_ARGS__);i=i##stop;i-=i##step) #define fe(a,i,...) for(auto&&__VA_OPT__([)i __VA_OPT__(,__VA_ARGS__]):a) #define single_testcase void solve();}int main(){my::io();my::solve();}namespace my{ void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<constexpr auto range(bool s,A...a){arrayr{0,0,1};ll I=0;((r[I++]=a),...);if(!s&&I==1)swap(r[0],r[1]);r[0]-=s;return r;} constexpr char nl=10; constexpr char sp=32; constexpr auto zz(auto x){return x<0?-x:x;} constexpr ll pw2(ll n){return 1LL<>i&1;} constexpr ll log2_floor(auto x){ll r=0;while(x>1)x>>=1,++r;return r;} bool amax(auto&a,const auto&b){return aostream&operator<<(ostream&o,const multiset&s){fe(s,e)o<struct multiset:std::multiset{ multiset(const initializer_list&a={}){fe(a,e)this->emplace(e);} multiset(const vector&a){fe(a,e)this->emplace(e);} }; templatestruct set:multiset{ using multiset::multiset; }; templateconcept vectorial=is_base_of_v,V>; templatestruct vec_attr{using core_type=T;static constexpr int d=0;}; templatestruct vec_attr{using core_type=typename vec_attr::core_type;static constexpr int d=vec_attr::d+1;}; templateusing core_t=vec_attr::core_type; templateistream&operator>>(istream&i,vector&v){fe(v,e)i>>e;return i;} templateostream&operator<<(ostream&o,const vector&v){fe(v,e)o<?nl:sp);return o;} templatestruct vec:vector{ using vector::vector; vec(const vector&v){vector::operator=(v);} vec&operator^=(const vec&u){this->insert(this->end(),u.begin(),u.end());return*this;} vec operator^(const vec&u)const{return vec{*this}^=u;} vec&operator++(){fe(*this,e)++e;return*this;} vec&operator--(){fe(*this,e)--e;return*this;} vec operator-()const{vec v=*this;fe(v,e)e=-e;return v;} }; templateauto make_vec(const ll(&s)[n],T x={}){if constexpr(n==i+1)return vec(s[i],x);else{auto X=make_vec(s,x);return vec(s[i],X);}} templatevoid setsize(const ll(&l)[n],A&...a){((a=make_vec(l,core_t())),...);} templatestruct infinity{ templateconstexpr operator T()const{return numeric_limits::max()*(1-is_negative*2);} templateconstexpr operator T()const{return static_cast(*this);} templateconstexpr bool operator==(T x)const{return static_cast(*this)==x;} constexpr auto operator-()const{return infinity();} }; constexpr infinity oo; void lin(auto&...a){(cin>>...>>a);} templatevoid pp(const auto&...a){ll n=sizeof...(a);((cout<0,c)),...);cout<struct segtree{ ll n,A,log;vecd; segtree(ll n):segtree(vec(n,e())){} segtree(const vec&v):n(v.size()){log=log2_floor((n-1)|1)+1,A=pw2(log),d.resize(A*2,e());fo(i,n)d[i+A]=v[i];of(i,A-1)update(i+1);} ll size()const{return n;} void update(ll i){d[i]=op(d[i*2],d[i*2+1]);} void set(ll i,S x){assert(0<=i&&i>j);} S get(ll i)const{assert(0<=i&&i>=1,r>>=1;} return op(sml,smr); } friend auto&operator<<(ostream&o,const segtree&s){fo(i,s.size())o<T sgt_e(){return x;} templateT sgt_max(T a,T b){return bT sgt_min(T a,T b){return astruct segmax:atcoder::segtree,sgt_e>{ using atcoder::segtree,sgt_e>::segtree; }; templatestruct segmin:atcoder::segtree,sgt_e>{ using atcoder::segtree,sgt_e>::segtree; }; } single_testcase void solve(){ LL(N); constexpr ll A=5; VVL(N,A,a); vec>smax(pw2(A),sgt::segmax(N)); vec>smin(pw2(A),sgt::segmin(N)); fo(i,N){ fo(S,pw2(A)){ ll t=0; fo(j,A){ if(at2(S,j))t+=a[i][j]; else t-=a[i][j]; } smax[S].set(i,t); smin[S].set(i,t); } } fo(i,N){ ll res=0; fo(S,pw2(A)){ ll xi=smax[S].get(i); amax(res,zz(xi-smax[S].prod(0,N))); amax(res,zz(xi-smin[S].prod(0,N))); } pp(res); } }}