dfs :: Int -> Int -> String -> Int -> Int -> [Bool] -> [Bool]
dfs a b s na nb result
  | null s = result
  | head s == 'a' = if na + nb < a + b
                    then dfs a b s' (na+1) nb (result ++ [True])
                    else dfs a b s' na nb (result ++ [False])
  | head s == 'b' = if na + nb < a + b && nb < b
                    then dfs a b s' na (nb+1) (result ++ [True])
                    else dfs a b s' na nb (result ++ [False])
  | otherwise = dfs a b s' na nb (result ++ [False])
  where
    s' = tail s

solve (t:s:_) = dfs a b s 0 0 []
  where (_:a:b:_) = map read $ words t

main = getContents >>= mapM_ (\x -> putStrLn (if x then "YES" else "NO")).solve.lines
