#!/usr/bin/env python3

def main():
    with open('list.txt', mode='r') as fin, open('nodup.txt', mode='w') as fout:
        for row in fin.readlines():
            row = row.split(';')
            known_elements = set()
            for i in range(3, len(row)):
                element = row[i]
                if element in known_elements:
                    row[i] = ''
                else:
                    known_elements.add(element)
            print(';'.join(row), end='', file=fout)

if __name__ == '__main__':
    main()
