object Main {
  def Print(x:Int){
    for(i<-1 to x) print("#")
    println()
  }
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    var tmp=false  
      while(true){
       val h,w=sc.nextInt
       if(tmp) println()
       if(h==0&&w==0) return
       Print(w)
       for(i<-1 to h-2;j<-1 to w){
         if(j==1||j==w) print("#")
         else print(".")
         if(j==w) println()
       }
       if(h!=1) Print(w)
       tmp=true
     }
  }
}