#include <iostream>
using namespace std;
int main()
{
long long m, n,b;
char a;
cin >> m >> n >> a >> b;
for (int i = 1;i <= m;i++)
{
if (b != 0)
{
for (int k = 0;k <= n;k++)
{
cout << a;
}
}
else
{
if (i == 1 || i == m)
{
for (int j = 1;j <= n;j++)
{
cout << a;
}
}
else
{
for (int j = 1;j <= n;j++)
{
if (j == 1 || j == n)
cout << a;
else
cout << " ";
}
}
}
cout << endl;
}
return 0;
}