#!/use/bin/python m,n=map(int,raw_input().strip().split()) for i in range(m): if i==0 or i==m-1: print "*"*n else: print "*"+" "*(n-2)+"*"