#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include using namespace std; using namespace __gnu_pbds; // #include // using mint = atcoder::modint998244353; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) // const ll dy[] = {-1, -1, -1, 0, 0, 1, 1, 1}; // const ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}; const ll dy[] = {-1, 0, 0, 1}; const ll dx[] = {0, -1, 1, 0}; template bool isrange(T target, T1 low, T2 high) { return low <= target && target < high; } template T min(const T &t, const U &u) { return t < u ? t : u; } template T max(const T &t, const U &u) { return t < u ? u : t; } template bool chmin(T &t, const U &u) { if (t > u) { t = u; return true; } return false; } template bool chmax(T &t, const U &u) { if (t < u) { t = u; return true; } return false; } template using hash_map = gp_hash_table; template using hash_set = gp_hash_table; // #include "titan_cpplib/others/io.cpp" /// https://github.com/titan-23/Library_cpp/blob/main/titan_cpplib/others/io.cpp #include #include using namespace std; namespace titan23 { // 参考: https://qiita.com/nojima/items/57b9d39d7d73362ac883 class Scanner { private: vector buffer; ssize_t n_written; ssize_t n_read; void do_read() { ssize_t r = read(0, &buffer[0], buffer.size()); if (r < 0) throw runtime_error(strerror(errno)); n_written = r; n_read = 0; } inline int next_char() { ++n_read; if (n_read == n_written) { do_read(); } return current_char(); } inline int current_char() { return (n_read == n_written) ? EOF : buffer[n_read]; } public: Scanner(): buffer(1<<20) { do_read(); } int64_t read_int64() { int64_t ret = 0, sgn = 1; int ch = current_char(); while (isspace(ch)) { ch = next_char(); } if (ch == '-') { sgn = -1; ch = next_char(); } for (; isdigit(ch); ch = next_char()) ret = (ret * 10) + (ch - '0'); return sgn * ret; } char read_char() { int ch = current_char(); while (isspace(ch)) { ch = next_char(); } next_char(); return ch; } string read_string() { string ret; int ch = current_char(); while (isspace(ch)) { ch = next_char(); } while (!isspace(ch) && ch != EOF) { ret += ch; ch = next_char(); } return ret; } } scanner; } // namespace titan23 int64_t read_int64() { return titan23::scanner.read_int64(); } // #include "titan_cpplib/others/print.cpp" void solve() { int h = read_int64(), w = read_int64(); vector S(h); ll T = 0; rep(i, h) { uint32_t s = 0; rep(j, w) { ll a = read_int64(); s += a; } T += s; S[i] = s; } rep(i, h) { cout << S[i]+T << "\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); int t = 1; // cin >> t; for (int i = 0; i < t; ++i) { solve(); } return 0; }