Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So instead he's going to make a quiz for you about making permutations of $n$ distinct integers between $1$ and $n$, inclusive, to test his code with your output.

The quiz is as follows.

Gildong provides a string of length $n-1$, consisting of characters '<' and '>' only. The $i$-th (1-indexed) character is the comparison result between the $i$-th element and the $i+1$-st element of the sequence. If the $i$-th character of the string is '<', then the $i$-th element of the sequence is less than the $i+1$-st element. If the $i$-th character of the string is '>', then the $i$-th element of the sequence is greater than the $i+1$-st element.

He wants you to find two possible sequences (not necessarily distinct) consisting of $n$ distinct integers between $1$ and $n$, inclusive, each satisfying the comparison results, where the length of the LIS of the first sequence is minimum possible, and the length of the LIS of the second sequence is maximum possible.


-----Input-----

Each test contains one or more test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$).

Each test case contains exactly one line, consisting of an integer and a string consisting of characters '<' and '>' only. The integer is $n$ ($2 \le n \le 2 \cdot 10^5$), the length of the permutation you need to find. The string is the comparison results explained in the description. The length of the string is $n-1$.

It is guaranteed that the sum of all $n$ in all test cases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each test case, print two lines with $n$ integers each. The first line is the sequence with the minimum length of the LIS, and the second line is the sequence with the maximum length of the LIS. If there are multiple answers, print any one of them. Each sequence should contain all integers between $1$ and $n$, inclusive, and should satisfy the comparison results.

It can be shown that at least one answer always exists.


-----Example-----
Input
3
3 <<
7 >><>><
5 >>><

Output
1 2 3
1 2 3
5 4 3 7 2 1 6
4 3 1 7 5 2 6
4 3 2 1 5
5 4 2 1 3



-----Note-----

In the first case, $1$ $2$ $3$ is the only possible answer.

In the second case, the shortest length of the LIS is $2$, and the longest length of the LIS is $3$. In the example of the maximum LIS sequence, $4$ '$3$' $1$ $7$ '$5$' $2$ '$6$' can be one of the possible LIS.

Difficulty: MEDIUM_HARD
Tags: Greedy algorithms

Graph algorithms

Amortized analysis

Constructive algorithms
Skill types: Amortized analysis

Greedy algorithms

Starter code:

