m,n=list(map(int,input().split())) if m>1: print("*"*n,"\n",("*"+" "*(n-2)+"*\n")*(m-2),"*"*n,sep="") else: print("*"*n,sep="")