#include<stdio.h>
int main()
{
int c, r, n;
while (scanf("%d", &n) != EOF)
{
for (r = 1; r <= n ;r++)
{
for (c = 1; c <= n; c++)
{
if (r == 1 || r == n || c == 1 || c == n)
printf("%-2c", '*');
else
printf(" ");
}
printf("\n");
}
}
return 0;
}