def get_all_rules(data):
    """
    Create list of rules from data in format:
    (color1, num, color2)
    '<color1> bags contain <num> <color2> bags'
    """
    rules = []
    for record in data:
        count = record.count(",")
        record = record.split()
        bag_from = record[0] + " " + record[1]
        if "other" in record:
            rule = (bag_from, 0, "no other")
            rules.append(rule)
            continue
        for i in range(count+1):
            bag_to_count = record[4+4*i]
            bag_to = record[5+4*i] + " " + record[6+4*i]
            rule = (bag_from, int(bag_to_count), bag_to)
            rules.append(rule)
    return rules