#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX1 = 2020;
const int MAX2 = 2020;
int SIZE1, SIZE2;

template<class T> struct BIT2D {    
    T dat[2][2][MAX1 + 1][MAX2 + 1];
    
    void init(int n = 1, int m = 1) {
        SIZE1 = n, SIZE2 = m;
        for (int i = 0; i <= SIZE1; ++i) 
            for (int j = 0; j <= SIZE2; ++j) 
                dat[0][0][i][j] = dat[0][1][i][j] = dat[1][0][i][j] = dat[1][1][i][j] = 0;
    }
    
    inline void subsub_add(int f, int s, int a, int b, T x) {
        for (int i = a; i <= SIZE1; i += i & -i) 
            for (int j = b; j <= SIZE2; j += j & -j) 
                dat[f][s][i][j] = dat[f][s][i][j] + x;
    }
    
    inline void sub_add(int a1, int a2, long long x) {
        subsub_add(0, 0, a1, a2, x*(a1-1)*(a2-1));
        subsub_add(1, 0, a1, a2, -x*(a1-1));
        subsub_add(0, 1, a1, a2, -x*(a2-1));
        subsub_add(1, 1, a1, a2, x);
    }
    
    // a1 <= x < b1, a2 <= y < b2
    inline void add(int a1, int a2, int b1, int b2, long long x) {
        sub_add(a1, a2, x);
        sub_add(a1, b2, -x);
        sub_add(b1, a2, -x);
        sub_add(b1, b2, x);
    }
    
    inline T subsub_sum(int f, int s, int a, int b) {
        T res = 0;
        for (int i = a; i > 0; i -= i & -i) 
            for (int j = b; j > 0; j -= j & -j) 
                res = res + dat[f][s][i][j];
        return res;
    }
    
    inline T sub_sum(int a1, int a2) {
        T res = 0;
        res += subsub_sum(0, 0, a1-1, a2-1);
        res += subsub_sum(1, 0, a1-1, a2-1) * (a2-1);
        res += subsub_sum(0, 1, a1-1, a2-1) * (a1-1);
        res += subsub_sum(1, 1, a1-1, a2-1) * (a1-1) * (a2-1);
        return res;
    }
    
    // a1 <= x < b1, a2 <= y < b2
    inline T sum(int a1, int a2, int b1, int b2) {
        return sub_sum(b1, b2) - sub_sum(a1, b2) - sub_sum(b1, a2) + sub_sum(a1, a2);
    }
    
    void print() {
        for (int i = 1; i <= SIZE1; ++i) {
            for (int j = 1; j <= SIZE2; ++j) 
                cout << sum(i, j, i+1, j+1) << ",";
            cout << endl;
        }
    }
};

BIT2D<long long > bit;




int H, W;
int a[2000][2000];


int main() {
    while (cin >> H >> W) {
        bit.init(H, W);
        
        for (int i = 1; i <= H; ++i) for (int j = 1; j <= W; ++j) {
            cin >> a[i][j];
            if (a[i][j] == 0) {
                bit.add(i, 1, i+1, W+1, 1);
                bit.add(1, j, H+1, j+1, 1);
                bit.add(i, j, i+1, j+1, -1);
            }
        }
        for (int i = 1; i <= H; ++i) {
            for (int j = 1; j <= W; ++j) {
                long long sum = bit.sum(i, j, i+1, j+1);
                cout << sum%2;
                if (j != W) cout << " ";
            }
            cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 81024