#!/usr/bin/env perl

use strict;
use warnings;

open(STDIN, '<', 'list.txt') || die "can't open input";
binmode(STDIN);

open(STDOUT, '>', 'nodup.txt') || die "can't open output";
binmode(STDOUT);

while (my $line = readline(STDIN))
{
    chomp $line;
    my @F = split(/;/,$line);
    my %H;
    for (my $i=3; $i<=$#F; ++$i) {
        $F[$i] = ''
            if $H{$F[$i]}++;
    }
    print join(';',@F), ";\n";
}

die("error: readline failed:$!")
    if !eof(STDIN);