Solutions:
t = int(input())
for _ in range(t):
	(n, s) = map(str, input().split())
	small = [0 for i in range(int(n))]
	big = [0 for i in range(int(n))]
	n = int(n)
	ma = n
	p = s
	s = ' ' + s
	for i in range(n - 1, -1, -1):
		if s[i] == '<' or i == 0:
			big[i] = ma
			ma -= 1
			j = i + 1
			while j < n:
				if not big[j]:
					big[j] = ma
					ma -= 1
					j += 1
				else:
					break
	s1 = ''
	for i in range(n - 1 - 1, -1, -1):
		if s[i] == '<':
			s1 = s1 + '>'
		else:
			s1 += '<'
	small = big
	big = [0 for i in range(n)]
	ma = n
	big[-1] = 1
	s = p + ' '
	for i in range(0, n):
		if s[i] == '>' or i == n - 1:
			j = i - 1
			big[i] = ma
			ma -= 1
			while j >= 0:
				if not big[j]:
					big[j] = ma
					ma -= 1
					j -= 1
				else:
					break
	c = 0
	s = p
	for i in s:
		if i == '>':
			c += 1
	if c == n - 1:
		for i in range(1, n + 1):
			big[i - 1] = n - i + 1
		small = big
	c = 0
	for i in s:
		if i == '<':
			c += 1
	if c == n - 1:
		for i in range(n - 1, -1, -1):
			big[i] = i + 1
		small = big
	print(*big)
	print(*small)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, s) = input().split()
		n = int(n)
		ans = []
		(p, i) = (n, 0)
		while i < n - 1:
			if s[i] == '>':
				ans.append(p)
				p -= 1
			else:
				j = i
				a = [p]
				p -= 1
				while j < n - 1 and s[j] == '<':
					j += 1
					a.append(p)
					p -= 1
				while a:
					ans.append(a.pop())
				i = j
			i += 1
		if len(ans) != n:
			ans.append(p)
		ans1 = []
		(p, i) = (n, n - 2)
		while i > -1:
			if s[i] == '<':
				ans1.append(p)
				p -= 1
			else:
				j = i
				a = [p]
				p -= 1
				while j > -1 and s[j] == '>':
					j -= 1
					a.append(p)
					p -= 1
				while a:
					ans1.append(a.pop())
				i = j
			i -= 1
		if len(ans1) != n:
			ans1.append(p)
		ans1.reverse()
		print(*ans)
		print(*ans1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = int(input())
for i in range(a):
	(n, s) = map(str, input().split())
	n = int(n)
	ans = []
	flag = 1
	glag = 1
	for i in range(len(s)):
		if i == 0:
			if s[i] == '<':
				ans.append(-flag * n)
				ans.append(ans[-1] + 1)
			else:
				ans.append(-glag * n * n)
				ans.append(ans[-1] - 1)
		elif s[i] == s[i - 1] == '<':
			ans.append(ans[-1] + 1)
		elif s[i] == s[i - 1] == '>':
			ans.append(ans[-1] - 1)
		elif s[i] == '>':
			flag += 1
			ans.append(-glag * n * n)
		else:
			glag += 1
			ans.append(-flag * n)
	t = abs(min(ans))
	for i in range(len(ans)):
		ans[i] += t + 1
	big = []
	for i in range(len(ans)):
		big.append([ans[i], i])
	big.sort()
	gam = [0 for i in range(n)]
	for i in range(len(big)):
		gam[big[i][1]] = i + 1
	print(*gam)
	ans = []
	if s[0] == '>':
		ans.append(-1)
		ans.append(-2)
	else:
		ans.append(1)
		ans.append(2)
	mini = -3
	maxa = 3
	for i in range(1, len(s)):
		if s[i] == '>':
			ans.append(mini)
			mini -= 1
		else:
			ans.append(maxa)
			maxa += 1
	t = abs(min(ans))
	for i in range(len(ans)):
		ans[i] += t + 1
	big = []
	for i in range(len(ans)):
		big.append([ans[i], i])
	big.sort()
	gam = [0 for i in range(n)]
	for i in range(len(big)):
		gam[big[i][1]] = i + 1
	print(*gam)


for tc in range(int(input())):
	(n, s) = input().split(' ')
	n = int(n)
	inc = [-1] * n
	dec = [-1] * n
	cnti = 1
	for i in range(len(s)):
		if s[i] == '<':
			inc[i] = cnti
			cnti += 1
	lcnt = n
	for i in range(n):
		if inc[i] == -1:
			inc[i] = lcnt
			lcnt -= 1
	cntl = 1
	i = n - 2
	while i >= 0:
		if s[i] == '<':
			si = i
			ei = i
			while si >= 0 and s[si] != '>':
				si -= 1
			for j in range(si + 1, ei + 1):
				dec[j] = cntl
				cntl += 1
			i = si
		else:
			i -= 1
	lcnt = n
	for i in range(n):
		if dec[i] == -1:
			dec[i] = lcnt
			lcnt -= 1
	print(*dec)
	print(*inc)


line = input()
q = int(line)
for _ in range(q):
	line = input()
	(n, s) = [x for x in line.split()]
	n = int(n)
	minseq = [n]
	potential = 0
	maxseq = [1]
	minel = 1
	maxel = 1
	for x in s:
		if x == '<':
			maxseq.append(maxel + 1)
			maxel += 1
			potential += 1
		elif x == '>':
			if potential == 0:
				minseq.append(minseq[-1] - 1)
			else:
				minseq[-1] -= potential
				tmp = minseq[-1]
				for _ in range(potential):
					minseq.append(minseq[-1] + 1)
				potential = 0
				minseq.append(tmp - 1)
			maxseq.append(minel - 1)
			minel -= 1
	if potential != 0:
		minseq[-1] -= potential
		for _ in range(potential):
			minseq.append(minseq[-1] + 1)
	for x in minseq:
		print(x, end=' ')
	print('')
	for x in maxseq:
		print(x - minel + 1, end=' ')
	print('')


import sys
t = int(input())
g = sys.stdin.readlines()
for i in range(t):
	(n, s) = g[i].split()
	n = int(n)
	n -= 1
	j = 0
	big = []
	small = []
	while j < n:
		count = 1
		while j < n and s[j] == '>':
			count += 1
			j += 1
		big.append(count)
		j += 1
	if sum(big) != n + 1:
		big.append(1)
	j = 0
	while j < n:
		count = 1
		while j < n and s[j] == '<':
			count += 1
			j += 1
		small.append(count)
		j += 1
	if sum(small) != n + 1:
		small.append(1)
	count = n + 2
	for i in small:
		count -= i
		for j in range(count, count + i, 1):
			print(j, end=' ')
	count = 0
	print()
	for i in big:
		count += i
		for j in range(count, count - i, -1):
			print(j, end=' ')
	print()


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(n, comp) = stdin.readline().split()
	n = int(n)
	clist = []
	(last, cnt) = (None, 0)
	lt = 0
	for i in range(len(comp)):
		if comp[i] == '<':
			lt += 1
		if last:
			if comp[i] != last:
				clist.append((last, cnt))
				cnt = 0
		last = comp[i]
		cnt += 1
	else:
		clist.append((last, cnt))
	(i, j) = (0, 0)
	(sht, lng) = ([], [])
	for (c, v) in clist:
		if c == '<':
			for x in range(i + 1, i + v + 1):
				lng.append(str(x))
			for x in range(lt - i - v + 1, lt - i + 1):
				sht.append(str(x))
			i += v
		else:
			for _ in range(v):
				s = str(n - j)
				sht.append(s)
				lng.append(s)
				j += 1
	else:
		s = str(n - j)
		sht.append(s)
		lng.append(s)
	stdout.write('{}\n{}\n'.format(' '.join(sht), ' '.join(lng)))


for _ in range(int(input())):
	(n, s) = map(str, input().split())
	n = int(n)
	mn = [0] * n
	mx = [0] * n
	for i in range(n):
		mn[i] = n - i
		mx[i] = i + 1
	j = 0
	i = 0
	while i < n - 1:
		while j < n - 1 and s[i] == s[j]:
			j += 1
		if s[i] == '<':
			mn[i:j + 1] = mn[i:j + 1][::-1]
		else:
			mx[i:j + 1] = mx[i:j + 1][::-1]
		i = j
	print(*mn)
	print(*mx)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import deque

def check(string):
	if string == '<':
		return 1
	else:
		return 0
for j in range(int(input())):
	vals = [k for k in input().split()]
	vals = [k for k in vals[1:][0]]
	n = len(vals)
	chain = [1]
	par = [check(vals[0])]
	for s in range(1, n):
		if check(vals[s]) == par[-1]:
			chain[-1] += 1
		else:
			par.append(check(vals[s]))
			chain.append(1)
	shortest = [0 for s in range(n + 1)]
	longest = [0 for s in range(n + 1)]
	pref = [chain[0]]
	pos = []
	setty = set([])
	for s in range(1, len(chain)):
		pref.append(pref[-1] + chain[s])
	unused = list(range(1, n + 2))
	nxt = 0
	unused = list(range(1, n + 2))
	for s in range(len(pref)):
		if par[s] == 1:
			if s == 0:
				for i in range(pref[s], -1, -1):
					shortest[i] = unused.pop()
			else:
				for i in range(pref[s], pref[s - 1], -1):
					shortest[i] = unused.pop()
	for s in range(n + 1):
		if shortest[s] == 0:
			shortest[s] = unused.pop()
	unused = deque(list(range(1, n + 2)))
	for s in range(len(pref)):
		if par[s] == 1:
			if s == 0:
				for i in range(pref[s] + 1):
					longest[i] = unused.popleft()
			else:
				for i in range(pref[s - 1] + 1, pref[s] + 1):
					longest[i] = unused.popleft()
	v0 = n + 1 - max(longest)
	unused = list(range(1, v0 + 1))
	for s in range(n + 1):
		if longest[s] != 0:
			longest[s] += v0
	for s in range(n + 1):
		if longest[s] == 0:
			longest[s] = unused.pop()
	print(*shortest)
	print(*longest)


t = int(input())
for _ in range(t):
	(n, s) = input().split()
	n = int(n)
	s = list(s)
	ans1 = [n - i for i in range(n)]
	i = 0
	while i < n - 1:
		j = i
		while j < n - 1 and s[j] == '<':
			j += 1
		for k in range((j - i) // 2 + 1):
			(ans1[i + k], ans1[j - k]) = (ans1[j - k], ans1[i + k])
		i = j + 1
	print(' '.join([str(item) for item in ans1]))
	ans2 = [i + 1 for i in range(n)]
	i = 0
	while i < n - 1:
		j = i
		while j < n - 1 and s[j] == '>':
			j += 1
		for k in range((j - i) // 2 + 1):
			(ans2[i + k], ans2[j - k]) = (ans2[j - k], ans2[i + k])
		i = j + 1
	print(' '.join([str(item) for item in ans2]))


from sys import stdin
input = stdin.readline
q = int(input())

def maxmozodprawej(s, n):
	res = []
	ind = 0
	maksi = n
	while True:
		if ind >= n - 1:
			break
		if s[ind] == 1:
			res.append(maksi)
			maksi -= 1
			ind += 1
		if ind >= n - 1:
			break
		if s[ind] == 0:
			i = 0
			while i + ind < n - 1 and s[i + ind] == 0:
				i += 1
			for j in range(i + 1):
				res.append(maksi - i + j)
			maksi -= i + 1
			ind += i + 1
	if len(res) == n:
		return res
	else:
		return res + [1]
for _ in range(q):
	l = list(input().split())
	n = int(l[0])
	s = [1 if l[1][i] == '>' else 0 for i in range(n - 1)]
	ss = [(s[i] + 1) % 2 for i in range(n - 1)]
	najm = maxmozodprawej(s, n)
	print(*najm)
	najw = maxmozodprawej(ss, n)
	for i in range(n):
		if i < n - 1:
			print(n + 1 - najw[i], end=' ')
		else:
			print(n + 1 - najw[i])


def max_nvp(rel):
	n = len(rel) + 1
	seq = [0] * n
	(lower, higher) = (1, n)
	for i in range(len(rel)):
		if '<' == rel[i]:
			seq[i] = lower
			lower += 1
		elif '>' == rel[i]:
			seq[i] = higher
			higher -= 1
	seq[-1] = lower
	return ' '.join(map(str, seq))

def min_nvp(rel):

	def ge(i, seq, higher):
		seq[i] = higher
		higher -= 1
		i -= 1
		while i >= 0 and rel[i] == '<':
			seq[i] = higher
			higher -= 1
			i -= 1
		return higher

	def le(i, seq, higher):
		return higher
	n = len(rel) + 1
	seq = [0] * n
	higher = n
	for (i, cur_rel) in enumerate(rel):
		if '<' == cur_rel:
			higher = le(i, seq, higher)
		elif '>' == cur_rel:
			higher = ge(i, seq, higher)
	ge(len(rel), seq, higher)
	return ' '.join(map(str, seq))
t = int(input())
for testcase_i in range(t):
	(_, rel) = input().split()
	print(min_nvp(rel))
	print(max_nvp(rel))


def print_arr(arr):
	for a in arr:
		print(a, end=' ')
	print()

def solve_max(n, s):
	div = s.count('>') + 1
	(l, r) = (div - 1, div + 1)
	ans = [div]
	for c in s:
		if c == '<':
			ans.append(r)
			r += 1
		else:
			ans.append(l)
			l -= 1
	print_arr(ans)

def solve_min(n, s):
	div = s.count('>') + 1
	ans = [div]
	div -= 1
	i = 0
	while i < len(s):
		if s[i] == '>':
			ans.append(div)
			div -= 1
			i += 1
		else:
			j = i
			while j < len(s) and s[i] == s[j]:
				j += 1
			for it in range(n - j + i + 1, n + 1):
				ans.append(it)
			n -= j - i
			i = j
	print_arr(ans)

def main():
	tc = int(input())
	for _ in range(tc):
		(n, s) = input().split()
		n = int(n)
		solve_min(n, s)
		solve_max(n, s)
main()


def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(n, s) = input().split()
		n = int(n)
		s = s + '$'
		seq = []
		prev = None
		l = 0
		for c in s:
			if c != prev:
				if l > 0:
					seq.append([prev == '<', l])
				l = 1
			else:
				l += 1
			prev = c
		seq[0][1] += 1
		minLIS = []
		curr = n
		startend = []
		for i in range(len(seq)):
			l = seq[i][1]
			if seq[i][0]:
				if i == 0:
					start = n - l + 1
					end = n
					curr = start - 1
				else:
					start = startend[i - 1][0] + 1
					end = start + l - 1
			elif i + 1 < len(seq):
				start = curr - seq[i + 1][1]
				end = start - l + 1
				curr = end - 1
			else:
				start = l
				end = 1
			startend.append([start, end])
		for (start, end) in startend:
			if start <= end:
				for v in range(start, end + 1):
					minLIS.append(v)
			else:
				for v in range(start, end - 1, -1):
					minLIS.append(v)
		maxLIS = []
		startend = []
		curr = 1
		for i in range(len(seq)):
			l = seq[i][1]
			if seq[i][0]:
				if i + 1 < len(seq):
					start = curr + seq[i + 1][1]
				else:
					start = curr
				end = start + l - 1
				curr = end + 1
			else:
				if i - 1 >= 0:
					start = startend[i - 1][0] - 1
				else:
					start = l
					curr = start + 1
				end = start - l + 1
			startend.append([start, end])
		for (start, end) in startend:
			if start <= end:
				for v in range(start, end + 1):
					maxLIS.append(v)
			else:
				for v in range(start, end - 1, -1):
					maxLIS.append(v)
		allans.append(minLIS)
		allans.append(maxLIS)
	multiLineArrayOfArraysPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(*args):
	assert len(args) >= 2, 'makeArr args should be (default value, dimension 1, dimension 2,...'
	if len(args) == 2:
		return [args[0] for _ in range(args[1])]
	else:
		return [makeArr(args[0], *args[2:]) for _ in range(args[1])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


import itertools

def countstrs(s):
	return [(k, len(list(g))) for (k, g) in itertools.groupby(s)]

def countstrs_withIndex(s):
	d = countstrs(s)
	r = []
	ind = 0
	for i in range(len(d)):
		r.append((d[i][0], d[i][1], ind))
		ind += d[i][1]
	return r
q = int(input())
for _ in range(q):
	inp = input().split()
	n = int(inp[0])
	s = inp[1]
	dat = [0] * n
	(num, last) = (n, 0)
	for i in range(n):
		if i == n - 1 or s[i] == '>':
			for j in range(i, last - 1, -1):
				dat[j] = str(num)
				num -= 1
			last = i + 1
	print(' '.join(dat))
	dat = [0] * n
	(num, last) = (1, 0)
	for i in range(n):
		if i == n - 1 or s[i] == '<':
			for j in range(i, last - 1, -1):
				dat[j] = str(num)
				num += 1
			last = i + 1
	print(' '.join(dat))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, s) = input().split()
	n = int(n)
	(inc, dec) = ([[0]], [[0]])
	for i in range(n - 1):
		if s[i] == '>':
			inc.append([])
		else:
			dec.append([])
		inc[-1].append(i + 1)
		dec[-1].append(i + 1)
	ans1_last = n + 1
	ans2_last = 0
	ans1 = [0] * n
	ans2 = [0] * n
	for l in inc:
		ans1_last -= len(l)
		for i in range(len(l)):
			ans1[l[i]] = ans1_last + i
	for l in dec:
		ans2_last += len(l)
		for i in range(len(l)):
			ans2[l[i]] = ans2_last - i
	print(*ans1)
	print(*ans2)


import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for ik in range(int(input())):
	(n, s) = map(str, input().split())
	n = int(n)
	smallest = [0] * n
	t = 1
	c = s.count('<') + 1
	cou = n - c
	for i in range(n - 1):
		if s[i] == '>':
			smallest[t] = cou
			cou -= 1
		t += 1
	cou = s.count('<') + 1
	rt = [i + 1 + n - c for i in range(cou)]
	rt = rt[::-1]
	t = 0
	ind = 0
	i = 0
	s = '<' + s
	while i < n:
		if s[i] == '<':
			de = i
			while s[de] == '<':
				ind += 1
				de += 1
				if de == n:
					break
			rty = ind
			ind += -1
			for j in range(i, de):
				smallest[j] = rt[ind]
				ind -= 1
			ind = rty
			i = de
		i += 1
	largest = [0] * n
	s = s + '<'
	w = []
	for i in range(len(s)):
		if s[i] == '<':
			w.append(i)
	cd = n
	for j in range(len(w) - 2, -1, -1):
		for k in range(w[j], w[j + 1]):
			largest[k] = cd
			cd -= 1
	print(*smallest, sep=' ')
	print(*largest, sep=' ')


import sys
inp = sys.stdin.readline
input = lambda : inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	T = iin()
	while T:
		T -= 1
		(n, s) = input().split()
		n = int(n)
		(ansmx, ansmn) = ([0] * n, [0] * n)
		ch = n
		i = 0
		while i < n - 1:
			if s[i] == '>':
				ansmn[i] = ch
				ch -= 1
			else:
				j = i + 1
				while j < n - 1:
					if s[j] == '>':
						break
					j += 1
				for k in range(j, i, -1):
					ansmn[k] = ch
					ch -= 1
				ansmn[i] = ch
				ch -= 1
				i = j
			i += 1
		else:
			if ansmn[n - 1] == 0:
				ansmn[n - 1] = ch
		s = list(s)[::-1]
		for i in range(n - 1):
			if s[i] == '>':
				s[i] = '<'
			else:
				s[i] = '>'
		ch = n
		i = 0
		while i < n - 1:
			if s[i] == '>':
				ansmx[i] = ch
				ch -= 1
			else:
				j = i + 1
				while j < n - 1:
					if s[j] == '>':
						break
					j += 1
				for k in range(j, i, -1):
					ansmx[k] = ch
					ch -= 1
				ansmx[i] = ch
				ch -= 1
				i = j
			i += 1
		else:
			if ansmx[n - 1] == 0:
				ansmx[n - 1] = ch
		ansmx = ansmx[::-1]
		print(*ansmn)
		print(*ansmx)
main()


t = int(input())
for _ in range(t):
	(n, s) = input().split()
	s = s + '<'
	n = int(n)
	ans1 = [-1 for i in range(n)]
	time = 0
	now1 = n
	key = 0
	for i in range(n):
		if i == n - 1:
			for j in range(n - 1, key - 1, -1):
				ans1[j] = now1
				now1 -= 1
			break
		if time == 0 and s[i] == '>':
			ans1[i] = now1
			now1 -= 1
			key = i + 1
		elif time == 0 and s[i] == '<':
			time = 1
			key = i
		elif time == 1 and s[i] == '<':
			pass
		elif time == 1 and s[i] == '>':
			time = 0
			for j in range(i, key - 1, -1):
				ans1[j] = now1
				now1 -= 1
			key = i + 1
	print(*ans1)
	s = '>' + s[:-1]
	ans2 = [-1 for i in range(n)]
	time = 0
	now2 = n
	key = n - 1
	for i in range(n - 1, -1, -1):
		if i == 0:
			for j in range(key + 1):
				ans2[j] = now2
				now2 -= 1
			break
		if time == 0 and s[i] == '<':
			ans2[i] = now2
			now2 -= 1
			key = i - 1
		elif time == 0 and s[i] == '>':
			time = 1
		elif time == 1 and s[i] == '>':
			pass
		elif time == 1 and s[i] == '<':
			time = 0
			for j in range(i, key + 1):
				ans2[j] = now2
				now2 -= 1
			key = i - 1
	print(*ans2)


def reverse(arr, i, j):
	while i < j:
		temp = arr[i]
		arr[i] = arr[j]
		arr[j] = temp
		i += 1
		j -= 1
	return None

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(n, s) = input().split()
		n = int(n)
		minLIS = list(range(n, 0, -1))
		i = 0
		while i < n - 1:
			j = i
			while j < n - 1 and s[j] == '<':
				j += 1
			reverse(minLIS, i, j)
			i = j + 1
		allans.append(minLIS)
		maxLIS = list(range(1, n + 1))
		i = 0
		while i < n - 1:
			j = i
			while j < n - 1 and s[j] == '>':
				j += 1
			reverse(maxLIS, i, j)
			i = j + 1
		allans.append(maxLIS)
	multiLineArrayOfArraysPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(*args):
	assert len(args) >= 2, 'makeArr args should be (default value, dimension 1, dimension 2,...'
	if len(args) == 2:
		return [args[0] for _ in range(args[1])]
	else:
		return [makeArr(args[0], *args[2:]) for _ in range(args[1])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


for nt in range(int(input())):
	(n, s) = input().split()
	n = int(n)
	a = [i for i in range(n, 0, -1)]
	i = 0
	c = []
	while i < n:
		if i < n - 1 and s[i] == '<':
			start = i
			while start < n - 1 and s[start] == '<':
				start += 1
			c.append((i, start))
			i = start
		else:
			i += 1
	(j, i) = (0, 0)
	ans = []
	while i < n:
		if j < len(c) and c[j][0] == i:
			for k in range(c[j][1], c[j][0] - 1, -1):
				ans.append(a[k])
			i = c[j][1] + 1
			j += 1
		else:
			ans.append(a[i])
			i += 1
	print(*ans)
	a = [i for i in range(1, n + 1)]
	i = 0
	c = []
	while i < n:
		if i < n - 1 and s[i] == '>':
			start = i
			while start < n - 1 and s[start] == '>':
				start += 1
			c.append((i, start))
			i = start
		else:
			i += 1
	(j, i) = (0, 0)
	ans = []
	while i < n:
		if j < len(c) and c[j][0] == i:
			for k in range(c[j][1], c[j][0] - 1, -1):
				ans.append(a[k])
			i = c[j][1] + 1
			j += 1
		else:
			ans.append(a[i])
			i += 1
	print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, s) = input().rstrip().split()
	n = int(n)
	last = 0
	num = n
	ans1 = [0] * n
	for i in range(n):
		if i == n - 1 or s[i] == '>':
			for j in range(last, i + 1)[::-1]:
				ans1[j] = num
				num -= 1
			last = i + 1
	print(*ans1)
	num = 1
	last = 0
	ans2 = [0] * n
	for i in range(n):
		if i == n - 1 or s[i] == '<':
			for j in range(last, i + 1)[::-1]:
				ans2[j] = num
				num += 1
			last = i + 1
	print(*ans2)


for _ in range(int(input())):
	(n, s) = input().split()
	n = int(n)
	tmp = []
	ans = []
	for (i, x) in enumerate(s):
		tmp.append(n - i)
		if x == '>':
			ans += tmp[::-1]
			tmp = []
	tmp.append(1)
	ans += tmp[::-1]
	print(' '.join([str(x) for x in ans]))
	i = 1
	j = n
	ans = []
	for x in s:
		if x == '>':
			ans.append(j)
			j -= 1
		else:
			ans.append(i)
			i += 1
	ans.append(i)
	print(' '.join([str(x) for x in ans]))


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, s) = [x for x in input().split()]
		n = int(n) - 1
		min_lcs = list(range(n + 1, 0, -1))
		max_lcs = list(range(1, n + 2))
		i = 0
		j = 0
		min_flips = []
		while i < n:
			if s[i] == '>':
				i += 1
			else:
				j = i
				while j + 1 < n and s[j + 1] == '<':
					j += 1
				min_flips.append([i, j])
				i = j + 1
		i = 0
		j = 0
		max_flips = []
		while i < n:
			if s[i] == '<':
				i += 1
			else:
				j = i
				while j + 1 < n and s[j + 1] == '>':
					j += 1
				max_flips.append([i, j])
				i = j + 1
		for p in min_flips:
			(l, r) = p
			r += 1
			t = min_lcs[r]
			for i in range(l, r + 1):
				min_lcs[i] = t
				t += 1
		for p in max_flips:
			(l, r) = p
			r += 1
			t = max_lcs[r]
			for i in range(l, r + 1):
				max_lcs[i] = t
				t -= 1
		print(*min_lcs)
		print(*max_lcs)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for test_case in range(t):
	(n, pattern) = input().split()
	n = int(n)
	ans = [0] * n
	(num, last) = (n, 0)
	for i in range(n):
		if i == n - 1 or pattern[i] == '>':
			for j in range(i, last - 1, -1):
				ans[j] = num
				num -= 1
			last = i + 1
	print(' '.join((str(k) for k in ans)))
	(num, last) = (1, 0)
	for i in range(n):
		if i == n - 1 or pattern[i] == '<':
			for j in range(i, last - 1, -1):
				ans[j] = num
				num += 1
			last = i + 1
	print(' '.join((str(k) for k in ans)))


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, s) = input().split()
	n = int(n)
	l = [0] * n
	s1 = [0] * n
	l1 = []
	c = 0
	low = 1
	for j in range(n - 1):
		if s[j] == '<':
			c += 1
			l[j] = low
			low += 1
		else:
			if c != 0:
				l1.append(c)
			c = 0
	if c != 0:
		l1.append(c)
	high = n
	for j in range(n):
		if l[j] == 0:
			l[j] = high
			high -= 1
	start = 0
	low = 0
	for j in range(n - 2, -1, -1):
		if s[j] == '<':
			if start == 0:
				start = l1.pop()
				prev = start
			s1[j] = low + start
			start -= 1
			if start == 0:
				low += prev
	high = n
	for j in range(n):
		if s1[j] == 0:
			s1[j] = high
			high -= 1
	print(*s1)
	print(*l)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(nt, ss) = input().split()
		n = int(nt)
		tt = []
		for s in ss[::-1]:
			if s == '>':
				tt.append('<')
			else:
				tt.append('>')
		ls = longest_lis(''.join(tt))
		print(' '.join(map(str, ls[::-1])))
		ls = longest_lis(ss)
		print(' '.join(map(str, ls)))

	def longest_lis(ss):
		dl = [0]
		for s in ss[::-1]:
			if s == '>':
				dl.append(dl[-1] + 1)
			else:
				dl.append(0)
		ls = []
		mx = 0
		curr = 0
		dp = 0
		for d in dl[::-1]:
			if dp == 0:
				mx = mx + 1
				curr = mx
			ls.append(curr + d)
			mx = max(curr + d, mx)
			dp = d
		return ls
	q = int(input())
	for _ in range(q):
		solve()
main()


for _ in range(int(input())):
	(n, s) = input().split()
	n = int(n)
	mn = [0] * n
	mx = [0] * n
	s_i = [0] * n
	if s[-1] == '>':
		s_i[-2] = 1
	else:
		s_i[-2] = -1
	for i in range(len(s) - 2, -1, -1):
		if s[i] == '>':
			if i + 1 < len(s) and s_i[i + 1] > 0:
				s_i[i] = s_i[i + 1] + 1
			else:
				s_i[i] = 1
		elif i + 1 < len(s) and s_i[i + 1] < 0:
			s_i[i] = s_i[i + 1] - 1
		else:
			s_i[i] = -1
	mxm = n
	i = 0
	while i < n:
		if s_i[i] > 0:
			ei = i + s_i[i] + 1
			if ei == n:
				while i < n:
					mx[i] = mxm
					i += 1
					mxm -= 1
			else:
				mx[ei] = mxm
				mxm -= 1
				while i < ei:
					mx[i] = mxm
					i += 1
					mxm -= 1
				i += 1
		else:
			ei = i + abs(s_i[i])
			j = ei
			while j >= i:
				mx[j] = mxm
				mxm -= 1
				j -= 1
			i = ei + 1
	i = 0
	mnm = 1
	while i < n:
		if s_i[i] > 0:
			ei = i + abs(s_i[i])
			j = ei
			while j >= i:
				mn[j] = mnm
				mnm += 1
				j -= 1
			i = ei + 1
		else:
			ei = i + abs(s_i[i])
			while i <= ei:
				mn[i] = mnm
				mnm += 1
				i += 1
	i = 0
	while i < len(s):
		if s[i] == '>' and mx[i] < mx[i + 1]:
			(mx[i], mx[i + 1]) = (mx[i + 1], mx[i])
			i -= 1
			continue
		elif s[i] == '<' and mx[i] > mx[i + 1]:
			(mx[i], mx[i + 1]) = (mx[i + 1], mx[i])
			i -= 1
			continue
		i += 1
	print(*mx)
	i = 0
	while i < len(s):
		if s[i] == '>' and mn[i] < mn[i + 1]:
			(mn[i], mn[i + 1]) = (mn[i + 1], mn[i])
			i -= 1
			continue
		elif s[i] == '<' and mn[i] > mn[i + 1]:
			(mn[i], mn[i + 1]) = (mn[i + 1], mn[i])
			i -= 1
			continue
		i += 1
	print(*mn)


cases = int(input())
for _ in range(cases):
	(l, s) = input().split()
	l = int(l)
	seq = []
	i = 0
	prev = l
	start_i = 0
	while i <= len(s):
		start_i = i
		while i < len(s) and s[i] == '<':
			i += 1
		for n in range(prev - (i - start_i), prev + 1):
			seq.append(n)
		prev -= i - start_i + 1
		i += 1
	print(' '.join([str(x) for x in seq]))
	hi = 1
	for c in s:
		if c == '>':
			hi += 1
	seq = [hi]
	lo = hi - 1
	for c in s:
		if c == '<':
			hi += 1
			seq.append(hi)
		else:
			seq.append(lo)
			lo -= 1
	print(' '.join([str(x) for x in seq]))


def makeRepeat(s):
	repeat = [[s[0], 0]]
	for ch in s:
		if ch == repeat[-1][0]:
			repeat[-1][1] += 1
		else:
			repeat.append([ch, 1])
	return repeat

def solve(N, S):
	assert len(S) == N - 1
	curr = 0
	repeat = makeRepeat(S)
	longest = list(range(1, N + 1))
	shortest = list(reversed(range(1, N + 1)))
	for (ch, count) in repeat:
		if ch == '>':
			longest[curr:curr + count + 1] = reversed(longest[curr:curr + count + 1])
		else:
			assert ch == '<'
			shortest[curr:curr + count + 1] = reversed(shortest[curr:curr + count + 1])
		curr += count
	return ' '.join(map(str, shortest)) + '\n' + ' '.join(map(str, longest))
(T,) = map(int, input().split())
for t in range(T):
	(N, S) = input().split()
	N = int(N)
	ans = solve(N, S)
	print(ans)


def getInput():
	line = input().split()
	return (int(line[0]), line[1])

def sLIS(n, s):
	ans = list(range(n, 0, -1))
	rev = []
	i = 0
	while i < n - 1:
		if s[i] == '<':
			j = i + 1
			while j < n - 1 and s[j] == '<':
				j += 1
			rev.append((i, j))
			i = j + 1
		else:
			i += 1
	for r in rev:
		(i, j) = r
		while i <= j:
			(ans[i], ans[j]) = (ans[j], ans[i])
			i += 1
			j -= 1
	return ans

def lLIS(n, s):
	ans = list(range(1, n + 1))
	rev = []
	i = 0
	while i < n - 1:
		if s[i] == '>':
			j = i + 1
			while j < n - 1 and s[j] == '>':
				j += 1
			rev.append((i, j))
			i = j + 1
		else:
			i += 1
	for r in rev:
		(i, j) = r
		while i <= j:
			(ans[i], ans[j]) = (ans[j], ans[i])
			i += 1
			j -= 1
	return ans
for _ in range(int(input())):
	(n, s) = getInput()
	print(*sLIS(n, s))
	print(*lLIS(n, s))


from collections import deque
for _ in range(int(input())):
	(n, s) = [i for i in input().split()]
	qu = deque([i for i in s])
	mn = list(range(1, int(n) + 1))
	mx = list(range(1, int(n) + 1))[::-1]
	arr = []
	cnt = 0
	sym = None
	while qu:
		ele = qu.popleft()
		if sym == ele[0]:
			arr[-1][1] += 1
		else:
			arr.append([ele[0], 1])
			sym = ele[0]
	ind = 0
	for i in arr:
		if i[0] == '<':
			mx[ind:ind + i[1] + 1] = mx[ind:ind + i[1] + 1][::-1]
		else:
			mn[ind:ind + i[1] + 1] = mn[ind:ind + i[1] + 1][::-1]
		ind += i[1]
	print(*mx)
	print(*mn)


from math import *
t = int(input())
for zz in range(t):
	(n, s) = [i for i in input().split()]
	n = int(n)
	mn = n
	s1 = []
	i = n - 2
	while i >= 0:
		if s[i] == '<':
			s1.append(mn)
			mn -= 1
			i -= 1
		else:
			j = i - 1
			while j >= 0 and s[j] == '>':
				j -= 1
			dt = i - j + 1
			for t in range(dt):
				s1.append(mn + t - dt + 1)
			mn -= dt
			i -= dt
	if len(s1) < n:
		s1.append(mn)
	s1.reverse()
	mn = 1
	s2 = []
	i = n - 2
	while i >= 0:
		if s[i] == '>':
			s2.append(mn)
			mn += 1
			i -= 1
		else:
			j = i - 1
			while j >= 0 and s[j] == '<':
				j -= 1
			dt = i - j + 1
			for t in range(dt):
				s2.append(mn + dt - t - 1)
			mn += dt
			i -= dt
	if len(s2) < n:
		s2.append(mn)
	s2.reverse()
	print(' '.join(map(str, s2)))
	print(' '.join(map(str, s1)))


tc = int(input())

def remap(s):
	sorted_s = sorted(s)
	num2idx = {num: i for (i, num) in enumerate(sorted_s, 1)}
	return [num2idx[num] for num in s]

def get_min(s):
	n = len(s)
	res = [0]
	min_so_far = 0
	for (i, sign) in enumerate(s):
		if sign == '<':
			res.append(res[-1] + 1)
		else:
			res.append(min_so_far - n - 1)
		min_so_far = min(min_so_far, res[-1])
	return remap(res)

def get_max(s):
	n = len(s)
	res = [0]
	max_so_far = 0
	for (i, sign) in enumerate(s):
		if sign == '<':
			res.append(res[-1] + n + 1)
		else:
			res.append(res[-1] - 1)
	return remap(res)
for _ in range(tc):
	(_, s) = input().split()
	print(*get_min(s))
	print(*get_max(s))


def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		line = list(input().split())
		N = int(line[0])
		S = line[1]
		inc_num = S.count('<')
		ans = [0] * N
		inc = N
		dec = N - inc_num
		for i in range(N - 1):
			if ans[i + 1]:
				continue
			if S[i] == '<':
				j = i + 1
				cnt = 1
				while True:
					if j == N - 1:
						break
					if S[j] == '<':
						cnt += 1
					else:
						break
					j += 1
				for j in range(i + cnt - 1, i - 1, -1):
					ans[j + 1] = inc
					inc -= 1
		for i in range(N):
			if ans[i] == 0:
				ans[i] = dec
				dec -= 1
		print(*ans)
		ans = [0] * N
		inc = N - inc_num + 1
		dec = N - inc_num
		for i in range(N - 1):
			if S[i] == '<':
				ans[i + 1] = inc
				inc += 1
		for i in range(N):
			if ans[i] == 0:
				ans[i] = dec
				dec -= 1
		print(*ans)

def __starting_point():
	main()
__starting_point()


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]

