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