n,m = map(int,raw_input().strip().split()); if n == 1: print "*"*m else: print "*"*m print ("*"+" "*(m-2) + "*\n")*(n-2), print "*"*m