#hotcodes
'''
مرتب سازی 3 عدد
x, y, z = map(int, input().split())
answer=[]
answer.append(x)
answer.append(y)
answer.append(z)
answer.sort()
for i in answer :
    print(i,end=" ")'''

'''
خشایار و چالش قطری
n=int(input())
i=0
while i < n :
    j=0
    while j < n :
        if i == 0 or i == n-1 or j ==0 or j==n-1 or (j==n//2 and i ==n//2) or j==i or j+i==n-1:
            print("*",end="")
        else:
            print(" ",end="")
        j+=1
    print("")
    i+=1
'''
'''
رسم شکل مربع 3
n=int(input())
i=0
while i < n :
    j=0
    while j < n :
        if i == 0 or i == n-1 or j ==0 or j==n-1 or (j==n//2 and i ==n//2) or j==i :
            print("*",end="")
        else:
            print(" ",end="")
        j+=1
    print("")
    i+=1
'''
n=int(input())
i=0
while i < n :
    j=0
    while j < n :
        if i == 0 or i == n-1 or j ==0 or j==n-1  :
            print("*",end="")
        else:
            print(" ",end="")
        j+=1
    print("")
    i+=1