def get_replaces_to_rule(rules):
    """Invert rules dictionary to list of (replace, rule) tuples."""
    replaces = []
    for rule, rule_replaces in rules.items():
        for replace in rule_replaces:
            replaces.append((replace, rule))
    return replaces