Go: package main

import (
	"bufio"
	"os"
	"unicode"
	"strconv"
	"fmt"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		s := strings.Split(scanner.Text(), "")
		ans, dir := make([]string, 0), ">"
		for _, x := range s {
			if IsLetter(x) {
				if dir == ">" {
					if !isIn(ans, x) {
						ans = append(ans, x)
					}
				} else {
					if !isIn(ans, x) {
						ans = append([]string{x}, ans...)
					}
				}
			} else if x == ">" || x == "<" {
				dir = x
			}
		}
		fmt.Println(strings.Join(ans, ""))
	}
}

func IsLetter(s string) bool {
	for _, r := range s {
		if !unicode.IsLetter(r) {
			return false
		}
	}
	return true
}

func isIn(arr []string, target string) bool {
	for _, val := range arr {
		if val == target {
			return true
		}
	}
	return false
}

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0130

"""
import sys
from sys import stdin
input = stdin.readline
from collections import deque


def bfs(u, result, out_edge, in_degree, processed):
    # ?????????????????????????????¨??????????????¢??°
    q = deque()
    q.append(u)
    processed[u] = True
    while q:
        u = q.popleft()
        result.append(u)
        for e in out_edge[u]:
            in_degree[e] -= 1   #  ?????¨?????????????????????(u)?????????????????¨???u?????\?¶????(e)????????\????¬???°???1???????????¨?????????
            if in_degree[e] == 0 and processed[e] == False: #  ??\????¬???°???1??????????????????0???????????°??????????????????????¬??????????????£??????????
                processed[e] = True
                q.append(e)


def solve(V, in_degree, out_edge):
    # ????????????????????????????????????????????????
    result = []
    processed = [False for _ in range(V)] #  ???????????????????????????????????????????????°
    for i, u in enumerate(in_degree):
        if u == 0 and processed[i] == False: #  ??\????¬???°???0???????????????
            bfs(i, result, out_edge, in_degree, processed)
    return result


def decode_txt(S):
    # ??\????????????????????????????§£???????????¨???????????±??¨?????´?????????????????±?????????
    es = set()
    cars = set()                #  ??????(?????????)?????°
    l = len(S)

    # ???????????????l -> ??? <- ?????¨???????????±?????????
    for i in range(l):
        if not 'a' <= S[i] <='z':
            continue
        s = S[i]
        try:
            t = S[i+3]
        except IndexError:
            break
        cars.add(s)
        cars.add(t)
        if S[i+1] == '-':
            es.add((s, t))
        else:
            es.add((t, s))
    return es, cars


def main(args):
    n = int(input())
    for _ in range(n):
        S = input().strip()
        if len(S) < 4:
            print(S)
            continue

        es_txt, cars = decode_txt(S)

        V = len(cars)
        num = 0
        mapping = dict()
        for c in cars:
            mapping[c] = num
            num += 1

        rev_mapping = dict(zip(mapping.values(), mapping.keys()))
        es = []
        for s, t in es_txt:
            es.append([mapping[s], mapping[t]])


        in_degree = [0 for _ in range(V)] #  ????????????????????\????¬???°
        out_edge = [[] for _ in range(V)] #  ???????????????????????????(??\?¶?)?????????????????????
        for s, t in es:
            out_edge[s].append(t)
            in_degree[t] += 1

        result = solve(V, in_degree, out_edge)
        txt = [rev_mapping[x] for x in result] #  ??°???????????????????????? (???: 0->'a')
        print(''.join(txt))


if __name__ == '__main__':
    main(sys.argv[1:])

Python: I=input
for _ in [0]*int(I()):
    t=I()
    ans=[t[0]]
    for x in range(1,len(t),3):
        if t[x+2] in ans:continue
        if t[x]=='-':ans+=[t[x+2]]
        else:ans=[t[x+2]]+ans
    print(*ans,sep='')

Python: N = int(input())

for l in range(N):
    s = input()
    ans = s[0]
    s = s[1:]
    while s != "":
        dist = s[0:2]
        ss = s[2]
        if not ss in ans:
            if dist == "->":
                ans = ans + ss
            else:
                ans = ss + ans
        s = s[3:]
    print(ans)

Python: import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  st=[tx-sx,ty-sy]; rst=R(st)
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    F=[rwt<r,rsw<r]
    if F==[1,0] or F==[0,1]: return 0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if a+1e-6>b and rst**2+1e-6>rsw**2-r**2: return 0
  return 1

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]

Python: n = int(input())
for i in range(n):
    s = input()
    train = [s[0]]
    for i in range(1,len(s),3):
        ind = train.index(s[i-1])
        if s[i:i+2] == "->" and s[i+2] not in train:
            train.insert(ind+1, s[i+2])
        elif  s[i:i+2] == "<-" and s[i+2] not in train:
            train.insert(ind,s[i+2])
    print("".join(train))

Python: # AOJ 0130 Train
# Python3 2018.6.19 bal4u

for _ in range(int(input())):
	s = list(input())
	ans, dir = [], '>'
	for x in s:
		if x.isalpha():
			if dir == '>':
				if x not in ans: ans.append(x)
			else:
				if x not in ans: ans.insert(0, x)
		elif x == '>' or x == '<': dir = x
	print(*ans, sep='')

Python: n = int(input())

for _ in range(n):
    train = ''
    seq = input()
    for i in range(0, len(seq), 3):
        if i == 0:
            train += seq[i]
        if seq[i - 2] == '-' and train[-1] == seq[i - 3]:
            train = train + seq[i]
        if seq[i - 2] == '<' and train[0] == seq[i - 3]:
            train = seq[i] + train
    print(train)

Python: inputCount = int(input())

for _ in range(inputCount):

    inputContent = input()
    trainOrder = [item for item in inputContent if str.isalpha(item)]
    directOrder = [item for item in inputContent if item == "<" or item == ">"]

    trainList = trainOrder[0]
    listIndex = 1
    trainLength = 1

    for train, direct in zip(trainOrder[1:], directOrder):

        if listIndex == 1 and direct == "<":
            trainList = train + trainList
            trainLength += 1
        elif listIndex == trainLength and direct == ">":
            trainList += train
            listIndex += 1
            trainLength += 1

        elif direct == "<":
            listIndex -= 1
        else:
            listIndex += 1

    print(trainList)