#!/usr/bin/env python
import sys

t = sys.stdin.readline()
t = int(t)

for i in xrange(t):
	n = sys.stdin.readline()
	n = int(n)
	s = sys.stdin.readline()
	s_trim = [s[0]]
	for i in xrange(1, n):
		if s[i] != s_trim[-1]:
			s_trim.append(s[i])
	if len(s_trim) >= 2 and s_trim[0] == '<'  and s_trim[-1] == '>':
		print 1
	else:
		print 0
