pair = {?[ => ?], ?( => ?)}
loop {
    s = gets.chomp
    break if s == ?.
    a = s.scan(/[()\[\]]/)
    stack = []
    a.each{|x|
        if stack.size > 0 && x == pair[stack[-1]]
            stack.pop 
        elsif pair.keys.include?(x)
            stack << x
        else
            stack << x
            break 
        end
    }
    puts stack.size == 0 ? 'yes' : 'no'
}   