#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,x;
char ch;
cin>>a>>b>>ch>>x;
if(x==1)
{
for(int i=1;i<=a;i++)
{
for(int j=1;i<=b;j++)
{
cout<<ch;
}
cout<<endl;
}
}
else if(x==0)
{
for(int i=0;i<b;i++)
{
cout<<ch;
}
cout<<endl;
for(int i=0;i<a-2;i++)
{
cout<<ch;
for(int j=0;j<b-2;j++)
{
cout<<' ';
}
cout<<ch<<endl;
}
for(int i=0;i<b;i++)
{
cout<<ch;
}
}
else
{
for(int i=1;i<=a;i++)
{
for(int j=1;i<=b;j++)
{
cout<<ch;
}
cout<<endl;
}
}
return 0;
}