import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

void main() {
    int H, W; scanf("%d %d\n", &H, &W);
    auto r = new int[H],
         c = new int[W];
    auto F = new int[][](H, W);
    foreach (i; 0 .. H) {
        foreach (j; 0 .. W) {
            int x; scanf("%d", &x);
            if (x == 0) {
                r[i]++; c[j]++;
                F[i][j] = 1;
            }
        }
    }
    int Ans = 0;
    int C(size_t y, size_t x) {
        return (r[y] + c[x] - F[y][x]) % 2;
    }
    foreach (i; 0 .. H) {
        write(C(i, 0));
        foreach (j; 1 .. W) {
            write(" ", C(i, j));
        }
        writeln;
    }
}