while true
	h, w = gets.split.map{|x| x.to_i}
	if h == 0 and w == 0
		break
	end
	
	h.times do |i|
		w.times do |j|
			if i == 0 or i == h-1
				print '#'
			elsif j == 0 or j == w-1
				print '#'
			else
				print '.'
			end
		end
		puts ''
	end
	puts ''
end