#include <iostream>
using namespace std;
int main()
{
    int h;
    int n;
    cin >> h;
    cin >> n;

    int **a = new int*[h + 1];
    for(int i = 1; i <= h; i++){
        int *a[i] = new int[n + 1];
    }
    for(int j = 1; j <= h; h++){
        for(int l = 1; l <= n; l++){
            cin >> a[j][l];
        }
    }
    int *pr = new int[n + 1];
    for(int c = 1; c <= n; c++){
        pr[c] = 1;
    }
    for(int t = 1; t <= h; t++){
        int br = 0;
        int x;
        for(int s = 1; s <= n; s++){
            if(a[t][s] == 0){
                if (br == 0) x = s;
                br += pr[s];
            }
            else{
                pr[x - 1] += br / 2;
                pr[s] += br / 2;
                if(br % 2 = 1 && s % 2 = 1) pr[x - 1]++;
                else if(br % 2 == 1) pr[s]++;
                br == 0;
            }
        }
        if(pr[0] > 0){
            int y = 1;
            while(a[t][y] == 0) y++;
            pr[y] += pr[0];
            pr[0] == 0;
        }
        if(br > 0){
            int y = n;
            while(a[t][y] == 0) y--;
            pr[y] += br;
            br = 0;
        }
    }
    for(int r = 1; r <= n; r++){
        cout << pr[r];
    }
    return 0;
}