main = interact $ unlines . map (show' . balance) . init . lines
 where show' p = case p of {True -> "yes"; False -> "no"}

balance = null . foldr scan [] . filter (flip elem "()[]")
 where
  scan b [] = [b]
  scan b (a:acc) = if [b,a] == "()" || [b,a] == "[]" then acc else (b:a:acc)