import scala.io.StdIn.readLine

object Main {
	def main(args: Array[String]) = {
		def buildFrame: Unit = {
			val Array(a,b) = readLine().split(" ").map(_.toInt)
			if(a != 0 && b != 0) {
				for(c <- 1 to a) {
				if(c == 1 || c == a) println("#" * b)
				else println("#" + "." * (b -2) + "#")
			}
			println()
			buildFrame
		}
	}
	buildFrame
	}
}