fork download
  1. z=input();B=z.split();M='i[::-1].translate({41:40,40:41,125:123,123:125,62:60,60:62,93:91,91:93})';f=B+[eval(M)for i in B if eval(M)not in B];d=[f.pop(0)]
  2. for h in d:
  3. try:d.append([f.pop(f.index(c))for c in f if h[-1]==c[0]][0])
  4. except:break
  5. print(''.join(d)if len(d)>=len(B)else'')
Success #stdin #stdout 0.02s 9936KB
stdin
(-] ]-> >-} }-) )-[ [-< <-{ {-(
stdout
(-]]->>-}}-))-[[-<<-{{-((-{{-<