C++#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define endl '\n'
int n,b;
map<string,int> pos;
string s[1000005];
signed main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n>>b;
for(int i=1;i<=n;i++)
{
char c;
cin >> c;
s[0]+=c;
}
pos[s[0]]=0;
for(int i=1;i<=b;i++)
{
s[i]=s[i-1];
for(int j=1;j<n;j++)
{
if(s[i-1][j-1]=='1')
{
if(s[i][j]=='1')
{
s[i][j]='0';
}
else
{
s[i][j]='1';
}
}
}
if(s[i-1][n-1]=='1')
{
if(s[i][0]=='1')
{
s[i][0]='0';
}
else
{
s[i][0]='1';
}
}
if(pos.count(s[i]))
{
int be=pos[s[i]];
int len=i-1-be+1;
b-=be-1;
b%=len;
if(b==0)
{
b=len;
}
for(int j=0;j<n;j++)
{
cout << s[be-1+b][j]<<endl;
}
return 0;
}
pos[s[i]]=i;
}
for(int j=0;j<n;j++)
{
cout << s[b][j]<<endl;
}
return 0;
}