#!/usr/bin/env ruby

word = [];numbers = []
i = 0
sharp = "#";dot = "."
loop do 
    word = gets.split.map(&:to_i)
    if word[0] == 0 and word[1] == 0 then; break; end
    word.each do |key|
        numbers << key
    end
end

((numbers.count + 1) / 2).times do
    numbers[i].times do |index|
        if index == 0 or index == numbers[i] - 1 then
            puts sharp * numbers[i + 1]
        else
            print sharp,dot * (numbers[i + 1] - 2),sharp,"\n"
        end
    end
    puts ""
    i += 2 
end
