a = []
while true
  num = gets.split(" ").map(&:to_i)
  break if(num[0] == 0 && num[1] == 0)
  a.push(num)
end

a.each do |i|
  height = i[0]
  width = i[1]
  height.downto(1) do |h|
    case h
    when height, 1 then
      width.downto(1) do |w|
        printf "#" unless w == 1
        printf "#\n" if w == 1
      end
    else
      width.downto(1) do |w|
        printf "#" if w == width
        printf "#\n" if w == 1
        printf "." unless w == 1 || w == width
      end
    end
  end
  printf "\n"
end