object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .map { line =>
        val arr = line.split(" ").map(_.toInt)
        (arr(0), arr(1))
      }
      .takeWhile {
        case (0, 0) => false
        case _ => true
      }
      .foreach { case (h, w) =>
        val size = w - 2
        val sb = StringBuilder.newBuilder
        append(sb)("#" * size)
        for (_ <- 0 until h - 2) {
          append(sb)("." * size)
        }
        append(sb)("#" * size)
        sb.append('\n')
        print(sb.toString())
      }
  }

  def append(sb: StringBuilder)(row: => String): Unit = {
    sb.append('#')
      .append(row)
      .append('#')
      .append('\n')
  }
}