while true
    numbers = gets.split.map(&:to_i)
    if numbers[0] == 0 && numbers[1] == 0
        break
    else
        puts "#"*numbers[1]
        (numbers[0]-2).times do
            puts "#"+"."*(numbers[1]-2)+"#"
        end
        puts "#"*numbers[1]
    end
    puts ""
end
