/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_B
  * Structured Program I - Print a Frame
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(" ").map(_.toInt))
      .map { case Array(h, w) => (h, w) }
      .takeWhile(_ != (0, 0))
      .map { case (h, w) => createAFrame(h, w) }
      .foreach(_.foreach(println))
  }

  def createAFrame(h: Int, w: Int): Seq[String] = {
    (1 to h).map {
      case y if y == 1 || y == h => "#" * w
      case _ => "#" + "." * (w - 2) + "#"
    } :+ ""
  }
}