#include <bits/stdc++.h>

using namespace std;
int matrica[1000][1000];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,n,a,b,c,f,e,i,j;
    cin >> h >> n;
    for( i = 0;i < n; i++)
    {
        for( j = 0;j < h; j++)
        {
            cin>>matrica[i][j];
        }
    }
    cout<<endl;
    for(i=0; i < n ; i++)
    {
        for( j = 0; j < h; j++)
        {
            if(matrica[i][j] == 0)
                {
                if(matrica[i][j] == matrica[i][0])
                    {
                        matrica[i][j+1] = matrica[i][j+1] +1;
                    }
                    else if(matrica[i][j] == matrica[i][h])
                    {
                        matrica[i][j-1] = matrica[i][j-1] +1;
                    }
                    else if(matrica[i][j] % 2 != 0)
                    {
                        if(i % 2 == 0)
                        {


                        matrica[i][j-1] = matrica[i][j]/2;
                        matrica[i][j+1] = matrica[i][j]/2 +1;
                        }
                        else
                        {
                        matrica[i][j-1] = matrica[i][j]/2 +1;
                        matrica[i][j+1] = matrica[i][j]/2;
                        }
                    }
                }

            }

        }
        for(j = 0; j < h; j++)
        {
        cout<<matrica[i][j];
        }


    return 0;
}