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