#include #include #include using u32 = uint32_t; class FastInput { static constexpr size_t BUF_SIZE = 1 << 20; char buf[BUF_SIZE]; size_t pos = 0, len = 0; inline char getChar() { if (pos == len) { len = std::fread(buf, 1, BUF_SIZE, stdin); pos = 0; if (len == 0) return '\0'; } return buf[pos++]; } public: inline u32 readUInt() { char c = getChar(); while (c < '0' || c > '9') { c = getChar(); } u32 x = 0; do { x = x * 10 + static_cast(c - '0'); c = getChar(); } while ('0' <= c && c <= '9'); return x; } }; class FastOutput { static constexpr size_t BUF_SIZE = 1 << 20; char buf[BUF_SIZE]; size_t pos = 0; public: ~FastOutput() { flush(); } inline void flush() { if (pos) { std::fwrite(buf, 1, pos, stdout); pos = 0; } } inline void writeUInt(u32 x) { char tmp[10]; int n = 0; do { tmp[n++] = static_cast('0' + x % 10); x /= 10; } while (x); if (pos + static_cast(n) + 1 > BUF_SIZE) { flush(); } while (n--) { buf[pos++] = tmp[n]; } buf[pos++] = '\n'; } }; int main() { FastInput in; FastOutput out; const u32 H = in.readUInt(); const u32 W = in.readUInt(); // S_i を保存する。 // H <= 10^6 なので最大でも約 4 MB。 std::vector S(H); u32 T = 0; for (u32 i = 0; i < H; ++i) { u32 s = 0; for (u32 j = 0; j < W; ++j) { const u32 a = in.readUInt(); s += a; // 自動的に mod 2^32 } S[i] = s; T += s; // 自動的に mod 2^32 } for (u32 i = 0; i < H; ++i) { const u32 C = S[i] + T; // 自動的に mod 2^32 out.writeUInt(C); } return 0; }