h =int(input()) w =int(input()) s='*'*w q='\n*' print (s+(q+' '*(w-2)+q)*(h-2)+s)