n,m=list(map(int,input().split())) if n != 1: print('*' * m,'\n',('*'+' '*(m-2)+'*\n')*(n-2),'*'*m,sep='') else: print('*'*m)