let l=require("fs").readFileSync("/dev/stdin","utf8").split("\n")
let i=0
while(true){
  let [h,w]=l[i++].split(" ").map(Number)
  if (!h&&!w)break
  let s="#".repeat(w)
  console.log(`${s}\n${`#${".".repeat(w-2)}#\n`.repeat(h-2)}${s}\n`)
}

