def print_inner(w)
  (1..w).map { |i|
    if i == 1 || i == w
      '#'
    else
      '.'
    end
  }
  .join
end

def print_frame(h, w)
  (1..h).each do |i|
    if i == 1 || i == h
      puts "#{'#' * w}"
    else
      puts print_inner(w)
    end
  end
  puts ""
end

loop do
  h, w = gets.split.map(&:to_i)
  break if h == 0 && w == 0

  print_frame(h, w)
end

