object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    
    def printFrame(w:Int, h:Int):Unit = {
      if(w==0&&h==0){}
      else {
        println("#"*w)

        for( i <- 1 to h) {
          print("#"+"."*(w-2)+"#")
        }
        println("#"*w)
        println
        printFrame(sc.nextInt,sc.nextInt)
      }
    }

    printFrame(sc.nextInt,sc.nextInt)

  }
}