Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int nsp = n;
int nst = n - 2;
int row = 1;
while (row <= n) {
if (row == 1 || row == n) {
int cst = 1;
while (cst <= nst);
System.out.print("*");
cst++;
} else {
System.out.print("*");
int csp = 1;
while (csp <= nsp) {
System.out.print(" ");
csp++;
}
System.out.print("*");
}
System.out.println();
row++;
}