#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int h,w,j,i;
char c;
bool on;
cin>>h>>w>>c>>on;
if(on==1)
{
for(i=1;i<=h;i++)
{
for(j=1;j<=w;j++)
cout<<c;
cout<<endl;
}
}
if(on==0)
{
for(i=1;i<=h;i++)
{
{
for(j=1;j<=w;j++)
{
if(i==1||i==h)
cout<<c;
else if(j==1||j==w)
cout<<c;
else
cout<<" ";
}
cout<<endl;
}
}
}
return 0;
}
#include<cstdio>
using namespace std;
int main()
{
int h,w,j,i;
char c;
bool on;
cin>>h>>w>>c>>on;
if(on==1)
{
for(i=1;i<=h;i++)
{
for(j=1;j<=w;j++)
cout<<c;
cout<<endl;
}
}
if(on==0)
{
for(i=1;i<=h;i++)
{
{
for(j=1;j<=w;j++)
{
if(i==1||i==h)
cout<<c;
else if(j==1||j==w)
cout<<c;
else
cout<<" ";
}
cout<<endl;
}
}
}
return 0;
}