Chef found a strange string yesterday - a string of signs s, where each sign is either a '<', '=' or a '>'. Let N be the length of this string. Chef wants to insert N + 1 positive integers into this sequence and make it valid. A valid sequence is a sequence where every sign is preceded and followed by an integer, and the signs are correct. That is, if a sign '<' is preceded by the integer a and followed by an integer b, then a should be less than b. Likewise for the other two signs as well. 
Chef can take some positive integers in the range [1, P] and use a number in the range as many times as he wants.
Help Chef find the minimum possible P with which he can create a valid sequence.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The only line of each test case contains the string of signs s, where each sign is either '<', '=' or a '>'. 

-----Output-----
For each test case, output a single line containing an integer corresponding to the minimum possible P. 

-----Constraints-----
- 1 ≤ T, |s| ≤ 105
- 1 ≤ Sum of |s| over all test cases in a single test file ≤ 106

-----Subtasks-----
Subtask #1 (30 points)
- 1 ≤ T, |s| ≤ 103
- 1 ≤ Sum of |s| over all test cases in a single test file ≤ 104

Subtask #2 (70 points)
- Original constraints

-----Example-----
Input:
4
<<<
<><
<=>
<=<

Output:
4
2
2
3

-----Explanation-----
Here are some possible valid sequences which can be formed with the minimum P for each of the test cases:
1 < 2 < 3 < 4
1 < 2 > 1 < 2
1 < 2 = 2 > 1
1 < 2 = 2 < 3

Source: codechef | Difficulty: MEDIUM
Tags: String algorithms

Combinatorics

Data structures


Solutions:
t = int(input())
while t > 0:
	s = input()
	s = s.replace('=', '')
	(i, j, m) = (0, 0, 0)
	while i < len(s):
		j = i
		while j < len(s) and s[j] == s[i]:
			j += 1
		m = max(m, j - i)
		i = j
	print(m + 1)
	t -= 1


t = input()
l = []
j = 0
lenm = lenb = 0
mas = []
dlina = 0
for i in range(int(t)):
	stroka = input()
	n = len(stroka)
	while j < n and stroka[j] == '=':
		j = j + 1
	if j != n:
		curr = stroka[j]
		for c in stroka[j:]:
			if c == curr:
				mas.append(c)
				if len(mas) > dlina:
					dlina = len(mas)
			elif c != '=':
				curr = c
				mas = [c]
	if n > 0:
		l.append(dlina + 1)
	else:
		l.append(0)
	mas = []
	dlina = 0
	j = 0
for x in l:
	print(x)


for _ in range(0, int(input())):
	a = input().strip().replace('=', '')
	m = 0
	temp = 0
	for i in a:
		if i == '>':
			temp += 1
		else:
			temp = 0
		m = max(m, temp)
	temp = 0
	for i in a:
		if i == '<':
			temp += 1
		else:
			temp = 0
		m = max(m, temp)
	print(m + 1)


def solve(s):
	temp = []
	for c in s:
		if c != '=':
			temp.append(c)
	count = 1
	ans = 1
	if temp:
		for i in range(1, len(temp)):
			if temp[i] == temp[i - 1]:
				count += 1
			else:
				ans = max(ans, count)
				count = 1
		ans = max(ans, count)
		print(ans + 1)
	else:
		print(1)
n = int(input())
for i in range(n):
	s = input().strip()
	solve(s)


t = int(input())
for I in range(t):
	s = input().rstrip('\r')
	count1 = 1
	flag1 = 0
	flag2 = 0
	max1 = 1
	for i in range(len(s)):
		if s[i] == '<':
			flag1 = 1
			if flag2 == 1:
				count1 = 1
				flag2 = 0
			count1 += 1
			if count1 > max1:
				max1 = count1
		elif s[i] == '>':
			flag2 = 1
			if flag1 == 1:
				count1 = 1
				flag1 = 0
			count1 += 1
			if count1 > max1:
				max1 = count1
	print(max1)


import re
for _ in range(int(input())):
	seq = ''.join(filter(lambda x: x != '=', input()))
	forward = 0
	backward = 0
	if '<' in seq:
		forward = len(max(re.findall('<<*', seq)))
	if '>' in seq:
		backward = len(max(re.findall('>>*', seq)))
	print(max(forward, backward) + 1)


