import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    while(true) {
      val in = StdIn.readLine().split(" ").map(_.toInt)
      val H = in(0)
      val W = in(1)
      if(H == 0 && W == 0) return
      for(i <- 1 to H;j <- 1 to W){
        print(
          (i,j) match {
          case (1,_) | (_,1) | (H,_) | (_,W)=> "#"
          case _ => "."
          }
        )
        if(j == W){println()}
      }
      println()
    }
  }
}