#include<stdio.h>
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; i++) { //外循环行
for (int j = 1; j <= n; j++) { //内循环列
if (i == 1 || i == n || j == 1 || j == n) printf("* ");
else printf(" ");
}
printf("\n");
}
}
return 0;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; i++) { //外循环行
for (int j = 1; j <= n; j++) { //内循环列
if (i == 1 || i == n || j == 1 || j == n) printf("* ");
else printf(" ");
}
printf("\n");
}
}
return 0;
}