#include <iostream>
using namespace std;
int main()
{
int n, m;
char c;
int y;
cin >> n >> m >> c >> y;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (y == 1 || i == 1 || i == n || j == 1 || j == m)
cout << c;
else
cout << ' ';
}
cout << endl;
}
return 0;
}