b,a =map(int,raw_input().strip().split()) i = 1 while i<=b: if i == 1 or i == b: print '*'*a else: print '*'+" "*(a-2)+'*' i=i+1