def freeze(x):
    """Freezes a dictionary, i.e. makes it immutable and thus hashable."""
    frozen = {}
    for k, v in x.items():
        if isinstance(v, list):
            frozen[k] = tuple(v)
        else:
            frozen[k] = v
    return frozenset(frozen.items())