def flipDict(d):
    """Flips dict p_d: keys become values, values become keys. p_d is left
       untouched: a new, flipped, dict is returned."""
    res = {}
    for k, v in d.items():
        res[v] = k
    return res
