import math


def compute_idfs(documents):
    """
    Given a dictionary of `documents` that maps names of documents to a list
    of words, return a dictionary that maps words to their IDF values.

    Any word that appears in at least one of the documents should be in the
    resulting dictionary.
    """
    idfs = dict()
    words = set()
    docLength = len(documents)
    for doc in documents:
        words.update(set(documents[doc]))

    for word in words:
        f = sum(word in documents[doc] for doc in documents)
        idf = math.log(docLength / f)
        idfs[word] = idf
    return idfs