#-*-coding:utf-8-*- n,m=map(int,raw_input().strip().split())#m为宽 print "*"*m if n!=1: print ("*"+" "*(m-2)+"*\n")*(n-2)+"*"*m