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 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]
        t = S[i+3]
        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))
        if i + 3 + 1 == l:
            break
    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:])

Python: def proc(i):
    l  = len(i)
    o = [ i[0] ]
    io = 1
    ii = 1

    while ii < l:
#        print(o)
#        print("io={0} d={1} c={2} o={3}".format(io,i[ii:ii+2],i[ii+2],o))
        if i[ii:ii+2] == "<-":
            io -= 1
        else:
            io += 1

        if (io == 0):
            o.insert(io,i[ii+2])
            io += 1
        elif (io == len(o)+1):
            o.insert(io,i[ii+2])
        else:
#            print("i={0} o={1}".format(i[ii+2],o[io-1]))
            if i[ii+2] != o[io-1]:
                raise untimeError("error")

        ii += 3

    s = ""
    for c in o:
        s += c
    return s


n = int(input())

for _ in range(n):
    l = input()
    r = proc(l)
    print(r)

Python: num= int(input())
OFFSET =25
for _ in range(num):
    T = [None] * (25+1+25)
    s = input()
    t = list(s[0::3])
    d = list(s[2::3])

    for i in range(len(t)):
        if i == 0:
            p = 0
        else:
            if d[i-1] == ">":
                p += 1
            else:
                p -= 1
        T[p+OFFSET] = t[i]
    for i in T:
        if i:
            print(i,end="")
    print()

Python: for _ in range(int(input())):
    s=list(input())
    word,direct=[],""
    for i in s:
        if i.isalpha():
            if direct==">":
                if i not in word:word.append(i)
            else:
                if i not in word:word.insert(0,i)
        elif i=="<" or i==">":direct=i
    print(*word,sep="")

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: from collections import deque

if __name__ == '__main__':

	n = int(input())

	for _ in range(n):
		cmd = input()
		A = deque()
		flg = 0
		for y in cmd:
			if y != "-":
				if y == ">":
					flg = 0
				elif y == "<":
					flg = 1
				else:
					if y not in A:
						if flg == 0:
							A.append(y)
						else:
							A.appendleft(y)

		B = ""
		for x in A:
			B += x
		print(B)