#include<iostream>
using namespace std;
int main(){
int a,b,f;
char c;
cin>>a>>b>>c>>f;
if(f==1)
{
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
cout<<c;
cout<<endl;
}
}
else
{
for(int i=0;i<a;i++)
{
if(i==0||i==a-1)
for(int j=0;j<b;j++)
cout<<c;
else
for(int j=0;j<b-2;j++)
cout<<" ";
cout<<endl;
}
}
return 0;
}