a=list(map(int,input().split())) n=a[0];m=a[1] for i in range(n): if i==0 or i==n-1: print("*"*m) else: print("*"+" "*(m-2)+"*")