Buggy python submission (verdict: Runtime Error):
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)



Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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)



Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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)



Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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)



Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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)



Fixed submission:
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)