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