#include <iostream>

using namespace std;

main ()
{
    int h, n, i, j;

    cout << "visina i siriina vodopada:" << endl;
    cin >> h;
    cin >> n;

    int matrica [h][n];

    cout << "popunjavanje matrice:" << endl;
    for (i=0; i<h ; i++)
    {
        for (j=0; j<n ; j++)
        {
            cin >> matrica[i][j];
        }
    }

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



    cout << endl;
     cout << "izlaz:" << endl;
    for (j=0; j<n ; j++)
    {
        cout << matrica [h-1][j];
    }
    return 0;
}