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