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