#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
char d;
cin>>a>>b>>d>>c;
if(c==0)
{
for(int i=1;i<=b;i++)
{
cout<<d;
}
cout<<endl;
for(int i=2;i<a;i++)
{
for(int j=1;j<=b;j++)
{
if(j==1 or j==b)
{
cout<<d;
}
else
{
cout<<" ";
}
}
cout<<endl;
}
for(int i=1;i<=b;i++)
{
cout<<d;
}
}
if(c==1)
{
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
cout<<d;
}
cout<<endl;
}
}
}