sets = readlines
sets.each{|line|
    h,w = line.split.map(&:to_i)
    
    break if (h == 0) && (w == 0)
    
    h.times{|n|
        w.times{|m|
            if (n == 0) || (n == (h-1))
                print '#' 
            elsif
                if (m == 0) || (m == (w-1))
                    print '#'
                else
                    print '.'
                end
            end
        }
        puts #new line
    }
    puts #new line
}
