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