n,m=map(int,raw_input().strip().split()) for i in range(1,n+1): if i==1 or i==n : print '*'*m else: print '*'+' '*(m-2)+'*'