#include <bits/stdc++.h>

using namespace std;

int main()
{
    int h, n, startS = -1, endS = -1;
    int ukVod = 0;
    scanf("%d %d", &h, &n);
    int vod[h][n], res[n];

    fill_n(res, n, 1);

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &vod[i][j]);
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < n; ++j) {
            if (!vod[i][j]) {
                if (startS == -1) {
                    startS = j;
                }

                if (vod[i][j + 1] || j + 1 == n) {
                    endS = j;
                }

                ukVod += res[j];
                res[j] = 0;

                if (endS != -1) {
                    if (startS == 0) {
                        res[endS + 1] += ukVod;
                    } else if (endS == n - 1) {
                        res[startS - 1] += ukVod;
                    } else {
                        if (ukVod % 2 == 0) {
                            res[startS - 1] += ukVod / 2;
                            res[endS + 1] += ukVod / 2;
                        } else {
                            if ((i+1) % 2 == 0) {
                                res[endS + 1] += ukVod / 2 + 1;
                                res[startS - 1] += ukVod / 2;
                            } else {
                                res[startS - 1] += ukVod / 2 + 1;
                                res[endS + 1] += ukVod / 2;
                            }
                        }
                    }

                    ukVod = 0;
                    startS = -1;
                    endS = -1;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        printf("%d ", res[i]);
    }
}