#!/usr/local/bin/python
import sys,string

import sys,string;
line=sys.stdin.readline()
while line!="":
  line=string.strip(line)
  if line!="":
    check=0
    lex=0
    if string.find(line,"->") > 0:
      if string.find(line,"|:") > 0:
        lex=1
      else:
        lex=0
      i=string.find(line,":")
      if (i<0) or (line[i+1:i+2] != ":"):
        check=+1
      brak1=""
      brak2=""
      s=string.find(line,"[")
      e=string.find(line,"]")
      if (e>0) or (s>0):
        brak1=line[s:e]
      s=string.find(line,"[",e)
      e=string.find(line,"]",s)
      if (e>0) or (s>0):
        brak2=line[s:e]
      if brak1=="" or brak2=="":
        check+=1
      else:
        if (string.count(brak1,"\"") % 2)!=0 or (string.count(brak2,"\"") % 2)!=0:
          check+=1
        if lex==1:
          if string.count(brak1,"\"]")+string.count(brak2,"\"]")!=0:
            check+=1
      if check!=0:
        print line
    else:
      if line.find(":") > 0:
        if line.find(":") < 2:
          check+=1
      if (lex==1):
        if line.find("x1")+line.find("y1")!=2:
          check+=1
    if check!=0:
      print line

  line=sys.stdin.readline()
