#include<bits/stdc++.h>
using namespace std;
int main(){
long long q,w,e,t=1,y=1,p=1;
char u;
cin>>q>>w>>u>>e;
while(t<=w){
cout<<u;t++;
}cout<<'\n';
if(e==0){
for(;y<=(w-2);y++){if(q==1) break;
cout<<u<<setw(w-1)<<u<<'\n';}
if(w==1) {for(int c=1;c<=q-2;c++) {cout<<u<<'\n';}}
}
if(e==1){
while(p<=q-2)
{if(q==1) break;t=1;
while(t<=w)
{cout<<u;t++;}cout<<'\n';p++;}
}
t=1;while(t<=w){if(q==1) break;
cout<<u;t++;}
cout<<'\n';
return 0;
}