#include<bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int R,k;cin>>R>>k;
	string tmp;cin>>tmp;
	tmp = '.' + tmp + '.';
	for(int i = 0;i<k;i++){
		string nv = ".";
		for(int j = 1;j < tmp.size()-1;j++){
			int ind = 0;
			if(tmp[j-1] == 'X')ind+=4;
			if(tmp[j] == 'X') ind+=2;
			if(tmp[j+1] == 'X') ind++;
			if((1<<ind) & R)
				nv += 'X';
			else
				nv += '.';
		}
		cout<<nv.substr(1,nv.size()-1)<<'\n';
		tmp = nv+'.';
	}
}