tc = int(input())
while tc:
	str = input()
	l = len(str)
	tl = l
	pre = str[0]
	cnt = 1
	max = 0
	flag = 0
	for x in range(1, l):
		if str[x] != '=':
			flag = 1
			cur = str[x]
			if cur == pre:
				cnt += 1
			else:
				if max < cnt:
					max = cnt
				cnt = 1
			pre = cur
	if flag == 0 and pre == '=':
		print('1')
	else:
		if max < cnt:
			max = cnt
		if max + 1 > 2:
			print(max + 1)
		else:
			print('2')
	tc = tc - 1


for _ in range(int(input())):
	q = input()
	x = 0
	o = 0
	y = '=' + q
	z = -1
	c = -1
	for i in range(1, len(y)):
		if y[i] == '>' and (y[i - 1] == '=' or y[i - 1] == '>'):
			x += 1
		elif y[i] == '<' and (y[i - 1] == '=' or y[i - 1] == '<'):
			o += 1
		else:
			if z < o:
				z = o
			if c < x:
				c = x
			if y[i] == '>':
				x = 1
				o = 0
			if y[i] == '<':
				o = 1
				x = 0
	if z < o:
		z = o
	if c < x:
		c = x
	print(max(z, c) + 1)


t = int(input())
for a0 in range(t):
	n = input()
	gis = []
	g1 = 0
	l1 = 0
	z = n.replace('=', '')
	for a1 in z:
		if a1 == '>':
			g1 += 1
		else:
			gis.append(g1)
			g1 = 0
	gis.append(g1)
	for a2 in z:
		if a2 == '<':
			l1 += 1
		else:
			gis.append(l1)
			l1 = 0
	gis.append(l1)
	print(max(gis) + 1)


casos = int(input())
while casos > 0:
	signos = input()
	maximo = 1
	largo = len(signos)
	i = 0
	while i < largo:
		if signos[i] != '=':
			necesito = 0
			j = i
			while j < largo:
				if signos[i] != signos[j] and signos[j] != '=':
					break
				elif signos[i] == signos[j]:
					necesito += 1
				j += 1
			necesito += 1
			maximo = int((maximo + necesito + abs(maximo - necesito)) / 2)
			i += j - i
		else:
			i += 1
	print(maximo)
	casos -= 1


for x in range(int(input())):
	s = input()
	maxx = 0
	(a, b) = (0, 0)
	for i in range(len(s)):
		if s[i] == '<':
			a += 1
			b = 0
			if a > maxx:
				maxx = a
		elif s[i] == '>':
			b += 1
			a = 0
			if b > maxx:
				maxx = b
	print(maxx + 1)


t = int(input())
i = 0
while i < t:
	sum = 0
	st = input()
	st = st.replace('=', '')
	l = len(st)
	j = 0
	max = 0
	if l == 0:
		print(1)
	else:
		while j < l - 1:
			if st[j] == st[j + 1]:
				sum += 1
			else:
				sum = 0
			if sum > max:
				max = sum
			j += 1
		print(max + 2)
	i += 1


t = int(input())
for z in range(t):
	s = input()
	j = 1
	ans = 1
	a = []
	for i in s:
		if i != '=':
			a.append(i)
	if len(a) == 0:
		print(1)
		continue
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			j += 1
			ans = max(ans, j)
		else:
			j = 1
	print(ans + 1)


T = int(input())
for _ in range(T):
	ipStr = input()
	maxValue = 0
	currentCh = '<'
	currentValue = 0
	for ch in ipStr:
		if ch == '=':
			continue
		elif ch == currentCh:
			currentValue += 1
		else:
			currentValue = 1
			currentCh = ch
		if currentValue > maxValue:
			maxValue = currentValue
	print(maxValue + 1)


for _ in range(int(input())):
	s = list(''.join(input().split('=')))
	n = 1
	m = 0
	i = 0
	if s == []:
		m = 1
	while i < len(s):
		if s[i] == '<':
			n += 1
			if n > m:
				m = n
		elif s[i] == '>':
			if i + 1 < len(s) and s[i + 1] != '>':
				n = 1
			elif i + 1 < len(s) and s[i + 1] == '>':
				for j in range(i, len(s)):
					if s[j] == '<':
						x = j - i
						i = j - 1
						if n - x < 1:
							y = n + 1 + (n - x) * -1
							if y > m:
								m = y
						break
					elif j == len(s) - 1:
						x = j - i
						i = j
						if n - x < 1:
							y = n + 2 + (n - x) * -1
							if y > m:
								m = y
					n = 1
			elif n == 1:
				n = 1
				if m < 2:
					m = 2
			else:
				n = n - 1
		i += 1
	print(m)


import math
t = 0
try:
	t = int(input())
except EOFError as e:
	pass