def p1(n, s, le):
	r = []
	b = i = 0
	while i < n:
		try:
			ni = s.index(le, i) + 1
		except ValueError:
			ni = n
		r += list(range(ni, i, -1))
		i = ni
	return r
(t,) = rl()
for _ in range(t):
	(n, s) = stdin.readline().split()
	n = int(n)
	print(*(n - x + 1 for x in p1(n, s, '>')))
	print(*p1(n, s, '<'))


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
t = int(input())
for w in range(t):
	(n, s) = (i for i in input().split())
	n = int(n)
	s = list(s)
	ans1 = [0] * n
	ans2 = [0] * n
	k = n
	prev = -1
	for i in range(n):
		if i == n - 1 or s[i] == '>':
			for j in range(i, prev, -1):
				ans1[j] = k
				k -= 1
			prev = i
	k = 1
	prev = -1
	for i in range(n):
		if i == n - 1 or s[i] == '<':
			for j in range(i, prev, -1):
				ans2[j] = k
				k += 1
			prev = i
	print(*ans1)
	print(*ans2)


import bisect
import collections
import copy
import enum
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(3001)
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, s) = input().split()
	n = int(n)
	l1 = list(range(n, 0, -1))
	l2 = list(range(1, n + 1))
	i = 0
	while i < n - 1:
		if s[i] == '<':
			st = i
			while i < n - 1 and s[i] == '<':
				i += 1
			l1[st:i + 1] = l1[st:i + 1][::-1]
		i += 1
	i = 0
	while i < n - 1:
		if s[i] == '>':
			st = i
			while i < n - 1 and s[i] == '>':
				i += 1
			l2[st:i + 1] = l2[st:i + 1][::-1]
		i += 1
	print(*l1)
	print(*l2)


