Luca has a cypher made up of a sequence of $n$ wheels, each with a digit $a_i$ written on it. On the $i$-th wheel, he made $b_i$ moves. Each move is one of two types:

up move (denoted by ${U}$): it increases the $i$-th digit by $1$. After applying the up move on $9$, it becomes $0$.

down move (denoted by ${D}$): it decreases the $i$-th digit by $1$. After applying the down move on $0$, it becomes $9$.

Example for $n=4$. The current sequence is 0 0 0 0.

Luca knows the final sequence of wheels and the moves for each wheel. Help him find the original sequence and crack the cypher.


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 100$) — the number of wheels.

The second line contains $n$ integers $a_i$ ($0 \leq a_i \leq 9$) — the digit shown on the $i$-th wheel after all moves have been performed.

Then $n$ lines follow, the $i$-th of which contains the integer $b_i$ ($1 \leq b_i \leq 10$) and $b_i$ characters that are either ${U}$ or ${D}$ — the number of moves performed on the $i$-th wheel, and the moves performed. ${U}$ and ${D}$ represent an up move and a down move respectively.


-----Output-----

For each test case, output $n$ space-separated digits  — the initial sequence of the cypher.


-----Examples-----

Input
3
3
9 3 1
3 DDD
4 UDUU
2 DU
2
0 9
9 DDDDDDDDD
9 UUUUUUUUU
5
0 5 9 8 3
10 UUUUUUUUUU
3 UUD
8 UUDUUDDD
10 UUDUUDUDDU
4 UUUU
Output
2 1 1 
9 0 
0 4 9 6 9


-----Note-----

In the first test case, we can prove that initial sequence was $[2,1,1]$. In that case, the following moves were performed:

On the first wheel: $2 \xrightarrow[{D}]{} 1 \xrightarrow[{D}]{} 0 \xrightarrow[{D}]{} 9$.

On the second wheel: $1 \xrightarrow[{U}]{} 2 \xrightarrow[{D}]{} 1 \xrightarrow[{U}]{} 2 \xrightarrow[{U}]{} 3$.

On the third wheel: $1 \xrightarrow[{D}]{} 0 \xrightarrow[{U}]{} 1$.

The final sequence was $[9,3,1]$, which matches the input.

Difficulty: EASY

Solutions:
fptr = open(0)
for _ in range(int(next(fptr))):
	n = int(next(fptr))
	a = list(map(int, next(fptr).split()))
	for i in range(n):
		(n1, s) = next(fptr).split()
		count = 0
		count += s.count('D')
		count -= s.count('U')
		a[i] += count
		if a[i] > 9 or a[i] < 0:
			a[i] %= 10
	for i in a:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(n):
		(x, y) = input().split()
		D = y.count('D')
		U = y.count('U')
		b.append(D - U)
	for (x, y) in zip(a, b):
		print((10 + x + y) % 10, end=' ')
	print()


t = int(input())
for i in range(1, t + 1):
	n = int(input())
	a = input()
	o = ''
	for j in range(n):
		s = input()
		o += str((int(a[2 * j]) - s.count('U') + s.count('D')) % 10) + ' '
	print(o)


t = int(input())
for r in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = ''
	for i in range(n):
		(n, s) = input().split()
		d = s.count('D') % 10
		u = s.count('U') % 10
		if d > u:
			d = d - u
			ans += str((a[i] + d) % 10) + ' '
		else:
			u = u - d
			ans += str((a[i] - u) % 10) + ' '
	print(ans)


def after_rotation(number, stri, b):
	for i in stri:
		if i == 'D':
			number += 1
		elif i == 'U':
			number -= 1
	pre_value = number % 10
	return pre_value
t = int(input())
while t > 0:
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	answer_string = ''
	for i in range(n):
		(b, s) = input().split(' ')
		b = int(b)
		value = after_rotation(numbers[i], s, b)
		answer_string += str(value) + ' '
	print(answer_string)
	t -= 1


t = int(input())

def logic(x, curr):
	rem = x % 10
	curr += rem
	if curr > 9:
		ans = curr - 10
		return ans
	if curr < 0:
		ans = curr + 10
		return ans
	return curr
for test in range(t):
	reels = int(input())
	final = list(map(int, input().split()))
	breaked = ''
	for i in range(reels):
		curr = final[i]
		(step, code) = input().split()
		step = int(step)
		(d, u) = (code.count('D'), code.count('U'))
		x = d - u
		if x == 0:
			ans = curr
		else:
			ans = logic(x, curr)
		digit = str(curr + ans)
		breaked += str(ans) + ' '
	print(breaked)


def main():
	n = int(input())
	d = [int(p) for p in input().split()]
	for pos in range(n):
		(_, ops) = input().split()
		cnt = 0
		for op in ops:
			cnt += 1 if op == 'D' else -1
		cnt = (cnt + 10) % 10
		d[pos] = (d[pos] + cnt) % 10
	for j in d:
		print(j, end=' ')
	print()
t = int(input())
for i in range(t):
	main()


for i in range(int(input())):
	s = int(input())
	k = list(map(int, input().split()))
	for j in range(s):
		a = input().split()
		x = len(a[1].replace('D', ''))
		y = len(a[1].replace('U', ''))
		if x > y:
			v = x - y
			if v > k[j]:
				k[j] = (k[j] - v % 10 + 10) % 10
			else:
				k[j] = k[j] - v % 10
		else:
			v = y - x
			k[j] = (k[j] + v) % 10
	for j in range(s):
		print(k[j], end=' ')
	print()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	current = list(map(int, input().split()))
	for i in range(n):
		(b, s) = input().split()
		temp = s.count('D')
		change = abs(int(b) - temp - temp)
		if int(b) - temp > temp:
			if change > current[i]:
				current[i] = 10 - (change - current[i])
			else:
				current[i] = current[i] - change
		elif change + current[i] <= 9:
			current[i] = current[i] + change
		else:
			current[i] = change + current[i] - 10
	for i in current:
		print(i, end=' ')
	print()


