include<stdio.h>

int main()
{
int a = 0;
while (~scanf("%d", &a))
{
for (int b = 0; b < a; b++)
{
for (int c = 0; c < a; c++)
{
if (b == 0 || b == a - 1)
{
printf("* ");
}
else if (c == 0 || c == a-1)
{
printf("* ");
}
else
printf(" ");
}printf("\n");
}
}
return 0;
}