from sys import stdin
for case in range(int(stdin.readline())):
	(n, s) = stdin.readline().strip().split()
	n = int(n)
	parts = []
	ind = 0
	while ind < n - 1:
		cur = s[ind]
		l = 0
		while s[ind] == cur:
			ind += 1
			l += 1
			if ind == len(s):
				break
		if cur == '<':
			parts.append((0, l))
		else:
			parts.append((1, l))
	highOut = []
	if parts[0][0] == 1:
		high = n - 1
		tempH = n
	else:
		high = n
	for x in parts:
		if x[0] == 1:
			highOut += [tempH] + [high - i for i in range(x[1] - 1)]
			high -= x[1] - 1
		else:
			highOut += [high - i for i in range(x[1], 0, -1)]
			tempH = high
			high -= x[1] + 1
	if parts[-1][0] == 0:
		highOut.append(tempH)
	else:
		highOut.append(1)
	lowOut = []
	if parts[0][0] == 0:
		low = 2
		tempL = 1
	else:
		low = 1
	for x in parts:
		if x[0] == 0:
			lowOut += [tempL] + [low + i for i in range(x[1] - 1)]
			low += x[1] - 1
		else:
			lowOut += [low + i for i in range(x[1], 0, -1)]
			tempL = low
			low += x[1] + 1
	if parts[-1][0] == 1:
		lowOut.append(tempL)
	else:
		lowOut.append(n)
	print(' '.join([str(x) for x in highOut]))
	print(' '.join([str(x) for x in lowOut]))


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' ', **kwargs):
	print(space.join(map(str, lista)), **kwargs)

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path
for test in range(ii()):
	(n, s) = lsi()
	n = int(n)
	M = n
	lon = [-1 for i in range(n)]
	sho = [-1 for i in range(n)]
	count = 0
	segni = list()
	for i in range(n - 2, -1, -1):
		if s[i] == '<':
			if count != 0:
				segni.append(count)
			count = 0
			lon[i + 1] = M
			M -= 1
		else:
			count += 1
	count += 1
	segni.append(count)
	segni.reverse()
	i = 0
	j = 0
	base = 1
	while i < n:
		if lon[i] == -1:
			num = segni[j]
			j += 1
			for k in range(num):
				lon[i + k] = base + num - k - 1
			base += num
			i += num
		else:
			i += 1
	count = 0
	segni = list()
	M = n
	for i in range(n - 1):
		if s[i] == '>':
			if count != 0:
				segni.append(count)
				count = 0
			sho[i] = M
			M -= 1
		else:
			count += 1
	count += 1
	segni.append(count)
	base = M
	i = 0
	j = 0
	while i < n:
		if sho[i] == -1:
			num = segni[j]
			j += 1
			for k in range(num):
				sho[i + k] = base - num + k + 1
			base -= num
			i += num
		else:
			i += 1
	print_list(sho)
	print_list(lon)


from sys import stdin, stdout
from os import path
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')
q = int(stdin.readline())
for _ in range(q):
	inp = stdin.readline().split()
	n = int(inp[0])
	s = inp[1]
	s += '@'
	qu = []
	ans = [None for i in range(n + 5)]
	res = [None for i in range(n + 5)]
	last = 0
	for i in range(n - 1):
		if s[i] == '<' and s[i + 1] != '<':
			qu.append((last, i))
		elif s[i] != '<' and s[i + 1] == '<':
			last = i + 1
	cnt = 1
	for v in qu:
		for j in range(v[0], v[1] + 1):
			ans[j] = cnt
			cnt += 1
	for i in range(n - 1, -1, -1):
		if ans[i] == None:
			ans[i] = cnt
			cnt += 1
	cnt = 1
	qu.reverse()
	for v in qu:
		for j in range(v[0], v[1] + 1):
			res[j] = cnt
			cnt += 1
	for i in range(n - 1, -1, -1):
		if res[i] == None:
			res[i] = cnt
			cnt += 1
	for i in range(n):
		print(res[i], end=' ')
	print()
	for i in range(n):
		print(ans[i], end=' ')
	print()


t = int(input())
for i in range(t):
	a = input().split()
	n = int(a[0])
	s = a[1] + '>'
	ans = []
	c = []
	now = n
	for j in range(n):
		if s[j] == '<':
			c.append(now)
			now -= 1
		elif len(c) > 0:
			c.append(now)
			now -= 1
			ans += c[::-1]
			c = []
		else:
			ans.append(now)
			now -= 1
	if len(c) > 0:
		ans += c[::-1]
	print(' '.join(map(str, ans)))
	ans = []
	c = []
	now = 1
	for j in range(n):
		if s[j] == '>':
			c.append(now)
			now += 1
		elif len(c) > 0:
			c.append(now)
			now += 1
			ans += c[::-1]
			c = []
		else:
			ans.append(now)
			now += 1
	if len(c) > 0:
		ans += c[::-1]
	print(' '.join(map(str, ans)))


import os
from sys import stdin

def solve(tc):
	(n, seq) = stdin.readline().split()
	n = int(n)
	mini = [0 for i in range(n)]
	maxi = [0 for i in range(n)]
	lo = 1
	hi = n
	for i in range(n - 1):
		if seq[i] == '>':
			mini[i] = hi
			maxi[i] = hi
			hi -= 1
	for i in range(n - 1):
		if seq[i] == '<':
			maxi[i] = lo
			lo += 1
	maxi[n - 1] = lo
	i = 0
	while i < n - 1:
		if seq[i] == '<':
			j = i + 1
			while j < n and mini[j] == 0:
				j += 1
			offset = 1
			for k in range(i, j):
				mini[k] = hi - j + i + offset
				offset += 1
			hi -= j - i
			i = j
		else:
			i += 1
	if mini[n - 1] == 0:
		mini[n - 1] = hi
	print(' '.join((str(x) for x in mini)))
	print(' '.join((str(x) for x in maxi)))
tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


import sys
input = iter(sys.stdin.readlines()).__next__
import itertools
t = int(input())
outputs = []
for _ in range(t):
	line = input().split()
	n = int(line[0])
	s = line[1]
	out1 = []
	out2 = []
	j = n
	i = 1
	for (k, g) in itertools.groupby(s):
		g_len = len(list(g))
		if k == '<':
			run1 = g_len + 1
			if j < n:
				j = out1.pop()
			out1 += range(j - run1 + 1, j + 1)
			j -= run1
			run2 = g_len + (1 if i == 1 else 0)
			out2 += range(i, i + run2)
			i += run2
		elif k == '>':
			run1 = g_len + (1 if j == n else 0)
			out1 += range(j, j - run1, -1)
			j -= run1
			run2 = g_len + 1
			if i > 1:
				i = out2.pop()
			out2 += range(i + run2 - 1, i - 1, -1)
			i += run2
	outputs.append(' '.join((str(x) for x in out1)))
	outputs.append(' '.join((str(x) for x in out2)))
print(*outputs, sep='\n')


