#include <iostream>
using namespace std;

void rectangle(int w, int h, bool outline) {
 for (int i=1; i <= h; ++i) {
  for (int j=1; j <= w; ++j) 
   cout << (!outline || i == 1 || i == h || j == 1 || j == w ? '*' : ' ');
  cout << endl;
 }
}

int main() {
 cout << "Enter the rectangle's width and height: ";
 int width, height;
 cin >> width >> height;
 cout << "Do you want to print only the outline? (Y/N): ";
 char ch;
 cin >> ch;
 bool outlineOnly = (ch == 'Y' || ch == 'y');
 rectangle(width, height, outlineOnly);
 return 0;
}

