n,m=map(int,input().strip().split()) i=1 while i<=n: if i==1 or i==n: print("*"*m) else: print("*"+" "*(m-2)+"*") i=i+1