#Print a Frame
def paints(arr)
	arr.each{|i|
		a = []
		i.each{|j|
			a << j
		}
		a[0].times{|k|
			if (k != 0 && k != (a[0] - 1))
				w_dotto_line = ''
				a[1].times{|l|
					if (l != 0 && l != (a[1] - 1))
						w_dotto_line << "."
					else
						w_dotto_line << '#'
					end
				}
				puts w_dotto_line
			else
				w_line = ''
				a[1].times{|l|
					w_line << '#'
				}
				puts w_line
			end
		}
		puts ''
	}
end

input_arr = []
while input = gets
	h, w = input.split(' ').map(&:to_i)
	break if (h == 0 && w == 0)
	input_arr << [h, w]
end

paints(input_arr)