<reponame>YaniLozanov/Software-University
n = int(input())

print("*" * n)

for num in range(1,n -1):
    print("*" + " " *( n-2) + "*")

print("*" * n)

n = int(input())

print("*" * n)

for num in range(1,n -1):
    print("*" + " " *( n-2) + "*")

print("*" * n)