#include <cstring>
#include <iostream>
#include <unordered_set>

int main(int argc,char *argv[])
{
  std::ios_base::sync_with_stdio(false) ; // this makes an actual difference!
  char buffer[0x10000] ; // extent if needed or make it dynamic if you like

  struct Key
  {
    size_t operator()(char const *p) const
    {
      unsigned long hash = 5381;
      while (int c = *p++)
	hash = ((hash << 5) + hash) + c ;
      // see http://www.cse.yorku.ca/~oz/hash.html
      return hash ;
    }
  } ;
  struct Equal
  {
    bool operator()(char const *p,char const *q) const
    {
      return 0 == strcmp(p,q) ;
    }
  } ;
  std::unordered_set<char const*,Key,Equal> S ;

  while (std::cin.getline(buffer,sizeof(buffer)))
  {
    S.clear() ;
    size_t n = 0 ;
    auto p = buffer ;
    auto q = p ;
    while (*q != '\0')
    {
      if (*q == ';')
      {
	*q++ = '\0' ;
	if (n<3 || S.insert(p).second) std::cout << p << ';' ;
	else                           std::cout      << ';' ;
	p = q ;
	++n ;
      }
      else ++q ;
    }
    if (n<3 || S.insert(p).second) std::cout << p << '\n' ;
    else                           std::cout      << '\n' ;
  }
  if (!std::cin.eof())
  {
    std::cerr << "line probably too long (please extend buffer size)\n" ;
    exit(1) ;
  }
  return 0 ;
}
