import re


def proc(l):
    r = []
    for v in l:
        if v.isdigit():
            r.append(int(v))
        else:
            for ch in v:
                r.append(10**10 + ord(ch))
    r.append(-1)
    return r


def cmp(a, b):
    for i, j in zip(a, b):
        if i < j:
            return True
        if i > j:
            return False


spl = re.compile(r'(\d+|[a-zA-Z]+)')
n = int(input())
s0 = proc(spl.findall(input()))
for i in range(n):
    s = proc(spl.findall(input()))
    if cmp(s, s0):
        print('-')
    else:
        print('+')
