import sys
sys.setrecursionlimit(10 ** 6)
# pow(3,2,5)==4
def isg(s):
    f1=0
    count1=0
    f2=0
    count2=0
    for i in s:
        if i=="<":
            f1=1
            count1+=1
        if i==">":
            f2=1
            count2+=1
    # print f1,f2,"um"
    return f1^f2,count1,count2
    # if f1 and f2:return 0
    # if (not f1) and (not f2):return 0
    # return 1
inp=input()
for i in range(inp):

    i2=input()
    inp2=raw_input()
    flag=1
    yed=inp2
    while flag:
        flag=0
        s=""
        i=0
        while i<len(inp2):
            if i<len(inp2)-1 and inp2[i]==">" and inp2[i+1]=="<":
                i+=2
                flag=1
            else:
                s+=inp2[i]
                i+=1
        inp2=s
    # print s
    c1=0
    c2=0
    # print s,"s"
    for i in s:
            if i=="<":c1+=1
            if i==">":c2+=1
    news=""
    if c1%2:
        news+="<"
    if c2%2:
        news+=">"
    # print news,"he"
    if not news:
        print 1
    else:
        if len(news)==2:
            print 1
        else:
            print 0