for i in range(t):
	myStr = input().replace('=', '')
	if len(myStr) == 0:
		print(1)
		continue
	ans = 0
	count = 1
	for k in range(len(myStr) - 1):
		if myStr[k] == myStr[k + 1]:
			count += 1
		else:
			count = 1
		ans = max(count, ans)
	print(ans + 1)


for t in range(int(input())):
	s = input()
	ans = count = 0
	last = s[0]
	for c in s:
		if c == '=':
			continue
		if c == last:
			count += 1
		else:
			ans = max(ans, count)
			count = 1
			last = c
	print(max(ans, count) + 1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	n = I()
	r = []
	for _ in range(n):
		a = b = d = 0
		m = 0
		s = S()
		l = len(s)
		for i in range(l):
			c = s[i]
			if c == '=':
				continue
			if c == '<':
				a += 1
				if m < a:
					m = a
				t = 0
				for j in range(i - 1, -1, -1):
					if s[j] == '=':
						continue
					if s[j] == '>':
						t += 1
					else:
						break
				if m < t:
					m = t
			if c == '>':
				a = 0
		t = 0
		for j in range(l - 1, -1, -1):
			if s[j] == '=':
				continue
			if s[j] == '>':
				t += 1
			else:
				break
		if m < t:
			m = t
		r.append(m + 1)
	return '\n'.join(map(str, r))
print(main())


from itertools import groupby
test = int(input())
for i in range(test):
	signs = list(input())
	Signs = [j for j in signs if j != '=']
	if Signs.count('=') == len(Signs):
		print('1')
	else:
		consecutiveList = [sum((1 for l in g)) for (k, g) in groupby(Signs)]
		print(max(consecutiveList) + 1)


t = int(input())
for i in range(t):
	s = input()
	(count, temp, less, great, equals) = (0, 0, 0, 0, 0)
	for j in range(0, len(s)):
		if s[j] == '<':
			less += 1
			great = 0
			if count <= less:
				count = less + 1
		elif s[j] == '>':
			great += 1
			less = 0
			temp = 2
			if count <= great:
				count = great + 1
		if s[j] == '=':
			equals = 1
	if equals != 0 and count == 0:
		print(equals)
	else:
		print(count)


t = int(input())
for z in range(t):
	(p, q) = (1, 0)
	s = []
	a = input()
	for i in a:
		if i != '=':
			s.append(i)
	n = len(s)
	if n == 1:
		print(2)
		continue
	for i in range(n - 1):
		if s[i] == s[i + 1]:
			p += 1
		else:
			p = 1
		q = max(p, q)
	print(q + 1)


import itertools
for test in range(int(input())):
	a = input()
	c = 0
	m = a.count('=')
	if m == len(a):
		c = 1
		print('1')
	if c == 0:
		n = a.replace('=', '')
		l = list(n)
		z = [(x[0], len(list(x[1]))) for x in itertools.groupby(l)]
		print(max(z, key=lambda x: x[1])[1] + 1)


n = int(input())
for i in range(n):
	k = 0
	n1 = 0
	p = 0
	q = 0
	lis = input()
	for j in lis:
		if j == '<':
			if k == 1:
				n1 += 1
				if n1 > p:
					p = n1
			else:
				n1 = 0
				n1 += 1
				if n1 > p:
					p = n1
				k = 1
		if j == '>':
			if k == 0:
				n1 += 1
				if n1 > q:
					q = n1
			else:
				n1 = 0
				n1 += 1
				if n1 > q:
					q = n1
				k = 0
	if p > q:
		print(p + 1)
	else:
		print(q + 1)


t = int(input())
for _ in range(t):
	s = input().replace('=', '')
	if len(s) == 0:
		print(1)
		continue
	(ans, count) = (0, 1)
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			count += 1
		else:
			ans = max(ans, count)
			count = 1
	ans = max(count, ans)
	print(ans + 1)


def solve(sign):
	k = 0
	minVal = k
	maxVal = k
	n = len(sign)
	for i in range(n):
		if sign[i] == '>':
			k = k - 1
		if sign[i] == '<':
			k = k + 1
		minVal = min(minVal, k)
		maxVal = max(maxVal, k)
	kVal = -1 * minVal + 1
	p = kVal + maxVal
	return p
	pass

def solve1(sign):
	k = 0
	minVal = k
	maxVal = k
	sign = sign + '?'
	n = len(sign)
	curSign = sign[0]
	count = 1
	for i in range(1, n):
		if sign[i] == curSign:
			count += 1
		else:
			if sign[i] == '=':
				continue
			if curSign == '<' and count <= abs(minVal):
				k = maxVal
			elif curSign == '<' and count > abs(minVal):
				k = count - abs(minVal)
				maxVal = max(maxVal, k)
			elif curSign == '>' and count <= maxVal:
				k = minVal
			elif curSign == '>' and count > maxVal:
				k = maxVal - count
				minVal = min(minVal, k)
			curSign = sign[i]
			count = 1
	kVal = -1 * minVal + 1
	p = kVal + maxVal
	return p
	pass
n = int(input())
for i in range(n):
	line = input()
	p = solve1(line)
	print(p)
p = 10000000000000


t = int(input())
for i in range(t):
	s = input()
	m = 0
	(a, b) = (0, 0)
	for j in range(len(s)):
		if s[j] == '<':
			a += 1
			b = 0
			if a > m:
				m = a
		elif s[j] == '>':
			b += 1
			a = 0
			if b > m:
				m = b
	print(m + 1)


for _ in range(int(input())):
	l = list(input())
	temp = ['<', '=']
	(fg, c) = (0, 0)
	(ans1, ans2) = (0, 0)
	for i in range(len(l)):
		if l[i] in temp:
			fg = 1
			if l[i] == '<':
				c += 1
		elif fg == 1:
			ans1 = max(ans1, c)
			fg = 0
			c = 0
	if fg == 1:
		ans1 = max(ans1, c)
	ans1 += 1
	temp = ['>', '=']
	(fg, c) = (0, 0)
	for i in range(len(l)):
		if l[i] in temp:
			fg = 1
			if l[i] == '>':
				c += 1
		elif fg == 1:
			ans2 = max(ans2, c)
			fg = 0
			c = 0
	if fg == 1:
		ans2 = max(ans2, c)
	ans2 += 1
	print(max(ans1, ans2))


t = int(input())
for i in range(t):
	a = input()
	temp = 0
	ans = 0
	b = a.replace('=', '')
	for j in range(len(b)):
		if b[j] == '<':
			temp += 1
		else:
			temp = 0
		ans = max(ans, temp)
	temp = 0
	for j in range(len(b)):
		if b[j] == '>':
			temp += 1
		else:
			temp = 0
		ans = max(ans, temp)
	print(ans + 1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	s = input()
	max = 0
	c = c1 = 0
	for i in range(len(s)):
		if s[i] == '>':
			c += 1
			c1 = 0
			if c > max:
				max = c
		if s[i] == '<':
			c1 += 1
			c = 0
			if c1 > max:
				max = c1
	print(max + 1)


for t in range(int(input())):
	s = input()
	l = 0
	g = 0
	e = 0
	maxl = 0
	maxg = 0
	i = 0
	j = 0
	length = len(s)
	for x in range(length):
		if s[x] == '=':
			e += 1
		elif s[x] == '<':
			l += 1
			i += 1
			j = 0
			if maxl < i:
				maxl = i
		else:
			g += 1
			j += 1
			i = 0
			if maxg < j:
				maxg = j
	if maxl < i:
		maxl = i
	if maxg < j:
		maxg = j
	if e == length:
		print(1)
	elif l == length or g == length:
		print(length + 1)
	elif maxl > maxg:
		print(1 + maxl)
	else:
		print(1 + maxg)


for i in range(int(input())):
	st = input()
	a = '<'
	b = '>'
	c = '='
	j = 0
	count = 1
	list2 = [x for x in st if x != '=']
	if len(list2) == 0:
		print(1)
	else:
		list1 = []
		while j < len(list2) - 1:
			if list2[j] == list2[j + 1]:
				count += 1
			else:
				list1.append(count)
				count = 1
			j += 1
		list1.append(count)
		max1 = list1[0]
		for k in list1:
			if k > max1:
				max1 = k
		print(max1 + 1)


t = int(input())
for _ in range(t):
	seq = list(input())
	counter = 0
	maximum = 0
	Greaterthan = False
	for i in seq:
		if i == '<':
			if Greaterthan:
				counter += 1
			else:
				if counter > maximum:
					maximum = counter
				Greaterthan = True
				counter = 1
		elif i == '>':
			if Greaterthan:
				if counter > maximum:
					maximum = counter
				Greaterthan = False
				counter = 1
			else:
				counter += 1
	if counter > maximum:
		maximum = counter
	print(maximum + 1)


for i in range(int(input())):
	str1 = input()
	(leftbrack, rightbrack, count) = (0, 0, 0)
	for _ in range(0, len(str1)):
		if str1[_] == '<':
			(leftbrack, rightbrack) = (leftbrack + 1, 0)
			if leftbrack > count:
				count = leftbrack
		elif str1[_] == '>':
			(rightbrack, leftbrack) = (rightbrack + 1, 0)
			if rightbrack > count:
				count = rightbrack
	print(count + 1)


x = int(input())
for _ in range(x):
	n = input()
	lol = []
	for i in n:
		if i != '=':
			lol.append(i)
	n = ''.join(lol)
	l = 0
	if len(n) > 0:
		l += 1
		c = 1
		for i in range(1, len(n)):
			if n[i] == n[i - 1]:
				c += 1
			else:
				l = max(l, c)
				c = 1
		l = max(l, c)
	print(l + 1)


test = int(input())
while test != 0:
	abc = input()
	abc = abc.replace('=', '')
	maxi = 0
	count = 0
	count1 = 0
	for i in abc:
		if i == abc[0]:
			count = count + 1
			count1 = 0
		else:
			count1 = count1 + 1
			count = 0
		maxi = max(count, count1, maxi)
	print(maxi + 1)
	test = test - 1


for _ in range(int(input())):
	sk = input()
	maxx = 0
	maxy = 0
	x = 0
	y = 0
	for c in sk:
		if c == '<':
			x += 1
			y = 0
			if x > maxx:
				maxx = x
		if c == '>':
			y += 1
			x = 0
			if y > maxy:
				maxy = y
	print(max(maxx, maxy) + 1)


for i in range(int(input())):
	s = input()
	req = -1
	con = 1
	i = 1
	prev = s[0]
	while i < len(s):
		if s[i] == '=':
			pass
		elif s[i] == prev:
			con += 1
		else:
			if con > req:
				req = con
			con = 1
			prev = s[i]
		i += 1
	if con > req:
		req = con
	a = s.count('<')
	b = s.count('>')
	if a != 0 or b != 0:
		req += 1
	print(req)


import collections as clts
import math
import heapq

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

def lcm(x, y):
	return int(x / gcd(x, y) * y)
for _ in range(int(input())):
	S = input()
	newS = []
	for i in range(len(S)):
		if S[i] != '=':
			newS.append(S[i])
	i = 0
	p = 0
	while i < len(newS):
		currChar = newS[i]
		j = i
		x = 0
		while j < len(newS):
			if newS[j] == currChar:
				x += 1
			else:
				break
			j += 1
		if x > p:
			p = x
		i = j
	print(p + 1)


import math
t = int(input())
while t > 0:
	l = []
	s1 = input()
	s = ''
	for i in s1:
		if i != '=':
			s = s + i
	max = -99999
	sum = 0
	for i in range(0, len(s) - 1):
		if s[i] != '=':
			sum = sum + 1
			if s[i] != s[i + 1]:
				if sum > max:
					max = sum
				sum = 0
	if len(s) > 1 and s[i] != '=':
		if sum + 1 > max:
			max = sum + 1
	if len(s) == 1 and s[0] != '=':
		max = 1
	if max == -99999:
		print(1)
	else:
		print(max + 1)
	t = t - 1


for t in range(int(input())):
	s = input().replace('=', '')
	a = s.split('>') + s.split('<')
	a = list(filter(lambda x: x != '', a))
	l = 0
	for i in a:
		l = max(l, len(i))
	print(l + 1)


for x in range(0, int(input())):
	s = input()
	s = s.replace('=', '')
	(res, b, l, count) = (0, 0, len(s), 0)
	if l > 0:
		while b < l:
			curr = s[b]
			b += 1
			count = 1
			while b < l and s[b] == curr:
				count += 1
				b += 1
			res = max(res, count)
	print(res + 1)


for _ in range(int(input())):
	s = input()
	l = len(s)
	(s1, s2) = ([0] * l, [0] * l)
	if s[0] == '>':
		s1[0] = 1
	elif s[0] == '<':
		s2[0] = 1
	for i in range(1, l):
		if s[i] == '>':
			if s[i - 1] == '>' or s[i - 1] == '=':
				s1[i] = s1[i - 1] + 1
			elif s[i - 1] == '<':
				s1[i] = 1
		elif s[i] == '<':
			if s[i - 1] == '<' or s[i - 1] == '=':
				s2[i] = s2[i - 1] + 1
			elif s[i - 1] == '>':
				s2[i] = 1
		else:
			s1[i] = s1[i - 1]
			s2[i] = s2[i - 1]
	print(max(max(s1), max(s2)) + 1)


for _ in range(int(input())):
	s = input()
	cur = ans = 0
	last = '?'
	for i in s:
		if i == '=':
			continue
		if i != last:
			ans = max(ans, cur)
			cur = 1
			last = i
		else:
			cur += 1
	ans = max(ans, cur)
	print(ans + 1)


for _ in range(int(input())):
	line = input()
	line = line.replace('=', '')
	values = list(line)
	result = 0
	answer = 0
	if len(values) == 0:
		print(1)
	else:
		for i in range(1, len(values)):
			if values[i] == values[i - 1]:
				answer = answer + 1
			else:
				if result < answer:
					result = answer
				answer = 0
		if result < answer:
			result = answer
		print(result + 2)


import re
n = int(input())
for i in range(0, n):
	s = input()
	eq_count = s.count('=')
	if eq_count == len(s):
		print('1')
	else:
		str = s.replace('=', '')
		len1 = len(max(re.findall('(<+<)*', str)))
		len2 = len(max(re.findall('(>+>)*', str)))
		res = max(len1, len2, 1)
		print(res + 1)


def main():
	t = eval(input())
	while t != 0:
		str = input()
		Cur1 = 0
		Cur2 = 0
		Max = 0
		for i in str:
			if i == '<':
				Cur1 = Cur1 + 1
				if Cur2 != 0:
					Cur2 = 0
			elif i == '>':
				Cur2 = Cur2 + 1
				if Cur1 != 0:
					Cur1 = 0
			Max = max(max(Cur1, Cur2) + 1, Max)
		print(Max)
		t = t - 1
main()


t = int(input())
for i in range(t):
	s = input()
	m = 0
	c = 0
	j = 0
	while j < len(s):
		if s[j:j + 1] == '=':
			j = j + 1
			continue
		c = 0
		if s[j:j + 1] == '<':
			while s[j:j + 1] != '>' and j < len(s):
				if s[j:j + 1] == '=':
					j = j + 1
					continue
				c = c + 1
				j = j + 1
			if c > m:
				m = c
		c = 0
		if s[j:j + 1] == '>':
			while s[j:j + 1] != '<' and j < len(s):
				if s[j:j + 1] == '=':
					j = j + 1
					continue
				c = c + 1
				j = j + 1
			if c > m:
				m = c
	print(m + 1)


t = int(input())
for _ in range(t):
	st = input()
	st = st.replace('=', '')
	if len(st) > 0:
		ans = 0
		temp = 1
		for i in range(1, len(st)):
			if st[i] == st[i - 1]:
				temp += 1
			else:
				ans = max(ans, temp + 1)
				temp = 1
		ans = max(ans, temp + 1)
		print(ans)
	else:
		print(1)


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	flag = 0
	cnt = 0
	mx = 0
	for j in range(l):
		if flag == 1:
			if s[j] == '<':
				cnt += 1
			elif s[j] == '>':
				mx = max(mx, cnt)
				cnt = 1
				flag = 2
		elif flag == 2:
			if s[j] == '>':
				cnt += 1
			elif s[j] == '<':
				mx = max(mx, cnt)
				cnt = 1
				flag = 1
		elif s[j] == '<':
			cnt = 1
			flag = 1
		elif s[j] == '>':
			cnt = 1
			flag = 2
	mx = max(mx, cnt)
	print(mx + 1)


for _ in range(int(input())):
	st = input()
	arr = []
	for i in st:
		if i != '=':
			arr.append(i)
	n = ''.join(arr)
	l = 0
	if len(n) > 0:
		l += 1
		cnt = 1
		for i in range(1, len(n)):
			if n[i] == n[i - 1]:
				cnt += 1
			else:
				l = max(l, cnt)
				cnt = 1
		l = max(l, cnt)
	print(l + 1)


t = int(input())
for i in range(0, t):
	str = input()
	temp = 0
	maximum = 0
	j = 0
	test = 0
	if str[0] == '>' or str[0] == '<':
		test = 1
	for i in range(0, len(str)):
		if str[i] == '=':
			continue
		elif str[i] == str[j] and i != 0:
			temp += 1
			j = i
		else:
			maximum = max(maximum, temp)
			temp = 0
			j = i
	maximum = max(maximum, temp)
	if j != 0 or test == 1:
		print(maximum + 2)
	else:
		print(1)


for i in range(int(input())):
	s = input()
	z = []
	l = g = 1
	for j in s:
		if j == '<':
			g = g + 1
			z.append(l)
			l = 1
		elif j == '>':
			l = l + 1
			z.append(g)
			g = 1
	z.append(l)
	z.append(g)
	print(max(z))


o = int(input())
for h in range(0, o):
	s1 = input()
	if s1.count('=') == len(s1):
		print(1)
	else:
		s = ''
		for j in s1:
			if j != '=':
				s = s + j
		s = s + 'a'
		max = 1
		while len(s) != 1:
			i = s.find('<')
			j = s.find('>')
			if i == -1:
				i = len(s) - 1
			if j == -1:
				j = len(s) - 1
			if j > i:
				a = len(s[i:j])
				s = s[j:]
			else:
				a = len(s[j:i])
				s = s[i:]
			if a > max:
				max = a
		print(max + 1)


N = int(input())
z = 0
while z < N:
	z += 1
	st = input()
	i = 0
	maxi = 0
	s1 = s2 = 0
	while i < len(st):
		if st[i] is '<':
			s1 += 1
			s2 = 0
		if st[i] is '>':
			s2 += 1
			s1 = 0
		if max(s1, s2) > maxi:
			maxi = max(s1, s2)
		i += 1
	print(maxi + 1)


for _ in range(int(input())):
	srng = str(input())
	srng = srng.replace('=', '')
	c1 = 0
	c2 = 0
	mx = 0
	for a in srng:
		if a == '>':
			c1 += 1
			c2 = 0
			if c1 > mx:
				mx = c1
		elif a == '<':
			c2 += 1
			c1 = 0
			if c2 > mx:
				mx = c2
	print(mx + 1)


def count(_str):
	min = 1
	max = 1
	val = 1
	for i in range(len(_str)):
		if _str[i] == '<':
			val += 1
		elif _str[i] == '>':
			val -= 1
		if val > max:
			max = val
		elif val < min:
			min = val
	print('min={0} max={1}'.format(min, max))
	return max - min + 1

class CountMaxSegment:

	def __init__(self):
		self.maxCount = 0

	def calcMax(self, newMax):
		if newMax > self.maxCount:
			self.maxCount = newMax

	def count(self, _str):
		countLT = 0
		countGT = 0
		for i in range(len(_str)):
			if _str[i] == '<':
				self.calcMax(countGT)
				countGT = 0
				countLT += 1
			elif _str[i] == '>':
				self.calcMax(countLT)
				countLT = 0
				countGT += 1
		self.calcMax(countGT)
		self.calcMax(countLT)
		if self.maxCount == 0:
			return 1
		return self.maxCount + 1

def ni():
	s = input()
	while len(s) == 0:
		s = input()
	try:
		return int(s)
	except:
		return 0

def ns():
	s = input()
	while len(s) == 0:
		s = input()
	return s

def solve():
	T = ni()
	while T > 0:
		T -= 1
		counter = CountMaxSegment()
		print(counter.count(ns()))

def test():
	print(count('>'))
	print(count('<'))
	print(count('='))
	print(count('=<'))
	print(count('>='))
	print(count('>>>>=<<<'))
	signs = '>><>>>'
	print(count(signs))
	counter = CountMaxSegment()
	print(counter.count('='))
	print(counter.count('<'))
	print(counter.count(signs))
solve()


T = int(input())
for i in range(T):
	x = input().replace('=', '')
	max_right = 0
	max_left = 0
	curr_right = 0
	curr_left = 0
	right = False
	left = False
	for j in x:
		if j == '>':
			curr_right += 1
			if not right:
				right = True
			if left:
				left = False
				if max_left < curr_left:
					max_left = curr_left
				curr_left = 0
		elif j == '<':
			curr_left += 1
			if not left:
				left = True
			if right:
				right = False
				if max_right < curr_right:
					max_right = curr_right
				curr_right = 0
	if curr_left > max_left:
		max_left = curr_left
	if curr_right > max_right:
		max_right = curr_right
	print(max(max_right, max_left) + 1)


n = int(input())
for i in range(0, n):
	text = input()
	m = len(text)
	maxnum1 = num1 = 1
	for i in range(0, m):
		if text[i] == '<':
			num1 = num1 + 1
		elif text[i] == '>':
			if num1 > maxnum1:
				maxnum1 = num1
			num1 = 1
		if num1 > maxnum1:
			maxnum1 = num1
	maxnum2 = num2 = 1
	for i in range(0, m):
		if text[i] == '>':
			num2 = num2 + 1
		elif text[i] == '<':
			if num2 > maxnum2:
				maxnum2 = num2
			num2 = 1
		if num2 > maxnum2:
			maxnum2 = num2
	maxnum = max(maxnum1, maxnum2)
	print(maxnum)


for _ in range(int(input())):
	st = input().replace('=', '')
	if not len(st):
		print(1)
	else:
		cu = mx = 1
		for j in range(1, len(st)):
			if st[j] == st[j - 1]:
				cu += 1
			else:
				mx = max(mx, cu)
				cu = 1
		print(max(mx + 1, cu + 1))


t = int(input())
for i in range(t):
	line = input()
	line = line.replace('=', '')
	max_seq = 1
	curr_seq = 1
	try:
		pre = line[0]
	except:
		print(1)
		continue
	for curr in line[1:]:
		if curr == pre:
			curr_seq += 1
		else:
			max_seq = max(max_seq, curr_seq)
			curr_seq = 1
		pre = curr
	max_seq = max(max_seq, curr_seq)
	print(max_seq + 1)


import re
regex = '(<+|>+)'
for _ in range(int(input())):
	signStr = input().replace('=', '')
	s = re.findall(regex, signStr)
	counts = 0
	answers = 0
	for i in s:
		answers = len(i) if len(i) > answers else answers
	print('{0}'.format(answers + 1))


for j in range(int(input())):
	count = 0
	ns = ''
	str1 = ''
	str1 = input()
	count1 = 0
	max1 = 0
	max2 = 0
	for i in range(len(str1)):
		if str1[i] == '=':
			continue
		ns += str1[i]
	for k in range(len(ns)):
		if ns[k] == '<':
			count1 = 0
			count += 1
		elif ns[k] == '>':
			count = 0
			count1 += 1
		if max1 < count:
			max1 = count
		elif max1 < count1:
			max1 = count1
	print(max1 + 1)


import math
T = int(input())
while T:
	l = input()
	m_lt = 0
	m_gt = 0
	c_lt = 0
	c_gt = 0
	for c in l:
		if c == '<':
			if c_gt > m_gt:
				m_gt = c_gt
			c_gt = 0
			c_lt += 1
		elif c == '>':
			if c_lt > m_lt:
				m_lt = c_lt
			c_lt = 0
			c_gt += 1
	if c_gt > m_gt:
		m_gt = c_gt
	if c_lt > m_lt:
		m_lt = c_lt
	print(max(m_lt, m_gt) + 1)
	T -= 1


for _ in range(int(input())):
	s = input()
	ans = 0
	last = '?'
	curr = 0
	for ch in s:
		if ch == '=':
			continue
		if ch != last:
			ans = max(ans, curr)
			curr = 1
			last = ch
		else:
			curr += 1
	ans = max(ans, curr)
	print(ans + 1)


def solution():
	s = input()
	last_char = '-'
	P = 0
	temp = 0
	for i in range(0, len(s)):
		if s[i] == '=':
			continue
		if last_char == s[i]:
			temp = temp + 1
		else:
			P = max(temp, P)
			temp = 1
		last_char = s[i]
	P = max(temp, P)
	print(P + 1)
T = int(input())
while T > 0:
	T = T - 1
	solution()


test = int(input())
while test:
	st = input()
	mx = freq = 0
	st += '0'
	l = len(st)
	p = '='
	for i in range(0, l - 1):
		if st[i] == '=':
			continue
		elif (st[i] == '<' or st[i] == '>') and freq == 0:
			freq += 1
			p = st[i]
		elif p == st[i]:
			freq += 1
		else:
			if freq > mx:
				mx = freq
			freq = 1
			p = st[i]
	if freq > mx:
		mx = freq
	print(mx + 1)
	test -= 1


r = int(input())
for z in range(r):
	s = input()
	s = s.replace('=', '')
	l = list(s)
	final = 0
	ans = 0
	if len(l) == 0:
		print(1)
	else:
		for i in range(1, len(l)):
			if l[i] == l[i - 1]:
				ans = ans + 1
			else:
				if final < ans:
					final = ans
				ans = 0
		if final < ans:
			final = ans
		print(final + 2)


for _ in range(int(input())):
	s = input()
	p = '='
	c = 1
	ans = 1
	for i in range(len(s)):
		if s[i] == '=':
			continue
		if s[i] == p:
			c += 1
		else:
			c = 1
		if c + 1 > ans:
			ans = c + 1
		p = s[i]
	print(ans)


t = int(input().strip())
for _ in range(t):
	numList = []
	(less, great, maxVal) = (0, 0, 0)
	sign = list(input().strip())
	for iter in sign:
		if iter == '<':
			great = 0
			less = less + 1
			if less > maxVal:
				maxVal = less
		elif iter == '>':
			less = 0
			great = great + 1
			if great > maxVal:
				maxVal = great
	print(maxVal + 1)