#!/usr/bin/python j=raw_input() m,n = map(int,j.split()) for i in range(m): if i>0 and i<m-1: print '*'+" "*(n-2)+'*' else: print '*'*n