#include<iostream>
#define MAX1 12
#define MAX 10

using namespace std;

int main(void)
{
    int h,n,matrica[MAX1][MAX];

    cin>>h>>n;

    for(int i=0;i<n;++i){
        matrica[0][i] = 1;
        matrica[h+1][i]=0;}



    for(int i=1;i<=h;++i)
        for(int j=0;j<n;++j)
        cin>>matrica[i][j];



    for(int i=1;i<=h;++i)
        for(int j=0;j<n;++j){
                if(matrica[i][j] == 0){
                   if(j == 0)
                       matrica[i+1][j+1] += matrica[i-1][j];
                   else
                    if(j == n-1)
                       matrica[i+1][j-1] += matrica[i-1][j];
                }
                else
                    if(matrica[i][j]>1)
                    matrica[i+1][j] = matrica[i][j];
        }

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






    return 0;
}