import sys from __pypy__ import newlist_hint MASK = 0xFFFFFFFF def main(): rd = sys.stdin.buffer H, W = map(int, rd.readline().split()) data = rd.read() # H = 1 の場合: # S1 = T なので、答えは 2 * 全要素和 mod 2^32 if H == 1: s = 0 x = 0 for c in data: if c > 32: x = x * 10 + c - 48 else: s += x x = 0 s += x sys.stdout.write(str((s << 1) & MASK)) return S = newlist_hint(H) append = S.append # W = 1 の場合は行和計算すら不要 if W == 1: x = 0 for c in data: if c > 32: x = x * 10 + c - 48 else: append(x) x = 0 if len(S) < H: append(x) else: x = 0 row = 0 for c in data: if c > 32: x = x * 10 + c - 48 else: row += x x = 0 if c == 10: append(row) row = 0 if len(S) < H: append(row + x) # Python の組み込み sum に任せる T = sum(S) & MASK # 巨大な入力バッファはもう不要 del data # 「T を足す」と「str 化」を同じループで行う out = newlist_hint(H) append_out = out.append for s in S: append_out(str((s + T) & MASK)) sys.stdout.write('\n'.join(out)) main()