#include void print_filled_rectangle(int h, int w, char c) { for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { std::cout << c; } std::cout << std::endl; } } void print_unfilled_rectangle(int h, int w, char c) { for (int i = 0; i < w; i++) { std::cout << c; } std::cout << std::endl; for (int i = 0; i < h - 2; i++) { std::cout << c; for (int j = 0; j < w - 2; j++) { std::cout << " "; } std::cout << c << std::endl; } for (int i = 0; i < w; i++) { std::cout << c; } std::cout << std::endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int h, w; char c; bool filled; while (std::cin >> h >> w >> c >> filled) { if (filled) { print_filled_rectangle(h, w, c); } else { print_unfilled_rectangle(h, w, c); } } return 0; }