loop {
  h, w = gets.chomp.split(' ').map { |i| i.to_i }
  if h == 0 and w == 0 then break
  else
    (1..h).each { |he|
      (1..w).each { |wi|
        if he == 1 or he == h or wi == 1 or wi == w
          print '#'
        else
          print '.'
        end
      }
      print "\n"
    }
    print "\n"
  end
}