hash = {?( => ?), ?[ => ?]}
loop {
    s = gets.chomp
    break if s == ?.
    stack = []
    s.each_char{|c|
        if c == hash[stack[-1]]
            stack.pop
        elsif hash.keys.include?(c)
            stack << c
        end
    }
    puts stack.empty? ? 'yes' : 'no'
}