def problem():
	lSize = int(input())
	finalCombination = list(map(int, input().split()))
	ans = []
	for ele in finalCombination:
		(n, steps) = input().split()
		n = int(n)
		steps = list(steps)
		for step in steps:
			if step == 'D':
				ele = ele + 1
				if ele == 10:
					ele = 0
			else:
				ele = ele - 1
				if ele == -1:
					ele = 9
		ans.append(ele)
	for ele in ans:
		print(ele, end=' ')
	print()
	return
t = int(input())
while t:
	problem()
	t = t - 1


for i in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	for i in range(len(lst)):
		x = input()
		(a, b) = x.split(' ')
		lstt1 = []
		lstt2 = []
		for j in b:
			if j == 'U':
				lstt1.append(j)
			elif j == 'D':
				lstt2.append(j)
		xor = lst[i] + len(lstt2)
		lst[i] = xor
		xrr = lst[i] - len(lstt1)
		lst[i] = xrr
	for i in lst:
		if i > 9:
			i -= 10
		elif i < 0:
			i += 10
		print(i, end=' ')
	print()


t = int(input())

def solve(s, e):
	earr = [char for char in e]
	for ele in earr:
		if ele == 'D':
			if s == 9:
				s = 0
			else:
				s = s + 1
		elif ele == 'U':
			if s == 0:
				s = 9
			else:
				s = s - 1
	return s
for i in range(t):
	no_wheel = int(input())
	final_seq = [int(i) for i in input().split(' ')]
	a = 0
	res_arr = []
	for seq in final_seq:
		arr = [i for i in input().split(' ')]
		res_arr.append(solve(seq, arr[1]))
	for i in res_arr:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	final = list(map(int, input().split()))
	for i in range(n):
		arr = input().split()[1]
		arr = list(arr)
		res = arr.count('D') - arr.count('U')
		final[i] += res
		final[i] %= 10
	for val in final:
		print(val, end=' ')
	print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	wheels = list(map(int, input().split()))
	for i in range(n):
		[seqLength, seq] = input().split()
		for each in seq:
			if each == 'U':
				wheels[i] -= 1
				if wheels[i] < 0:
					wheels[i] = 9
			else:
				wheels[i] += 1
				if wheels[i] > 9:
					wheels[i] = 0
	for each in wheels:
		print(each, end=' ')
	print()


t = int(input())
for i in range(t):
	n_d = int(input())
	digit_lst = list(map(int, input().split()))
	new_lst = []
	for i in range(n_d):
		(moves, s) = input().split()
		moves = int(moves)
		for ele in s:
			if digit_lst[i] == 9 and ele == 'D':
				digit_lst[i] = 0
				continue
			if digit_lst[i] == 0 and ele == 'U':
				digit_lst[i] = 9
				continue
			if ele == 'U':
				digit_lst[i] -= 1
				continue
			if ele == 'D':
				digit_lst[i] += 1
				continue
	new_s = ''
	for ele in digit_lst:
		new_s = new_s + str(ele) + ' '
	print(new_s)


t = int(input())
a = 1
while t > 0:
	t = t - 1
	n = int(input())
	if a == 1:
		l1 = list(map(int, input().split()))
	for i in range(n):
		if a == 1:
			n = n - 1
		(m, s) = input().split()
		l1[i] = (l1[i] + s.count('D') - s.count('U')) % 10
	for j in l1:
		print(j, end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	l = []
	for i in range(n):
		s = input()
		k = int(s[0])
		l.append(s[2:])
	for i in range(n):
		i1 = l[i].count('U')
		i2 = l[i].count('D')
		c = abs(i1 - i2)
		if i1 > i2:
			d = arr[i] - c
			if d < 0:
				print(10 + d, end=' ')
			else:
				print(d, end=' ')
		elif i1 == i2:
			print(arr[i], end=' ')
		else:
			p = arr[i] + c
			if p >= 10:
				print(abs(10 - p), end=' ')
			else:
				print(p, end=' ')
	print()
	t -= 1


def solve(l, q):
	res = []
	for i in range(len(l)):
		res.append((l[i] - q[i].count('U') + q[i].count('D')) % 10)
	return res

def main():
	t = int(input())
	l = []
	res = []
	for i in range(t):
		temp = []
		q = []
		n = int(input())
		temp = input()
		temp = temp.split()
		for i in range(n):
			temp[i] = int(temp[i])
		for j in range(n):
			line = input()
			line = line.split()
			q.append(line[1])
		res.append(solve(temp, q))
	for a in res:
		for k in a:
			print(k, end=' ')
		print()
main()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	for j in range(n):
		t = input().split()
		t = t[1]
		temp = l[j]
		for k in t:
			if k == 'U':
				if temp == 0:
					temp = 9
				else:
					temp -= 1
			elif temp == 9:
				temp = 0
			else:
				temp += 1
		l[j] = temp
	for k in l:
		print(k, end=' ')
	print()


def f(arr, n, steps):
	ans = []
	for i in range(n):
		temp = arr[i]
		st = steps[i]
		for j in st:
			if j == 'D':
				if temp == 9:
					temp = 0
				else:
					temp += 1
			elif j == 'U':
				if temp == 0:
					temp = 9
				else:
					temp -= 1
		ans.append(temp)
	return ans
for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	steps = []
	for i in range(n):
		a = [i for i in input().split()]
		steps.append(a[1])
	ans = f(arr, n, steps)
	for i in ans:
		print(i, end=' ')
	print()