#include <iostream>
#include <string> 
#include <vector>


using namespace std;



int main()
{
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) a[i]=1;
    for(int i=0;i<h;i++)
    {
        int pocetakStena=-1, zarobljeniProtok=0;
        bool prepreka = false,naPocetku=true;
        int b,c=-1;
        cout << "*" << endl;
        for(int j=0;j<n;j++) cout << a[j] << " ";
        cout << endl;
        for(int j=0;j<n;j++)
        {
            cin >> b;
            if(b==1) naPocetku = false; 
            if(b==0)
            {
                zarobljeniProtok+=a[j];
                a[j]=0;
                if(c==1) pocetakStena=j;
            }
            if(b==1 && c==0)
            {
               if(naPocetku) a[j]=zarobljeniProtok;
               else
               {
                   if(zarobljeniProtok%2==0) a[pocetakStena-1]=a[j]=zarobljeniProtok/2;
                   else
                   {
                       if(j==n-1) a[pocetakStena-1]+=zarobljeniProtok;
                       else
                       {
                            a[pocetakStena-1]+=(zarobljeniProtok+1-i%2)/2;
                            a[j]+=zarobljeniProtok-(zarobljeniProtok+1-i%2)/2;
                       }
                   }
               }
               zarobljeniProtok=0;
            }
            c=b;
        }
    }
    for(int i=0;i<n;i++) cout << a[i] << " ";
    return 0;
}