t = int(input())
for _ in range(t):
	(n, s) = input().split()
	n = int(n)
	s = '<' + s + '>'
	up = [1]
	dw = []
	for i in range(1, n + 1):
		if s[i - 1:i + 1] == '<<':
			up[-1] += 1
		elif s[i - 1:i + 1] == '>>':
			dw[-1] += 1
		elif s[i - 1:i + 1] == '<>':
			dw.append(1)
		else:
			up.append(1)
	dw[-1] -= 1
	l = len(up)
	ans = []
	now = 0
	for i in range(l):
		z1 = [now + j + 1 for j in range(up[i] - 1)]
		now += up[i] - 1
		z2 = [now + j + 1 for j in range(dw[i] + 1)]
		z2.reverse()
		now += dw[i] + 1
		ans += z1
		ans += z2
	ans1 = ' '.join(list(map(str, ans)))
	up[0] -= 1
	dw[-1] += 1
	ans = []
	now = n + 1
	for i in range(l):
		z1 = [now - j - 1 for j in range(dw[i])]
		now -= dw[i]
		z2 = [now - j - 1 for j in range(up[i])]
		z2.reverse()
		now -= up[i]
		ans += z2
		ans += z1
	ans2 = ' '.join(list(map(str, ans)))
	print(ans2)
	print(ans1)


from sys import stdin, stdout
from collections import deque
T = int(stdin.readline())

def pl(l):
	for i in l:
		print(i, end=' ')
	print('')
for i in range(T):
	(n, s) = map(str, stdin.readline().split())
	s = list(s)
	n = int(n)
	a = []
	b = []
	for i in range(1, n + 1):
		b.append(i)
	for i in range(n, 0, -1):
		a.append(i)
	x = 0
	cur = 0
	aa = []
	bb = []
	while cur < n - 1:
		if s[cur] == '>':
			y = cur
			for j in range(y, x - 1, -1):
				aa.append(a[j])
			x = y + 1
		cur += 1
	y = cur
	for j in range(y, x - 1, -1):
		aa.append(a[j])
	x = 0
	cur = 0
	while cur < n - 1:
		if s[cur] == '<':
			y = cur
			for j in range(y, x - 1, -1):
				bb.append(b[j])
			x = y + 1
		cur += 1
	y = cur
	for j in range(y, x - 1, -1):
		bb.append(b[j])
	pl(aa)
	pl(bb)


t = int(input())
while t:
	(n, s) = input().split()
	n = int(n)
	a = []
	temp = n
	ls = []
	for i in range(n - 1):
		if s[i] == '>':
			a.append(temp)
			temp -= 1
			if len(ls):
				j = len(ls) - 1
				while j >= 0:
					a.append(ls[j])
					j -= 1
				ls = []
		else:
			ls.append(temp)
			temp -= 1
	ls.append(temp)
	if len(ls):
		j = len(ls) - 1
		while j >= 0:
			a.append(ls[j])
			j -= 1
	b = []
	temp = 1
	ls = []
	for i in range(n - 1):
		if s[i] == '<':
			b.append(temp)
			temp += 1
			if len(ls):
				j = len(ls) - 1
				while j >= 0:
					b.append(ls[j])
					j -= 1
				ls = []
		else:
			ls.append(temp)
			temp += 1
	ls.append(temp)
	if len(ls):
		j = len(ls) - 1
		while j >= 0:
			b.append(ls[j])
			j -= 1
	print(*a)
	print(*b)
	t -= 1


t = int(input())
while t:
	t -= 1
	(n, s) = input().split()
	n = int(n)
	cur = n
	ans = [0] * n
	last = -1
	for i in range(n):
		if i == n - 1 or s[i] == '>':
			for j in range(i, last, -1):
				ans[j] = cur
				cur -= 1
			last = i
	print(' '.join(map(str, ans)))
	cur = 1
	last = -1
	for i in range(n):
		if i == n - 1 or s[i] == '<':
			for j in range(i, last, -1):
				ans[j] = cur
				cur += 1
			last = i
	print(' '.join(map(str, ans)))


n = int(input())
for i in range(0, n):
	lis = input()
	(a, b) = lis.split()
	curr = int(a)
	pos = 0
	arr = [1] * curr
	while curr > 0 and pos < int(a) - 1:
		if b[pos] == '>':
			arr[pos] = curr
			curr -= 1
			pos += 1
		else:
			cal = pos
			diff = 0
			while cal < int(a) - 1 and b[cal] == '<':
				cal += 1
				diff += 1
			curr = curr - diff
			while pos <= cal:
				arr[pos] = curr
				curr = curr + 1
				pos += 1
			curr = curr - diff - 2
	for i in range(0, int(a)):
		print(arr[i], end=' ')
	print()
	curr = int(a)
	pos = curr - 2
	arr = [1] * curr
	while curr > 0 and pos >= 0:
		if b[pos] == '<':
			arr[pos + 1] = curr
			curr -= 1
			pos -= 1
		else:
			cal = pos
			diff = 0
			while cal >= 0 and b[cal] == '>':
				cal -= 1
				diff += 1
			curr = curr - diff
			while pos >= cal:
				arr[pos + 1] = curr
				curr = curr + 1
				pos -= 1
			curr = curr - diff - 2
	for i in range(0, int(a)):
		print(arr[i], end=' ')
	print()


import sys
Q = int(sys.stdin.readline().strip())
for q in range(0, Q):
	(n, s) = sys.stdin.readline().strip().split()
	n = int(n)
	U = [1]
	D = [1]
	for i in range(0, n - 1):
		if s[i] == '<':
			U[-1] = U[-1] + 1
			D.append(1)
		else:
			D[-1] = D[-1] + 1
			U.append(1)
	m = n
	i = 0
	A = []
	while m > 0:
		for j in range(0, U[i]):
			A.append(str(m - U[i] + j + 1))
		m = m - U[i]
		i = i + 1
	print(' '.join(A))
	m = 0
	i = 0
	A = []
	while i < len(D):
		for j in range(0, D[i]):
			A.append(str(m + D[i] - j))
		m = m + D[i]
		i = i + 1
	print(' '.join(A))


import math
from sys import stdin, stdout

def main():
	T = int(stdin.readline())
	for _ in range(T):
		(n, stri) = stdin.readline().split()
		n = int(n)
		count = 0
		maxi = [0] * n
		mini = [0] * n
		for i in stri:
			if i == '<':
				count += 1
		cur_min = 0
		cur_max = 0
		for (z, i) in enumerate(stri):
			if i == '<':
				maxi[z] = cur_min + 1
				if mini[z] != 0:
					cur_min += 1
					continue
				j = int(z) + 1
				while j < len(stri):
					if stri[j] == '>':
						break
					j += 1
				for zz in range(j - z):
					mini[z + zz] = count - j + z + zz - cur_min + 1
				cur_min += 1
			else:
				maxi[z] = n - cur_max
				mini[z] = n - cur_max
				cur_max += 1
		mini[-1] = n - cur_max
		maxi[-1] = n - cur_max
		stdout.write(' '.join((str(x) for x in mini)) + '\n')
		stdout.write(' '.join((str(x) for x in maxi)) + '\n')
main()


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(N, s) = input().split()
	N = int(N)
	s = s.strip()
	ts = []
	t = 0
	for c in s:
		if c == '<':
			t += 1
		else:
			ts.append(t)
			t = 0
	ts.append(t)
	c = 0
	rs = []
	while ts:
		t = ts.pop()
		for j in range(t + 1):
			rs.append(c + t + 1 - j)
		c += t + 1
	print(*rs[::-1])
	ts = []
	t = 0
	for c in s:
		if c == '>':
			t += 1
		else:
			ts.append(t)
			t = 0
	ts.append(t)
	c = 0
	rs = []
	for t in ts:
		for j in range(t + 1):
			rs.append(c + t + 1 - j)
		c += t + 1
	print(*rs)


import sys

class Node:

	def __init__(self):
		self.val: int = None
		self.next: Node = None

class NodeLink:

	def __init__(self):
		self.head = Node()
		self.tail = self.head
		self.size = 0

	def append(self, node: Node, val):
		new_node = Node()
		new_node.val = val
		new_node.next = node.next
		node.next = new_node
		if node is self.tail:
			self.tail = new_node

	def print(self):
		node = self.head.next
		output_strings = []
		while node is not None:
			output_strings.append(str(node.val))
			node = node.next
		print(' '.join(output_strings))

def output_shortest_and_longest(max_number, comp_serial):
	current_smallest_number = 1
	current_largest_number = max_number
	shortest_lis = NodeLink()
	longest_lis = NodeLink()
	latest_gt_node = shortest_lis.head
	latest_lt_node = longest_lis.head
	shortest_lis.append(shortest_lis.tail, current_largest_number)
	longest_lis.append(longest_lis.tail, current_smallest_number)
	for ch in comp_serial:
		current_smallest_number += 1
		current_largest_number -= 1
		if ch == '<':
			latest_lt_node = longest_lis.tail
			shortest_lis.append(latest_gt_node, current_largest_number)
			longest_lis.append(longest_lis.tail, current_smallest_number)
		else:
			latest_gt_node = shortest_lis.tail
			shortest_lis.append(shortest_lis.tail, current_largest_number)
			longest_lis.append(latest_lt_node, current_smallest_number)
	shortest_lis.print()
	longest_lis.print()

def solve():
	import time
	left_cases = None
	for line in sys.stdin:
		if left_cases is None:
			left_cases = int(line.strip())
		else:
			vals = line.split()
			output_shortest_and_longest(int(vals[0]), vals[1])
			left_cases -= 1
			if left_cases == 0:
				break
solve()


t = int(input())
for loop in range(t):
	(n, s) = input().split()
	n = int(n)
	s = list(s)
	lisUP = []
	lisDO = []
	now = 1
	d = s[0]
	for i in range(n - 1):
		if d == s[i]:
			now += 1
		else:
			if d == '<':
				lisUP.append(now)
			else:
				lisDO.append(now)
			d = s[i]
			now = 1
	if now > 0:
		if d == '<':
			lisUP.append(now)
		else:
			lisDO.append(now)
	if s[0] == '<':
		ans = []
		nmax = sum(lisUP)
		nmin = 0
		for i in range(max(len(lisUP), len(lisDO))):
			now = []
			for j in range(lisUP[i]):
				now.append(nmax)
				nmax -= 1
			now.reverse()
			ans += now
			if len(lisDO) == i:
				break
			now = []
			for j in range(lisDO[i]):
				now.append(nmin)
				nmin -= 1
			ans += now
	else:
		ans = []
		nmax = sum(lisUP)
		nmin = 0
		for i in range(max(len(lisUP), len(lisDO))):
			now = []
			for j in range(lisDO[i]):
				now.append(nmin)
				nmin -= 1
			ans += now
			if len(lisUP) == i:
				break
			now = []
			for j in range(lisUP[i]):
				now.append(nmax)
				nmax -= 1
			now.reverse()
			ans += now
	ma = min(ans)
	for i in range(n):
		ans[i] -= ma - 1
	print(' '.join(map(str, ans)))
	s.reverse()
	lisUP = []
	lisDO = []
	now = 1
	d = s[0]
	for i in range(n - 1):
		if d == s[i]:
			now += 1
		else:
			if d == '>':
				lisUP.append(now)
			else:
				lisDO.append(now)
			d = s[i]
			now = 1
	if now > 0:
		if d == '>':
			lisUP.append(now)
		else:
			lisDO.append(now)
	if s[0] == '>':
		ans = []
		nmax = sum(lisUP)
		nmin = 0
		for i in range(max(len(lisUP), len(lisDO))):
			now = []
			for j in range(lisUP[i]):
				now.append(nmax)
				nmax -= 1
			now.reverse()
			ans += now
			if len(lisDO) <= i:
				break
			now = []
			for j in range(lisDO[i]):
				now.append(nmin)
				nmin -= 1
			ans += now
	else:
		ans = []
		nmax = sum(lisUP)
		nmin = 0
		for i in range(max(len(lisUP), len(lisDO))):
			now = []
			for j in range(lisDO[i]):
				now.append(nmin)
				nmin -= 1
			ans += now
			if len(lisUP) == i:
				break
			now = []
			for j in range(lisUP[i]):
				now.append(nmax)
				nmax -= 1
			now.reverse()
			ans += now
	ma = min(ans)
	for i in range(n):
		ans[i] -= ma - 1
	ans.reverse()
	print(' '.join(map(str, ans)))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
