#include <iostream>
#include <algorithm>

using namespace std;

static int h, n, niz1[500000], niz2[500000];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    	cin >> h >> n;
        	bool neparan = false;
            	int *tren = niz1, *sled = niz2;
                	for (int i = 0; i < n; i++)
                    		tren[i] = 1;
                            	while (h--)
                                	{
                                    		neparan = !neparan;
                                            		int t;
                                                    		cin >> t;
                                                            		int carry = t ? 0 : tren[0];
                                                                    		sled[0] = t ? tren[0] : 0;
                                                                            		int lasti = t - 1;
                                                                                    		for (int i = 1; i < n-1; i++)
                                                                                            		{
                                                                                                    			cin >> t;
                                                                                                                			if (t)
                                                                                                                            			{
                                                                                                                                        				lasti = i;
                                                                                                                                                        				sled[i] = tren[i] + carry;
                                                                                                                                                                        				carry = 0;
                                                                                                                                                                                        			}
                                                                                                                                                                                                    			else
                                                                                                                                                                                                                			{
                                                                                                                                                                                                                            				sled[i] = 0;
                                                                                                                                                                                                                                            				if (lasti == -1)
                                                                                                                                                                                                                                                            				{
                                                                                                                                                                                                                                                                            					carry += tren[i];
                                                                                                                                                                                                                                                                                                					continue;
                                                                                                                                                                                                                                                                                                                    				}
                                                                                                                                                                                                                                                                                                                                    				int pola = tren[i] / 2;
                                                                                                                                                                                                                                                                                                                                                    				carry += pola;
                                                                                                                                                                                                                                                                                                                                                                    				sled[lasti] += pola;
                                                                                                                                                                                                                                                                                                                                                                                    				if (tren[i] & 1)
                                                                                                                                                                                                                                                                                                                                                                                                    				{
                                                                                                                                                                                                                                                                                                                                                                                                                    					if (neparan)
                                                                                                                                                                                                                                                                                                                                                                                                                                        						sled[lasti]++;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                					else
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    						carry++;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            				}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            			}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        		}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                		cin >> t;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        		sled[n-1] = t ? tren[n-1] + carry : 0;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                		if (!t)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        			sled[lasti] += tren[n-1] + carry;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    		swap(tren, sled);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            	}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	for (int i = 0; i < n; i++)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    		cout << tren[i] << ' ';
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }