def get_sumrules(root_to_leaf):
    """Returns the sumrules of each class name
    Params:
        root_to_leaf: Dict[str, List[str]], map root_string -> list of leaf_string
    Outputs:
        memo: Dict[str, List[str]] class name -> list of finest leaf strings
    Example:
        personnel -> [male, female]
    """

    def helper(node, memo):
        if node in memo:
            return memo[node]
        if node not in root_to_leaf:
            return [node]

        memo[node] = []
        leaves = root_to_leaf[node]
        for l in leaves:
            memo[node] += helper(l, memo)
        return memo[node]

    memo = {}
    for r in root_to_leaf:
        _ = helper(r, memo)

    return memo