mod = int(1000000000.0 + 7)
for t in range(int(data())):
	(n, s) = input().split()
	n = int(n)
	l1 = [0] * n
	l2 = [0] * n
	cnt = n
	for i in range(n - 2, -1, -1):
		if s[i] == '<':
			l1[i + 1] = cnt
			cnt -= 1
	for i in range(n - 2, -1, -1):
		if s[i] == '>':
			if i == 0:
				l1[0] = cnt
				cnt -= 1
				j = i + 1
				while j < n and s[j - 1] == '>':
					l1[j] = cnt
					cnt -= 1
					j += 1
			elif s[i - 1] == '<':
				j = i + 1
				while j < n and s[j - 1] == '>':
					l1[j] = cnt
					cnt -= 1
					j += 1
	if l1[0] == 0:
		l1[0] = 1
	cnt = n
	for i in range(n - 1):
		if s[i] == '>':
			l2[i] = cnt
			cnt -= 1
	for i in range(n - 1):
		if s[i] == '<':
			if i == n - 2:
				l2[n - 1] = cnt
				cnt -= 1
				j = i
				while j >= 0 and s[j] == '<':
					l2[j] = cnt
					cnt -= 1
					j -= 1
			elif s[i + 1] == '>':
				j = i
				while j >= 0 and s[j] == '<':
					l2[j] = cnt
					cnt -= 1
					j -= 1
	if l2[n - 1] == 0:
		l2[n - 1] = 1
	print(*l2)
	print(*l1)


import sys
from math import *
input = sys.stdin.readline
t = int(input())
while t > 0:
	t -= 1
	(n, s) = input().split()
	s = list(s)
	n = int(n)
	a = [n - i for i in range(n)]
	i = 0
	j = 0
	while i < n - 1:
		j = i
		while j < n - 1 and s[j] == '<':
			j += 1
		d = a[i:j + 1][::-1]
		c = 0
		for k in range(i, j + 1):
			a[k] = d[c]
			c += 1
		i = j
		i += 1
	print(*a)
	a = [i + 1 for i in range(n)]
	i = 0
	j = 0
	while i < n - 1:
		j = i
		while j < n - 1 and s[j] == '>':
			j += 1
		d = a[i:j + 1][::-1]
		c = 0
		for k in range(i, j + 1):
			a[k] = d[c]
			c += 1
		i = j
		i += 1
	print(*a)


from sys import stdin, stdout
from collections import deque, Counter
from copy import copy
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def main():
	T = int(rl())
	for _ in range(T):
		line = rll()
		(n, s) = (int(line[0]), line[1])
		(runs, L) = ([], 0)
		(inc, dec) = (0, 0)
		for R in range(len(s) + 1):
			if R == len(s) or s[R] != s[L]:
				runlen = R - L if L > 0 else R - L + 1
				runs.append((runlen, s[L]))
				if s[L] == '<':
					inc += runlen
				else:
					dec += runlen
				L = R
		short = []
		(inc_ptr, dec_ptr) = (n, dec)
		for (rlen, rtype) in runs:
			local = deque()
			if rtype == '<':
				for _ in range(rlen):
					local.appendleft(inc_ptr)
					inc_ptr -= 1
				short.extend(local)
			else:
				for _ in range(rlen):
					local.append(dec_ptr)
					dec_ptr -= 1
				short.extend(local)
		long_ = []
		(inc_ptr, dec_ptr) = (n - inc + 1, 1)
		for (rlen, rtype) in runs:
			local = deque()
			if rtype == '<':
				for _ in range(rlen):
					local.append(inc_ptr)
					inc_ptr += 1
				long_.extend(local)
			else:
				for _ in range(rlen):
					local.appendleft(dec_ptr)
					dec_ptr += 1
				long_.extend(local)
		shortLIS = ' '.join((str(x) for x in short))
		longLIS = ' '.join((str(x) for x in long_))
		stdout.write(str(shortLIS))
		stdout.write('\n')
		stdout.write(str(longLIS))
		stdout.write('\n')
main()


