#!/usr/bin/env ruby

if __FILE__ == $0
	loop do
		h, w = gets.split.map { |x| x.to_i }
		if h == 0 and w == 0 then
			break
		end

		ht = "#"*w+"\n"
		md = "#"+"."*(w-2)+"#\n"
		puts ht + md*(h-2) + ht + "\n"
	end
end

