import sys try: from __pypy__.builders import StringBuilder as _StringBuilder except ImportError: from io import StringIO as _StringIO class _StringBuilder(_StringIO): append = _StringIO.write build = _StringIO.getvalue class FastIO: """Bulk input and buffered text output for non-interactive problems. Input is a blocking binary stream (default: sys.stdin.buffer); output is a text stream (default: sys.stdout). ASCII whitespace separates tokens. Integers must be decimal with an optional '+' or '-'; strings must be UTF-8. Token reads raise EOFError at end of input. Invalid tokens are unsupported. The first read consumes all input in O(input size) time and memory. Integers are parsed directly from bytes without allocating token strings. Construction is O(1). Output is retained until an explicit flush(); streams and global input/print are never replaced. PyPy uses its built-in string builder; other Python runtimes use io.StringIO. """ def __init__(self, reader=None, writer=None): self._reader = sys.stdin.buffer if reader is None else reader self._writer = sys.stdout if writer is None else writer self._data = b"\xff" self._loaded = False self._index = 0 self._output = _StringBuilder() def read_int(self) -> int: """Read an integer in O(skipped whitespace + digits), excluding first read.""" data = self._data index = self._index while data[index] < 45: index += 1 if data[index] == 255: if self._loaded: self._index = index raise EOFError self._data = self._reader.read() + b" \xff" self._loaded = True return self.read_int() negative = data[index] == 45 index += negative value = data[index] & 15 index += 1 while data[index] >= 48: value = value * 10 + (data[index] & 15) index += 1 self._index = index + 1 return -value if negative else value def read_ints(self, count: int) -> list: """Read count >= 0 integers across lines; O(consumed bytes + count), excluding first read.""" return [self.read_int() for _ in range(count)] def read_bytes(self) -> bytes: """Read bytes in O(skipped whitespace + token size), excluding first read.""" data = self._data if not self._loaded: data = self._data = self._reader.read() + b" \xff" self._loaded = True index = self._index size = len(data) - 2 while data[index] == 32 or 9 <= data[index] <= 13: index += 1 if index >= size: self._index = size raise EOFError start = index while data[index] != 32 and not 9 <= data[index] <= 13: index += 1 self._index = index + 1 return data[start:index] def read_str(self) -> str: """Read UTF-8 in O(skipped whitespace + token size), excluding first read.""" return self.read_bytes().decode() def write(self, text: str): """Buffer text without a newline in amortized O(text size) time.""" self._output.append(text) def print(self, *values, sep: str = " ", end: str = "\n"): """Buffer formatted values in O(total formatted size) time.""" if len(values) == 1: self._output.append(str(values[0])) else: self._output.append(sep.join(map(str, values))) self._output.append(end) def writeln(self, value): """Buffer one value and a newline in O(formatted size) time.""" self._output.append(str(value)) self._output.append("\n") def flush(self): """Write and clear buffered output, then flush the stream; O(size).""" output = self._output.build() if output: self._writer.write(output) self._output = _StringBuilder() self._writer.flush() io = FastIO() II = io.read_int LI = io.read_ints print = io.print def solve(): mask = 2 ** 32 - 1 H, W = II(), II() S = [sum(LI(W)) for _ in range(H)] T = sum(S) for si in S: print((si + T) & mask) return if __name__ == "__main__": solve() io.flush()