import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
	(n, s) = input().split()
	n = int(n)
	direct = [0]
	for i in range(1, n - 1):
		if s[i] != s[i - 1]:
			direct.append(i)
	if s[-1] == '>':
		direct.append(n - 1)
	l = len(direct)
	if l == 1:
		print(*list(range(1, n + 1)))
		print(*list(range(1, n + 1)))
		continue
	geq = []
	leq = []
	for i in range(1, l):
		if i % 2 and s[0] == '>' or (i % 2 == 0 and s[0] == '<'):
			geq.append(direct[i] - direct[i - 1])
		else:
			leq.append(direct[i] - direct[i - 1])
	if s[0] == '<':
		geq.append(1)
		ans1 = []
		ans2 = []
		cnt = 0
		for i in range(l - 1):
			if i % 2 == 0:
				ans1.extend(list(range(n - cnt - leq[i // 2], n - cnt + 1)))
				cnt += leq[i // 2] + 1
			else:
				ans1.extend(list(range(n - cnt, n - cnt - geq[i // 2] + 1, -1)))
				cnt += geq[i // 2] - 1
		ans1.extend(list(range(1, n - cnt + 1)))
		cnt = 1
		for i in range(l - 1):
			if i == 0:
				ans2.extend(list(range(cnt, cnt + leq[i // 2])))
				cnt += leq[i // 2]
			elif i % 2 == 0:
				ans2.extend(list(range(cnt, cnt + leq[i // 2] - 1)))
				cnt += leq[i // 2] - 1
			else:
				ans2.extend(list(range(cnt + geq[i // 2], cnt - 1, -1)))
				cnt += geq[i // 2] + 1
		ans2.extend(list(range(cnt, n + 1)))
	else:
		ans1 = []
		ans2 = []
		cnt = 0
		for i in range(l - 1):
			if i == 0:
				ans1.extend(list(range(n, n - geq[i // 2], -1)))
				cnt += geq[i // 2]
			elif i % 2 == 0:
				ans1.extend(list(range(n - cnt, n - cnt - geq[i // 2] + 1, -1)))
				cnt += geq[i // 2] - 1
			else:
				ans1.extend(list(range(n - cnt - leq[i // 2], n - cnt + 1)))
				cnt += leq[i // 2] + 1
		ans1.extend(list(range(1, n - cnt + 1)))
		cnt = 1
		for i in range(l - 1):
			if i % 2 == 0:
				ans2.extend(list(range(cnt + geq[i // 2], cnt - 1, -1)))
				cnt += geq[i // 2]
			else:
				ans2.extend(list(range(cnt + 1, cnt + leq[i // 2])))
				cnt += leq[i // 2]
		ans2.extend(list(range(cnt + 1, n + 1)))
	print(*ans1)
	print(*ans2)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, s) = sys.stdin.readline().split()
	n = int(n)
	(num, last) = (n, 0)
	ans = [-1 for _ in range(n)]
	for i in range(n):
		if i == n - 1 or s[i] == '>':
			for j in range(i, last - 1, -1):
				ans[j] = num
				num -= 1
			last = i + 1
	ans1 = [-1 for _ in range(n)]
	(num, last) = (1, 0)
	for i in range(n):
		if i == n - 1 or s[i] == '<':
			for j in range(i, last - 1, -1):
				ans1[j] = num
				num += 1
			last = i + 1
	print(' '.join((str(x) for x in ans)))
	print(' '.join((str(x) for x in ans1)))


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
inputI = int(input())
mod = 1000000007
INF = float('inf')

def main():
	N = inputI
	for _ in range(N):
		(n, s) = input().split()
		n = int(n)
		(st, lg) = ([], [])
		res = [0] * n
		now = n
		nowp = 0
		for i in range(n):
			if i == n - 1 or s[i] == '>':
				for j in range(i, nowp - 1, -1):
					res[j] = now
					now -= 1
					nowp += 1
		print(*res)
		now = 1
		nowp = 0
		for i in range(n):
			if i == n - 1 or s[i] == '<':
				for j in range(i, nowp - 1, -1):
					res[j] = now
					now += 1
					nowp += 1
		print(*res)
main()


for t in range(int(input())):
	(n, s) = [i for i in input().split()]
	n = int(n)
	s1 = ''
	s2 = ''
	for i in range(n - 1):
		if s[i] == '<':
			s1 += '0'
			s2 += '1'
		else:
			s1 += '1'
			s2 += '0'
	s2 = s2[::-1]
	res1 = []
	res2 = []
	temp1 = [1]
	temp2 = [1]
	curr = 2
	i = 0
	while i < n - 1:
		if s1[i] == '0':
			while temp1:
				res1.append(temp1.pop())
			temp1.append(i + 2)
		else:
			temp1.append(i + 2)
		if s2[i] == '0':
			while temp2:
				res2.append(temp2.pop())
			temp2.append(i + 2)
		else:
			temp2.append(i + 2)
		i += 1
	while temp1:
		res1.append(temp1.pop())
	while temp2:
		res2.append(temp2.pop())
	print(*res2[::-1])
	print(*res1)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(x, y):
	return f(x) // (f(y) * f(x - y))
t = int(input())
for _ in range(t):
	(n, s) = map(str, input().split())
	n = int(n)
	maxi = [0] * n
	mini = [0] * n
	for i in range(n):
		mini[i] = n - i
		maxi[i] = i + 1
	i = 0
	j = 0
	while i < n - 1:
		while j < n - 1 and s[i] == s[j]:
			j += 1
		if s[i] == '>':
			maxi[i:j + 1] = maxi[i:j + 1][::-1]
		else:
			mini[i:j + 1] = mini[i:j + 1][::-1]
		i = j
	print(*mini)
	print(*maxi)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]

def makel(s):
	l = [[1, s[0]]]
	for i in s[1:]:
		if i == l[-1][1]:
			l[-1][0] += 1
		else:
			l.append([1, i])
	l[0][0] += 1
	return l

def minLIS(l, n):
	for i in range(len(l)):
		if l[i][1] == '<':
			l[i][1] = n
			n -= l[i][0]
	for i in range(len(l)):
		if l[i][1] == '>':
			l[i][0] *= -1
			l[i][1] = n
			n += l[i][0]
	ans = []
	for i in l:
		if i[0] > 0:
			for j in range(i[1] - i[0] + 1, i[1] + 1, 1):
				ans.append(j)
		else:
			for j in range(i[1], i[1] + i[0], -1):
				ans.append(j)
	return ans

def maxLIS(l, n):
	for i in range(len(l) - 1, -1, -1):
		if l[i][1] == '<':
			l[i][1] = n
			n -= l[i][0]
	for i in range(len(l) - 1, -1, -1):
		if l[i][1] == '>':
			l[i][0] *= -1
			l[i][1] = n
			n += l[i][0]
	ans = []
	for i in l:
		if i[0] > 0:
			for j in range(i[1] - i[0] + 1, i[1] + 1, 1):
				ans.append(j)
		else:
			for j in range(i[1], i[1] + i[0], -1):
				ans.append(j)
	return ans
for _ in range(val()):
	s = li2()[1:][0]
	n = len(s)
	l = makel(s)
	print(*minLIS(l[:], n + 1))
	l = makel(s)
	print(*maxLIS(l, n + 1))


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, s) = input().split()
	n = int(n)
	lts = [-1, *(i for i in range(len(s)) if s[i] == '>'), n - 1]
	cur = n + 1
	for i in range(1, len(lts)):
		diff = lts[i] - lts[i - 1]
		print(*range(cur - diff, cur), end=' ')
		cur -= diff
	print()
	gts = [-1, *(i for i in range(len(s)) if s[i] == '<'), n - 1]
	cur = 1
	for i in range(1, len(gts)):
		diff = gts[i] - gts[i - 1]
		print(*reversed(range(cur, cur + diff)), end=' ')
		cur += diff
	print()


import sys

def reverse(s):
	return s[::-1]

def main():
	N = int(sys.stdin.readline().strip())
	for _ in range(N):
		(n, s) = sys.stdin.readline().strip().split()
		n = int(n)
		a0 = [0] * n
		cnt0 = 1
		for i in list(range(n - 1))[::-1]:
			if s[i] == '>':
				a0[i + 1] = cnt0
				cnt0 += 1
		a1 = a0[:]
		cnt1 = cnt0
		for i in list(range(n))[::-1]:
			if a1[i] == 0 and (i == 0 or a1[i - 1] != 0):
				j = i
				while j < n and a1[j] == 0:
					a1[j] = cnt1
					cnt1 += 1
					j += 1
		print(' '.join((str(x) for x in a1)))
		a2 = a0[:]
		cnt2 = cnt0
		for i in list(range(n)):
			if a2[i] == 0 and (i == 0 or a2[i - 1] != 0):
				j = i
				while j < n and a2[j] == 0:
					a2[j] = cnt2
					cnt2 += 1
					j += 1
		print(' '.join((str(x) for x in a2)))
main()


def calmin(xs):
	n = len(xs) + 1
	ans = [-1] * n
	high = n
	i = xs.find('<')
	while 0 <= i < n - 1:
		j = xs.find('>', i)
		if j == -1:
			j = n - 1
		diff = j - i
		begin = high - diff + 1
		for i in range(i, j):
			ans[i + 1] = begin
			begin += 1
			high -= 1
		i = xs.find('<', j)
	for i in range(n):
		if ans[i] == -1:
			ans[i] = high
			high -= 1
	return ans

def calmax(xs):
	n = len(xs) + 1
	ans = [-1] * n
	i = xs.find('>')
	while 0 <= i < n - 1:
		low = i
		j = xs.find('<', i)
		if j == -1:
			j = n - 1
		diff = j - i
		begin = low + diff + 1
		for i in range(i, j):
			ans[i] = begin
			begin -= 1
			low += 1
		ans[i + 1] = begin
		i = xs.find('>', j)
	for i in range(n):
		if ans[i] == -1:
			ans[i] = i + 1
	return ans
T = int(input())
for _ in range(T):
	ins = input().split()
	n = int(ins[0])
	xs = ins[1]
	print(' '.join(map(str, calmin(xs))))
	print(' '.join(map(str, calmax(xs))))


t = int(input())
for _ in range(t):
	(n, st) = input().split()
	n = int(n)
	num = n
	last = 0
	answ = [0 for i in range(n)]
	for i in range(n):
		if i == n - 1 or st[i] == '>':
			for j in range(i, last - 1, -1):
				answ[j] = num
				num -= 1
			last = i + 1
	print(' '.join(map(str, answ)))
	num = 1
	last = 0
	answ = [0 for i in range(n)]
	for i in range(n):
		if i == n - 1 or st[i] == '<':
			for j in range(i, last - 1, -1):
				answ[j] = num
				num += 1
			last = i + 1
	print(' '.join(map(str, answ)))


T = int(input())
for _ in range(0, T):
	tt = input().split()
	n = int(tt[0])
	s = str(tt[1])
	mx = []
	vismx = [0] * (n + 1)
	mn = []
	vismn = [0] * (n + 1)
	L = []
	c = 1
	for i in range(1, len(s)):
		if s[i] != s[i - 1]:
			L.append((s[i - 1], c))
			c = 1
		else:
			c += 1
	L.append((s[-1], c))
	ptr1 = 1
	ptr2 = n
	L = L[::-1]
	if s[-1] == '>':
		mn.append(1)
		vismn[1] = 1
		ptr1 += 1
	for i in range(0, len(L)):
		if L[i][0] == '>':
			for j in range(L[i][1] - 1):
				mn.append(ptr1)
				vismn[ptr1] = 1
				ptr1 += 1
		else:
			h = []
			for j in range(L[i][1] + 1):
				h.append(ptr1)
				vismn[ptr1] = 1
				ptr1 += 1
			h = h[::-1]
			mn += h
	for i in range(1, len(vismn)):
		if vismn[i] == 0:
			mn.append(i)
			break
	mn = mn[::-1]
	print(*mn)
	ptr1 = 1
	ptr2 = n
	L = L[::-1]
	for i in range(0, len(L)):
		if L[i][0] == '>':
			for j in range(L[i][1]):
				mx.append(ptr2)
				vismx[ptr2] = 1
				ptr2 -= 1
		else:
			for j in range(L[i][1]):
				mx.append(ptr1)
				vismx[ptr1] = 1
				ptr1 += 1
	for i in range(1, len(vismx)):
		if vismx[i] == 0:
			mx.append(i)
			break
	print(*mx)


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def reverse(a, l, r):
	while l < r:
		(a[l], a[r]) = (a[r], a[l])
		r -= 1
		l += 1

def solve():
	for _ in range(ii()):
		(n, s) = map(str, input().split())
		n = int(n)
		a = [i for i in range(n, 0, -1)]
		c = -1
		for i in range(n - 1):
			if s[i] == '>':
				if c != -1:
					reverse(a, c, i)
				c = -1
			elif c == -1:
				c = i
		if c != -1:
			reverse(a, c, n - 1)
		print(*a)
		a = [i for i in range(1, n + 1)]
		c = -1
		for i in range(n - 1):
			if s[i] == '<':
				if c != -1:
					reverse(a, c, i)
				c = -1
			elif c == -1:
				c = i
		if c != -1:
			reverse(a, c, n - 1)
		print(*a)
solve()


def main():
	T = int(input())
	for t in range(T):
		(n, a) = input().split()
		n = int(n)
		ans1 = [0] * n
		l = 0
		while l < n - 1:
			if a[l] == '<':
				r = l
				while r < n - 1 and a[r] == '<':
					r += 1
				x = n - r
				for i in range(l, r + 1):
					ans1[i] = x
					x += 1
				l = r
			l += 1
		x = 1
		for i in range(n - 1, -1, -1):
			if ans1[i] == 0:
				ans1[i] = x
			x += 1
		ans2 = [0] * n
		l = 0
		while l < n - 1:
			if a[l] == '>':
				r = l
				while r < n - 1 and a[r] == '>':
					r += 1
				x = l + 1
				for i in range(r, l - 1, -1):
					ans2[i] = x
					x += 1
				l = r
			l += 1
		x = 1
		for i in range(n):
			if ans2[i] == 0:
				ans2[i] = x
			x += 1
		print(*ans1)
		print(*ans2)
main()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List

def getMinLis(N, S):
	minLis = [0 for _ in range(N)]
	v = N
	i = 0
	while i < N - 1:
		if S[i] == '>':
			while i < N - 1 and S[i] == '>':
				minLis[i] = v
				v -= 1
				i += 1
		else:
			r = i
			while r < N - 1 and S[r] == '<':
				r += 1
			u = v - (r - i)
			v = u - 1
			for j in range(i, r + 1):
				minLis[j] = u
				u += 1
			i = r + 1
	if i < N:
		minLis[i] = v
	return minLis

def getMaxLis(N, S):
	maxLis = [0 for _ in range(N)]
	i = 0
	v = 1
	while i < N - 1:
		if S[i] == '<':
			while i < N - 1 and S[i] == '<':
				maxLis[i] = v
				v += 1
				i += 1
		else:
			r = i
			while r < N - 1 and S[r] == '>':
				r += 1
			u = v + (r - i)
			v = u + 1
			for j in range(i, r + 1):
				maxLis[j] = u
				u -= 1
			i = r + 1
	if i < N:
		maxLis[i] = v
	return maxLis

def solve(N, S):
	return '\n'.join([' '.join(map(str, a)) for a in [getMinLis(N, S), getMaxLis(N, S)]])
T = int(input())
ans = []
for ti in range(T):
	line = input()
	(N, S) = line.split()
	N = int(N)
	ans.append(solve(N, S))
print('\n'.join(ans))


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	(N, S) = map(str, input().rstrip().split())
	Query.append((int(N), list(S)))
for (N, S) in Query:
	L = []
	for (i, s) in enumerate(S):
		if s == '<':
			L.append(i)
	L.append(N - 1)
	Ls = set(L)
	Longans = [-1] * N
	Shortans = [-1] * N
	P = []
	k = []
	pre = -2
	for (i, l) in enumerate(L):
		Longans[l] = i + 1
		if l == pre + 1:
			k.append(l)
		else:
			P.append(k)
			k = [l]
		pre = l
	P.append(k)
	count = 0
	for k in reversed(P):
		for n in k:
			count += 1
			Shortans[n] = count
	for i in reversed(range(N)):
		if not i in Ls:
			count += 1
			Longans[i] = count
			Shortans[i] = count
	print(*Shortans, sep=' ')
	print(*Longans, sep=' ')


for _ in range(int(input())):
	(n, s) = map(str, input().split())
	n = int(n)
	cnt = {'<': 0, '>': 0}
	for i in range(n - 1):
		cnt[s[i]] += 1
	big = n - cnt['<'] + 1
	small = big - 2
	ans1 = [big - 1]
	for i in range(n - 1):
		if s[i] == '<':
			ans1.append(big)
			big += 1
		else:
			ans1.append(small)
			small -= 1
	if cnt['<'] == 0 or cnt['>'] == 0:
		print(*ans1)
		print(*ans1)
		continue
	s += ' '
	big = n
	small = n - cnt['>'] - 1
	used = [0] * (n + 1)
	i = 0
	ans = [0] * (n + 1)
	while i < n:
		add = 0
		t = i
		while s[t] == '<':
			t += 1
			add += 1
		CNT = 0
		for j in range(add):
			ans[i + j] = small - add + 1
			used[small - add + 1] = 1
			add -= 1
			CNT += 1
		small -= CNT
		i = t
		if s[i] == '>':
			ans[i] = big
			used[big] = 1
			big -= 1
		i += 1
	del ans[-1]
	for i in range(1, n + 1):
		if used[i] == 0:
			rest = i
			break
	ans[-1] = rest
	print(*ans)
	print(*ans1)


from bisect import *
from math import *
t = int(input())
for i in range(t):
	(n, inp_str) = input().split()
	n = int(n)
	inp_str = inp_str[0] + inp_str
	count_1 = 0
	for j in inp_str:
		if j == '>':
			count_1 += 1
	count_2 = n - count_1
	count = 0
	arr_min = [-1 for j in range(n)]
	for j in range(n):
		if inp_str[j] == '>':
			arr_min[j] = count_1
			count_1 -= 1
	ind = 0
	temp_count = 0
	while count < count_2:
		ind_u = ind
		while count < count_2 and inp_str[ind_u] == '<':
			count += 1
			temp_count += 1
			ind_u += 1
		if temp_count != 0:
			for j in range(ind_u - 1, ind - 1, -1):
				arr_min[j] = n - count + 1 + (j - ind)
		temp_count = 0
		ind = ind_u
		ind += 1
	arr_min = list(map(str, arr_min))
	out_min = ' '.join(arr_min)
	print(out_min)
	arr_max = [-1 for j in range(n)]
	val = n - count_2 + 1
	for j in range(n):
		if inp_str[j] == '<':
			arr_max[j] = val
			val += 1
	count = 0
	ind = 0
	temp_count = 0
	while count < n - count_2:
		ind_u = ind
		while count < n - count_2 and inp_str[ind_u] == '>':
			count += 1
			temp_count += 1
			ind_u += 1
		if temp_count != 0:
			for j in range(ind_u - 1, ind - 1, -1):
				arr_max[j] = count - (j - ind)
		temp_count = 0
		ind = ind_u
		ind += 1
	arr_max = list(map(str, arr_max))
	out_max = ' '.join(arr_max)
	print(out_max)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(str, input().split())
	n = int(n)
	l = []
	g = []
	buf = [n]
	li = n - 1
	gi = 2
	for i in m:
		if i == '>':
			while buf:
				l.append(buf.pop())
			l.append(li)
			li -= 1
		else:
			buf.append(li)
			li -= 1
	while buf:
		l.append(buf.pop())
	buf = [1]
	for i in range(len(m)):
		if m[i] == '>':
			if l[i] < l[i + 1]:
				(l[i], l[i + 1]) = (l[i + 1], li[i])
		elif l[i] > l[i + 1]:
			(l[i], l[i + 1]) = (l[i + 1], l[i])
	for i in m:
		if i == '<':
			while buf:
				g.append(buf.pop())
			g.append(gi)
			gi += 1
		else:
			buf.append(gi)
			gi += 1
	while buf:
		g.append(buf.pop())
	for i in range(len(m)):
		if m[i] == '>':
			if g[i] < g[i + 1]:
				(g[i], g[i + 1]) = (g[i + 1], g[i])
		elif g[i] > g[i + 1]:
			(g[i], g[i + 1]) = (g[i + 1], g[i])
	print(*l)
	print(*g)


def solve1(n, comps):
	ans = []
	rng = iter(list(range(1, n + 1)))
	for comp in [len(comp) + 1 for comp in comps.split('>')][::-1]:
		ans.append([ansi for (_, ansi) in zip(list(range(comp)), rng)])
	fin_ans = []
	ans.reverse()
	for ansi in ans:
		fin_ans.extend(ansi)
	return fin_ans

def solve2(n, comps):
	ans = []
	rng = iter(list(range(1, n + 1)))
	for comp in [len(comp) + 1 for comp in comps.split('<')]:
		ans.extend([ansi for (_, ansi) in zip(list(range(comp)), rng)][::-1])
	return ans

def main():
	for _ in range(int(input())):
		(n, comps) = input().split()
		n = int(n)
		print(*solve1(n, comps))
		print(*solve2(n, comps))
main()


INF = 10 ** 10

def main():
	print = out.append
	(n, st) = input().split()
	st = list(st)

	def get_lis(li):
		res = [0] * (len(li) + 1)
		p = 1
		for (i, ele) in enumerate(li):
			if ele == '<':
				res[i + 1] = p
				p += 1
		cnt = 0
		s = -li.count('>')
		for (i, ele) in enumerate(li + ['<']):
			if ele == '>':
				cnt += 1
			else:
				p = s + cnt - 1
				for j in range(i - cnt, i):
					res[j + 1] = p
					p -= 1
				s = s + cnt
				cnt = 0
		add = 1 - min(res)
		res = list(map(lambda x: x + add, res))
		return res
	reve = []
	for i in st:
		if i == '<':
			reve.append('>')
		else:
			reve.append('<')
	print(' '.join(map(str, get_lis(reve[::-1])[::-1])))
	print(' '.join(map(str, get_lis(st))))
import sys
from collections import defaultdict, Counter
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


from sys import stdin, stdout
from collections import deque, Counter
from copy import copy
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def main():
	T = int(rl())
	for _ in range(T):
		line = rll()
		(n, s) = (int(line[0]), line[1])
		cnts = Counter(s)
		(D, I) = (cnts['>'], cnts['<'])
		Darr = deque((i for i in range(D, 0, -1)))
		Iarr = deque((i for i in range(D + 1, n + 1)))
		nums = deque((i for i in range(1, n + 1)))
		(runs, L) = ([], 0)
		for R in range(len(s) + 1):
			if R == len(s) or s[R] != s[L]:
				runs.append((R - L, s[L]))
				L = R
		short = [Iarr.popleft()]
		long_ = []
		for (rlen, rtype) in runs:
			local = []
			if rtype == '<':
				for _ in range(rlen):
					local.append(Iarr.pop())
				short.extend(local[::-1])
			else:
				for _ in range(rlen):
					local.append(Darr.popleft())
				short.extend(local)
		for (rlen, rtype) in runs:
			local = []
			if rtype == '<':
				for _ in range(rlen):
					local.append(nums.popleft())
				long_.extend(local)
			else:
				for _ in range(rlen):
					local.append(nums.pop())
				long_.extend(local)
		long_.append(nums.pop())
		ans_short = ' '.join((str(x) for x in short))
		ans_long = ' '.join((str(x) for x in long_))
		stdout.write(str(ans_short))
		stdout.write('\n')
		stdout.write(str(ans_long))
		stdout.write('\n')
	stdout.close()
main()


import sys
input = sys.stdin.readline

def compress(array):
	array2 = sorted(set(array))
	memo = {value: index for (index, value) in enumerate(array2)}
	for i in range(len(array)):
		array[i] = memo[array[i]] + 1
	return array
t = int(input())
base = 10 ** 6
for _ in range(t):
	(n, b) = list(map(str, input().split()))
	n = int(n)
	ans = [0] * n
	now = base
	ans[0] = base
	for i in range(n - 1):
		if b[i] == '>':
			now -= base
			ans[i + 1] = now
		else:
			now += 1
			ans[i + 1] = now
	print(*compress(ans))
	now = base
	ans[0] = base
	for i in range(n - 1):
		if b[i] == '>':
			now -= 1
			ans[i + 1] = now
		else:
			now += base
			ans[i + 1] = now
	print(*compress(ans))


import sys
input = sys.stdin.readline
for __ in range(int(input())):
	s = input().split()[1]
	n = len(s) + 1
	amin = []
	i = 0
	t = n
	while i < n - 1:
		c = s[i]
		if c == '>':
			amin.append(t)
			t -= 1
			i += 1
		else:
			j = i + 1
			while j < n - 1 and s[j] != '>':
				j += 1
			amin.extend(range(t - (j - i), t + 1))
			t -= j - i + 1
			i = j + 1
	if len(amin) < n:
		amin.append(t)
	print(*amin)
	amax = []
	i = 0
	t = 1
	while i < n - 1:
		c = s[i]
		if c == '<':
			amax.append(t)
			t += 1
			i += 1
		else:
			j = i + 1
			while j < n - 1 and s[j] != '<':
				j += 1
			amax.extend(range(t + (j - i), t - 1, -1))
			t += j - i + 1
			i = j + 1
	if len(amax) < n:
		amax.append(t)
	print(*amax)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, S) = input().split()
	n = int(n)
	max_ans = [0] * n
	i = j = 0
	cur = 1
	for s in S + '<':
		if s == '>':
			j += 1
		elif s == '<':
			for k in range(j, i - 1, -1):
				max_ans[k] = cur
				cur += 1
			j += 1
			i = j
	min_ans = [0] * n
	i = j = 0
	cur = 1
	for s in S[::-1] + '>':
		if s == '<':
			j += 1
		elif s == '>':
			for k in range(j, i - 1, -1):
				min_ans[k] = cur
				cur += 1
			j += 1
			i = j
	print(*min_ans[::-1])
	print(*max_ans)


import sys

def reverse_items(seq, reverse_start, reverse_end):
	while reverse_start < reverse_end:
		tmp = seq[reverse_start]
		seq[reverse_start] = seq[reverse_end]
		seq[reverse_end] = tmp
		reverse_start += 1
		reverse_end -= 1

def output_shortest_and_longest(max_number, comp_serial):
	increasing_seq = [str(i) for i in range(1, max_number + 1)]
	decreasing_seq = [s for s in reversed(increasing_seq)]
	continuous_lt_start = None
	continuous_gt_start = None
	last_comp_symbol = comp_serial[0]
	for i in range(0, len(comp_serial)):
		ch = comp_serial[i]
		if ch == '<':
			if continuous_lt_start is None:
				continuous_lt_start = i
			if ch != last_comp_symbol:
				reverse_items(increasing_seq, continuous_gt_start, i)
				continuous_gt_start = None
		else:
			if continuous_gt_start is None:
				continuous_gt_start = i
			if ch != last_comp_symbol:
				reverse_items(decreasing_seq, continuous_lt_start, i)
				continuous_lt_start = None
		last_comp_symbol = ch
	if continuous_lt_start is not None and comp_serial[-1] == '<':
		reverse_items(decreasing_seq, continuous_lt_start, len(comp_serial))
	if continuous_gt_start is not None and comp_serial[-1] == '>':
		reverse_items(increasing_seq, continuous_gt_start, len(comp_serial))
	print(' '.join(decreasing_seq))
	print(' '.join(increasing_seq))

def solve():
	import time
	left_cases = None
	for line in sys.stdin:
		if left_cases is None:
			left_cases = int(line.strip())
		else:
			vals = line.split()
			output_shortest_and_longest(int(vals[0]), vals[1])
			left_cases -= 1
			if left_cases == 0:
				break
solve()


import sys
from itertools import groupby
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, s) = input().split()
	n = int(n)
	good = [0] + list(range(1, n + 1))
	bad = [0] + list(reversed(range(1, n + 1)))
	l = 1
	for (k, g) in groupby(s):
		r = l + len(list(g))
		if k == '>':
			for i in range(l, (r + l) // 2 + 1):
				(good[i], good[r + l - i]) = (good[r + l - i], good[i])
		else:
			for i in range(l, (r + l) // 2 + 1):
				(bad[i], bad[r + l - i]) = (bad[r + l - i], bad[i])
		l = r
	print(*(bad[i] for i in range(1, n + 1)))
	print(*(good[i] for i in range(1, n + 1)))


from collections import *
te = int(input())
for y in range(te):
	(n, s) = input().split()
	n = int(n)
	st = []
	r = n
	st.append(r)
	r -= 1
	for i in range(n - 1):
		if s[i] == '<':
			st.append(r)
			r -= 1
		else:
			while len(st) != 0:
				print(st[-1], end=' ')
				st.pop()
			st.append(r)
			r -= 1
	while len(st) != 0:
		print(st[-1], end=' ')
		st.pop()
	print()
	l = 1
	st.append(l)
	l += 1
	for i in range(n - 1):
		if s[i] == '>':
			st.append(l)
			l += 1
		else:
			while len(st) != 0:
				print(st[-1], end=' ')
				st.pop()
			st.append(l)
			l += 1
	while len(st) != 0:
		print(st[-1], end=' ')
		st.pop()
	print()


Q = int(input())
total = []
for _ in range(Q):
	(n, s) = input().split()
	n = int(n)
	seq = []
	curlen = 1
	for i in range(len(s)):
		if s[i] == '<':
			curlen += 1
		else:
			seq.append(curlen)
			curlen = 1
	seq.append(curlen)
	curr = n
	ans = []
	for sq in seq:
		ans.extend(range(curr - sq + 1, curr + 1))
		curr -= sq
	total.append(' '.join(map(str, ans)))
	curr = n
	ans = [''] * n
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '<':
			ans[i + 1] = str(curr)
			curr -= 1
	for i in range(n):
		if not ans[i]:
			ans[i] = str(curr)
			curr -= 1
	total.append(' '.join(ans))
print(*total, sep='\n')


import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
go = lambda : 1 / 0

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}{}'.format(i, sep))
INF = float('inf')
MOD = int(1000000000.0 + 7)
YES = 'YES'
NO = 'NO'

def intersect(a, b):
	(a, b) = sorted([a, b])
	if a[0] < b[0] and a[1] < b[0]:
		return []
	elif a[0] <= b[0] and a[1] >= b[0]:
		return [b[0], min(a[1], b[1])]
	else:
		print('???')
		raise ConnectionError()
for _ in range(int(input())):
	try:
		(n, s) = input().split()
		n = int(n)
		arr = [[s[0], 1]]
		for i in s[1:]:
			if arr[-1][0] == i:
				arr[-1][1] += 1
			else:
				arr.append([i, 1])
		x = s.count('<')
		ans = []
		a = n
		b = n - x
		if arr[0][0] == '<':
			arr[0][1] += 1
			b -= 1
		else:
			ans.append(b)
			b -= 1
		for (i, j) in arr:
			if i == '<':
				for k in range(a - j + 1, a + 1):
					ans.append(k)
				a = a - j
			else:
				for k in reversed(range(b - j + 1, b + 1)):
					ans.append(k)
				b = b - j
		print(*ans)
		if arr[0][0] == '<':
			arr[0][1] -= 1
		ans = []
		a = n - x
		b = n - x
		if arr[0][0] == '<':
			arr[0][1] += 1
			b -= 1
		else:
			ans.append(b)
			b -= 1
			a += 1
		for (i, j) in arr:
			if i == '<':
				for k in range(a, a + j):
					ans.append(k)
				a = a + j
			else:
				for k in reversed(range(b - j + 1, b + 1)):
					ans.append(k)
				b = b - j
		print(*ans)
	except ZeroDivisionError:
		continue
	except Exception as e:
		print(e)
		continue