object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    while(true) {
      val h, w = scanner.nextInt
      if((h == 0) && (w == 0)) System.exit(0)
      println("#" * w)
      println(("#" + "*" * (w - 2) + "#") * (h - 2))
      println("#" * w)
      println()
    }
  }
}
