t = int(raw_input())

def remove_sequences(s):
    if len(s) == 0:
        return ''
    new_s = s[0]
    for i in xrange(len(s)):
        if s[i] != new_s[-1]:
            new_s += s[i]
    return new_s            

for i in xrange(t):
    n = int(raw_input())
    s = remove_sequences(raw_input())
    if len(s) == 0 or s[0] == '>' or s[-1] == '<' or s[0] == s[-1]:
        print 0
    else:
        print 1
