// https://judge.yosupo.jp/submission/356599 #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" // #include "titan_cpplib/ahc/timer.cpp" // https://judge.yosupo.jp/problem/many_aplusb #include namespace debug { } // namespace debug #ifdef LOCAL #define CHECK(expr) assert(expr) #else #define CHECK(expr) void(0) #endif #ifndef __SIZEOF_INT128__ #error "This library requires compiler support for __int128." #endif namespace internal { template concept same_as = std::same_as, std::remove_cvref_t>; template concept basic_signed_integral = std::signed_integral> && !same_as; template concept basic_unsigned_integral = std::unsigned_integral> && !same_as; template concept basic_integral = basic_signed_integral || basic_unsigned_integral; template concept signed_integral = basic_signed_integral || same_as; template concept unsigned_integral = basic_unsigned_integral || same_as; template concept integral = signed_integral || unsigned_integral; template struct make_unsigned : std::make_unsigned> {}; template requires(same_as || same_as) struct make_unsigned { using type = __uint128_t; }; template using make_unsigned_t = typename make_unsigned::type; } // namespace internal #ifdef __unix__ #ifndef DISABLE_MMAP #define ENABLE_MMAP #include #include #include #endif #endif namespace fast_io { template struct FastInput { FILE* file; char* buf; char* cur; char* end; size_t map_size; explicit FastInput(FILE* _file = stdin) : file(_file) { #ifdef ENABLE_MMAP struct stat st; int fd = fileno(file); fstat(fd, &st); map_size = st.st_size; buf = cur = static_cast( mmap(nullptr, map_size, PROT_READ, MAP_PRIVATE, fd, 0)); end = cur + map_size; #else cur = buf = new char[BufSize + 64]; end = buf + fread(buf, 1, BufSize, file); memset(const_cast(end), 0, 64); #endif } #ifdef ENABLE_MMAP ~FastInput() { munmap(buf, map_size); } #else ~FastInput() { delete[] buf; } #endif void ensure() { #ifndef ENABLE_MMAP int rem = end - cur; if (rem >= 40) [[likely]] return; if (rem > 0 && cur != buf) memmove(buf, cur, rem); cur = buf; end = buf + rem + fread(buf + rem, 1, BufSize - rem, file); memset(const_cast(end), 0, 64); #endif } void skip_space() { ensure(); while (*cur < 33) [[unlikely]] { ++cur; ensure(); } } template requires(internal::same_as) T read() { ensure(); CHECK(*cur == '0' || *cur == '1'); T x = *cur & 1; cur += 2; return x; } template T read_small() { ensure(); CHECK(*cur >= '0' && *cur <= '9'); T x = *cur++ & 15; uint32_t v; memcpy(&v, cur, 4); v ^= 0x30303030; if (all_digits(v)) { v = (v * 10 + (v >> 8)) & 0xff00ff; v = (v * 100 + (v >> 16)) & 0xffff; x = x * 10000 + v, cur += 4; } for (; *cur >= 48; ++cur) { x = x * 10 + *cur - 48; } ++cur; return x; } template T read_small() { using U = internal::make_unsigned_t; bool neg = (*cur == '-'); cur += neg; U v = read_small(); return static_cast(neg ? -v : v); } template requires(sizeof(T) < 8) T read() { ensure(); CHECK(*cur >= '0' && *cur <= '9'); T x = *cur++ & 15; uint64_t v; memcpy(&v, cur, 8); v ^= 0x3030303030303030ull; if (all_digits(v)) { v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ffull; v = (v * 100 + (v >> 16)) & 0xffff0000ffffull; v = (v * 10000 + (v >> 32)) & 0xffffffffull; x = x * 100000000 + v, cur += 8; } for (; *cur >= 48; ++cur) { x = x * 10 + *cur - 48; } ++cur; return x; } template requires(sizeof(T) == 8) T read() { ensure(); CHECK(*cur >= '0' && *cur <= '9'); union { char ch[16]; uint64_t v[2]; }; memcpy(ch, cur, 16); uint64_t a = v[0] ^ 0x3030303030303030ull; uint64_t b = v[1] ^ 0x3030303030303030ull; T x = 0; if (all_digits(a)) { x = a = parse(a), cur += 8; if (all_digits(b)) { x = a * 100000000 + parse(b), cur += 8; if (~LUT[*reinterpret_cast(cur)]) { x = x * 100 + LUT[*reinterpret_cast(cur)]; cur += 2; } } } for (; *cur >= 48; ++cur) { x = x * 10 + (*cur & 15); } ++cur; return x; } template requires(sizeof(T) > 8) T read() { ensure(); CHECK(*cur >= '0' && *cur <= '9'); T x = 0; for (int i = 0; i < 4; ++i) { uint64_t v; memcpy(&v, cur, 8); v ^= 0x3030303030303030ull; if (!all_digits(v)) break; v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ffull; v = (v * 100 + (v >> 16)) & 0xffff0000ffffull; v = (v * 10000 + (v >> 32)) & 0xffffffffull; if (i != 0) x *= 100000000; x += v, cur += 8; } uint32_t v; memcpy(&v, cur, 4); v ^= 0x30303030; uint32_t val = 0, pow = 1; if (all_digits(v)) { v = (v * 10 + (v >> 8)) & 0xff00ff; v = (v * 100 + (v >> 16)) & 0xffff; val = v, pow = 10000, cur += 4; } for (; *cur >= 48; ++cur) { val = val * 10 + *cur - 48, pow *= 10; } x = x * pow + val; ++cur; return x; } template T read() { using U = internal::make_unsigned_t; bool neg = (*cur == '-'); cur += neg; U v = read(); return static_cast(neg ? -v : v); } template requires(internal::same_as) T read() { ensure(); T x = *cur; cur += 2; return x; } template requires(internal::same_as) T read() { ensure(); CHECK(*cur > 32); #ifdef ENABLE_MMAP char* first = cur; while (*cur > 32) ++cur; std::string s(first, cur); ++cur; return s; #else std::string s; while (true) { char* last = cur; while (last < end && *last > 32) ++last; if (last < end) { s.append(cur, last); cur = last + 1; return s; } else { s.append(cur, last); cur = end; ensure(); } } #endif } template FastInput& operator>>(T& x) { skip_space(); x = read(); return *this; } FastInput& operator>>(char* s) { skip_space(); while (*cur > 32) { *s++ = *cur++; ensure(); } *s = 0, ++cur; return *this; } private: static constexpr auto LUT = [] { std::array a; std::fill(a.begin(), a.end(), -1); for (int i = 48; i < 58; ++i) { for (int j = 48; j < 58; ++j) { a[i | j << 8] = (i - 48) * 10 + (j - 48); } } return a; }(); constexpr bool all_digits(uint32_t v) { return !(v & 0xf0f0f0f0); } constexpr bool all_digits(uint64_t v) { return !(v & 0xf0f0f0f0f0f0f0f0ull); } constexpr uint32_t parse(uint32_t v) { v = (v * 10 + (v >> 8)) & 0xff00ff; v = (v * 100 + (v >> 16)) & 0xffff; return v; } constexpr uint64_t parse(uint64_t v) { v = (v * 10 + (v >> 8)) & 0xff00ff00ff00ffull; v = (v * 100 + (v >> 16)) & 0xffff0000ffffull; v = (v * 10000 + (v >> 32)) & 0xffffffffull; return v; } }; struct EndLine { } endl; template struct FastOutput { FILE* file; char* buf; char* cur; char* end; explicit FastOutput(FILE* _file = stdout) : file(_file) { cur = buf = new char[BufSize]; end = buf + BufSize; } template void flush() { if (end - cur < N) [[unlikely]] { fwrite(buf, 1, cur - buf, file); cur = buf; } } ~FastOutput() { flush(); delete[] buf; } template requires(sizeof(T) < 8) void write(T x) { if (x > 9999'9999) { print<2>(x); } else if (x > 9999) { print<1>(x); } else { print<0>(x); } } template requires(sizeof(T) == 8) void write(T x) { if (x > 9999'9999'9999'9999ull) { print<4>(x); } else if (x > 9999'9999'9999ull) { print<3>(x); } else if (x > 9999'9999) { print<2>(x); } else if (x > 9999) { print<1>(static_cast(x)); } else { print<0>(static_cast(x)); } } template requires(sizeof(T) > 8) void write(T x) { if (x < E19) { write(static_cast(x)); } else if (x < E38) { auto high = x / E19; auto low = x - high * E19; write(static_cast(high)); print_E19(static_cast(low)); } else [[unlikely]] { auto high = x / E38; x -= high * E38; auto mid = x / E19; auto low = x - mid * E19; write(static_cast(high)); print_E19(static_cast(mid)); print_E19(static_cast(low)); } } template FastOutput& operator<<(T x) { flush::digits10 + 1>(); write(x); return *this; } template FastOutput& operator<<(T x) { using U = internal::make_unsigned_t; flush::digits10 + 2>(); *cur = '-'; cur += (x < 0); write(x < 0 ? -static_cast(x) : static_cast(x)); return *this; } FastOutput& operator<<(bool x) { flush<1>(); *cur++ = x + '0'; return *this; } FastOutput& operator<<(char x) { flush<1>(); *cur++ = x; return *this; } FastOutput& operator<<(const char* s) { uint32_t len = strlen(s); if (len > BufSize) [[unlikely]] { flush(); do { fwrite(s, 1, BufSize, file); s += BufSize; len -= BufSize; } while (len > BufSize); } if (end - cur < len) [[unlikely]] flush(); memcpy(cur, s, len); cur += len; return *this; } FastOutput& operator<<(char* s) { return *this << const_cast(s); } FastOutput& operator<<(const std::string& s) { return *this << s.c_str(); } FastOutput& operator<<(const EndLine& end_line) { flush<1>(); *cur++ = '\n'; flush(); return *this; } private: static constexpr auto LUT = [] { std::array, 10000> a, b; for (int i = 0; i < 10000; ++i) { b[i][0] = '0' + i / 1000; b[i][1] = '0' + i / 100 % 10; b[i][2] = '0' + i / 10 % 10; b[i][3] = '0' + i % 10; int j = 0; if (i >= 1000) a[i][j++] = b[i][0]; if (i >= 100) a[i][j++] = b[i][1]; if (i >= 10) a[i][j++] = b[i][2]; a[i][j] = b[i][3]; } return std::make_pair(a, b); }(); static constexpr auto E16 = 10'000'000'000'000'000ull; static constexpr auto E19 = E16 * 1000; static constexpr auto E38 = static_cast<__uint128_t>(E19) * E19; template void print_unit(uint32_t x) { if constexpr (head) { memcpy(cur, &LUT.first[x], 4); cur += 1 + (x > 9) + (x > 99) + (x > 999); } else { memcpy(cur, &LUT.second[x], 4); cur += 4; } } template void print(T x) { if constexpr (N == 0) { print_unit(x); } else { print(x / 10000); print_unit(x % 10000); } } void print_E19(uint64_t x) { auto high = static_cast(x / E16); auto low = x - high * E16; memcpy(cur, &LUT.second[high][1], 3); cur += 3; print<3, false>(low); } }; template struct FastIO { FastInput* in; FastOutput* out; FastIO() : in(nullptr), out(nullptr) {} ~FastIO() { if (in != nullptr) delete in; if (out != nullptr) { out->flush(); delete out; } } void init(FILE* input_file = stdin, FILE* output_file = stdout) { in = new FastInput(input_file); out = new FastOutput(output_file); } void flush() { out->flush(); } template FastIO& operator>>(T& x) { *in >> x; return *this; } template FastIO& operator<<(const T& x) { *out << x; return *this; } FastIO& operator<<(const EndLine& x) { *out << x; return *this; } }; } // namespace fast_io using fast_io::FastIO; using namespace std; FastIO<1 << 21, 1 << 20> io; // void solve_main() { // int n; // io >> n; // while (n--) { // io << io.in->read() + io.in->read() << '\n'; // } // } // int main() { // #ifdef LOCAL // assert(freopen("test.in", "r", stdin)); // assert(freopen("test.out", "w", stdout)); // #endif // // cin.tie(nullptr)->sync_with_stdio(false); // io.init(); // int T; // // cin >> T; // // io >> T; // T = 1; // while (T--) { // solve_main(); // } // return 0; // } void solve() { const uint64_t msk = (1ull << 32)-1; int h = io.in->read(), w = io.in->read(); vector> A(h, vector(w)); rep(i, h) rep(j, w) A[i][j] = io.in->read(); uint32_t T = 0; rep(i, h) { uint32_t s = 0; rep(j, w) { s += A[i][j]; s &= msk; } s &= msk; T += s; T &= msk; A[i][0] = s; } rep(i, h) { io << ((A[i][0]+T)&msk) << "\n"; } } int main() { // ios::sync_with_stdio(false); // cin.tie(0); io.init(); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); int t = 1; // cin >> t; for (int i = 0; i < t; ++i) { solve(); } return 0; }