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