import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      var n = readLine.split(" ").map(_.toInt)
      while( n(0) != 0 || n(1) != 0) {
        println("#"*n(1))

        (2 to n(0)-1).foreach(s=> { print("#");print("."*(n(1)-2));print("#\n") })

        if(n(0)>1) {
          println("#"*n(1))
        }
        println("")
        n = readLine.split(" ").map(_.toInt)
      }
  }
}