#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{

    int n, m, c, i;
    char *field[64], *p;
    char buf[32768];

    field[i = 0] = p = buf;

    while ((c = getchar()) != EOF) {
        if (c == ';') {
            *p++ = 0;
            if (i < sizeof(field)/sizeof(*field) - 1)
                field[++i] = p;
        }
        else if (c != '\n')
        {
            if (p < buf + sizeof(buf) - 2)
                *p++ = c;
        }
        else {
            *p = 0;

            for (n = 3; n < i-1; n++)
                if (field[n][0])
                    for (m = n+1; m < i; m++)
                        if (strcmp(field[n], field[m]) == 0)
                            field[m][0] = 0;

            for (n = 0; n < i; n++)
                fputs(field[n], stdout), fputc(';', stdout);

            fputc('\n', stdout);
            field[i = 0] = p = buf;
        }
    }
}
