def read(data):
    """Return the start string and the rules, as a dictionary."""
    lines = data.splitlines()
    rules = dict()      # one entry XY: L for each rewriting rule XY -> L
    for index in range(2, len(lines)):
        line = lines[index]
        rules[line[:2]] = line[-1]
    return lines[0], rules