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: # AOJ 0130 Train
# Python3 2018.6.19 bal4u

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

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

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:i] == '->' and train[-1] == seq[i - 3]:
            train = train + seq[i]
        if seq[i - 2:i] == '<-' and train[0] == seq[i - 3]:
            train = seq[i] + train
    print(train)

Python: n = int(input())

for _ in range(n):
    train = ''
    seq = input()
    for i in range(len(seq) // 3 + 1):
        if i == 0:
            train += seq[i]
        if seq[3 * i - 2] == '-' and train[-1] == seq[3 * (i - 1)]:
            train = train + seq[3 * i]
        if seq[3 * i - 2] == '<' and train[0] == seq[3 * (i - 1)]:
            train = seq[3 * 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 = []
    trainList.append(trainOrder[0])
    listIndex = 1
    trainLength = 1

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

        if listIndex == 1 and direct == "<":
            trainList.insert(0, train)
            trainLength += 1
        elif listIndex == trainLength and direct == ">":
            trainList.append(train)
            listIndex += 1
            trainLength += 1
            
        elif direct == "<":
            listIndex -= 1
        elif direct == ">":
            listIndex += 1

    output = "".join(trainList)
    print(output)

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 namedtuple
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
        num_s = ord(s) - ord('a') #  ???????¨????'a'???0?????¨????????????????????°????????????
        num_t = ord(t) - ord('a')
        cars.add(num_s)
        cars.add(num_t)
        if S[i+1] == '-':
            es.add(edge(num_s, num_t))
        else:
            es.add(edge(num_t, num_s))
    return es, cars


edge = namedtuple('edge', ['f', 't'])
def main(args):
    n = int(input())
    for _ in range(n):
        S = input().strip()
        if len(S) == 1:
            print(S)
            continue

        es, cars = decode_txt(S)

        V = len(cars)
        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 = [chr(x+ord('a')) for x in result] #  ??°???????????????????????? (???: 0->'a')
        print(''.join(txt))


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