#include using namespace std;
int main() {
int h, w;
char s;
int id;
cin >> h >> w >> s >> id;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (id == 1) {
cout << s;
} else {
if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
cout << s;
} else {
cout << ' ';
}
}
}
cout << endl;
}
return 0;
}