tmp = []
cou = "1"
while cnt != [0, 0]
  i = gets.chomp.split.map(&:to_i)
  tmp.push(i)
  tmp.flatten!
  cnt = i
end
tmp.delete(tmp[-1])
length = tmp.length/2
i = 0
length.times do
  h = tmp[i].to_i
  w = tmp[i+1].to_i
  hh = h-2
  ww = w-2

  w.times do
    print"#"
  end
  print"\n"
  hh.times do
    print"#"
    ww.times do
      print "."
    end
    print"#\n"
  end
  w.times do
    print"#"
  end
  i = i + 2
  print"\n\n"
end