There are $n$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.

For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $[0, 3, 2, 3, 4]$, and the value is $0+3+2+3+4=12$.

You are given the initial arrangement of people in the line. For each $k$ from $1$ to $n$, determine the maximum value of the line if you can change the direction of at most $k$ people.


-----Input-----

The input consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 100$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 2\cdot10^5$) — the length of the line.

The following line contains a string consisting of $n$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot10^5$.

Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).


-----Output-----

For each test case, output $n$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $k$ people for each $k$ from $1$ to $n$, inclusive.


-----Examples-----

Input
6
3
LLR
5
LRRLL
1
L
12
LRRRLLLRLLRL
10
LLLLLRRRRR
9
LRLRLRLRL
Output
3 5 5 
16 16 16 16 16 
0 
86 95 98 101 102 102 102 102 102 102 102 102 
29 38 45 52 57 62 65 68 69 70 
44 50 54 56 56 56 56 56 56


-----Note-----

In the first test case:

$k=1$: change the direction of $1$ person to make the line RLR. The total value is $2+1+0=3$.

$k=2$: change the direction of $2$ people to make the line RLL. The total value is $2+1+2=5$.

$k=3$: change the direction of $2$ people to make the line RLL. The total value is $2+1+2=5$. Note that you have to change the direction of at most $k$ people.

In the second test case, it is optimal to only change the direction of the first person for all $k$ from $1$ to $5$ (that is, make the line RRRLL).

Difficulty: EASY

Solutions:
import sys
input = sys.stdin.readline
tests = int(input())
for test in range(tests):
	n = int(input())
	a = input().rstrip()
	if n % 2:
		value = n // 2
	else:
		value = 0
	deltas = []
	for idx in range(n // 2):
		if a[idx] == 'L':
			deltas.append(n - 1 - 2 * idx)
			value += idx
		else:
			value += n - 1 - idx
		if a[-(idx + 1)] == 'R':
			deltas.append(n - 1 - 2 * idx)
			value += idx
		else:
			value += n - 1 - idx
	if deltas:
		deltas.reverse()
	for k in range(n):
		if deltas:
			value += deltas.pop()
		print(value, end=' ')
	print()


def cnt_line(seq):
	cnt = 0
	for i in range(len(seq)):
		if seq[i] == 'R':
			cnt += len(seq) - i - 1
		else:
			cnt += i
	return cnt
n = int(input())
for i in range(n):
	m = int(input())
	s = input()
	init_cnt = cnt_line(s)
	left = 0
	right = m - 1
	k = 0
	while left < right:
		if s[left] == 'R':
			left += 1
		else:
			init_cnt = init_cnt - left + (m - left - 1)
			print(init_cnt, end=' ')
			left += 1
			k += 1
		if left > right:
			break
		if s[right] == 'L':
			right -= 1
		else:
			init_cnt = init_cnt - (m - right - 1) + right
			print(init_cnt, end=' ')
			right -= 1
			k += 1
	while k < m:
		print(init_cnt, end=' ')
		k += 1
	print()


import math

def solve():
	n = int(input())
	lst = list(input())
	lst1 = []
	if n % 2:
		for i in reversed(range(n // 2 + 1, n)):
			lst1.append(i)
		lst1 = lst1 + [n // 2] + lst1[::-1]
	else:
		for i in reversed(range(n // 2, n)):
			lst1.append(i)
		lst1 = lst1 + lst1[::-1]
	lst2 = []
	for i in range(n):
		if lst[i] == 'R':
			lst2.append(n - i - 1)
		else:
			lst2.append(i)
	s1 = sum(lst1)
	s2 = sum(lst2)
	lst3 = []
	for i in range(n):
		lst3.append(lst1[i] - lst2[i])
	lst3.sort(reverse=True)
	for i in range(n):
		s2 += lst3[i]
		print(s2, end=' ')
	print()
t = int(input())
while t:
	t -= 1
	solve()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	line = input()
	score = 0
	possiblity = []
	for i in range(n // 2):
		if line[i] == 'L':
			score += i
			if i < n // 2:
				possiblity.append(n - 1 - 2 * i)
		else:
			score += n - 1 - i
	ind = n // 2
	if n % 2 == 1:
		ind += 1
		score += n // 2
	for i in range(ind, n):
		if line[i] == 'R':
			possiblity.append(2 * i + 1 - n)
			score += n - i - 1
		else:
			score += i
	possiblity.sort(reverse=True)
	diff = n - len(possiblity)
	for i in range(len(possiblity)):
		score += possiblity[i]
		print(score, end=' ')
	for i in range(diff):
		print(score, end=' ')
	print()


def main():
	for t in range(int(input())):
		n = int(input())
		s = input()
		a = []
		ans = 0
		for i in range(n):
			(x, y) = (0, 0)
			if s[i] == 'L':
				x = i
				y = n - 1 - i
			else:
				x = n - 1 - i
				y = i
			ans += x
			a.append(max(0, y - x))
		a.sort(reverse=True)
		for i in range(n):
			ans += a[i]
			print(ans, end=' ')
		print()
main()


for i in range(int(input())):
	n = int(input())
	string = list(input())
	summ = 0
	for i in range(n):
		if string[i] == 'L':
			summ += i
		else:
			summ += n - i - 1
	count = 0
	for i in range(n // 2):
		if string[i] == 'L':
			summ = summ - i + n - i - 1
			print(summ, end=' ')
		else:
			count += 1
		if string[n - i - 1] == 'R':
			summ = summ - i + n - i - 1
			print(summ, end=' ')
		else:
			count += 1
	for i in range(count):
		print(summ, end=' ')
	if n % 2 != 0:
		print(summ, end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	s = input()
	insum = 0
	c = 0
	for i in range(0, n):
		if s[i] == 'L' and i > 0:
			insum = insum + i
		elif s[i] == 'R' and i != n - 1:
			insum = insum + (n - i - 1)
	for i in range(0, n // 2):
		if s[i] == 'L':
			insum = insum - i + (n - i - 1)
			print(insum, end=' ')
			c = c + 1
		if s[n - 1 - i] == 'R':
			insum = insum - i + (n - i - 1)
			print(insum, end=' ')
			c = c + 1
	if c != n:
		for i in range(0, n - c):
			print(insum, end=' ')
	print()
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	line = input()
	initial_score = 0
	scores = []
	for j in range(n):
		if line[j] == 'L':
			initial_score += j
			scores.append(n - 2 * j - 1)
		elif line[j] == 'R':
			initial_score += n - j - 1
			scores.append(2 * j - n + 1)
	scores.sort(reverse=True)
	val = prev_val = initial_score
	for score in scores:
		val += score
		if val > prev_val:
			prev_val = val
		else:
			val = prev_val
		print(val, end=' ')
	print('\r')


def solve():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(input())
		c = []
		tot = 0
		for i in range(1, n + 1):
			if a[i - 1] == 'R':
				tot += n - i
			else:
				tot += i - 1
		for i in range(1, n + 1):
			if a[i - 1] == 'L':
				c.append(n - i - (i - 1))
			else:
				c.append(i - 1 - (n - i))
		c.sort()
		c.reverse()
		for i in range(n):
			if c[i] > 0:
				tot += c[i]
			print(tot, end=' ')
		print()
solve()


for _ in range(int(input())):
	n = int(input())
	string = input()
	change = []
	sum = 0
	for i in range(n):
		if string[i] == 'L':
			change.append(n - 1 - i - i)
			sum += i
		else:
			change.append(i - (n - i - 1))
			sum += n - i - 1
	change.sort(reverse=True)
	for i in change:
		if i > 0:
			sum += i
		print(sum, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	res = []
	total = 0
	for i in range(n):
		if s[i] == 'L':
			res.append(n - 2 * i - 1)
			total += i
		else:
			res.append(2 * i - n + 1)
			total += n - i - 1
	res.sort(reverse=True)
	for v in res:
		if v > 0:
			total += v
		print(total, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	val = 0
	for i in range(n):
		if s[i] == 'L':
			val += i
		else:
			val += n - i - 1
	k = n
	(l, r) = (0, len(s) - 1)
	while k >= 0 and l <= r:
		if s[l] == 'L':
			k -= 1
			val += n - l - 1 - l
			print(val, end=' ')
		l += 1
		if s[r] == 'R':
			k -= 1
			val += r - (n - r - 1)
			print(val, end=' ')
		r -= 1
	for i in range(k):
		print(val, end=' ')
	print()


def solve():
	n = int(input())
	str = input()
	count = []
	count1 = []
	sum = 0
	for i in range(n):
		if str[i] == 'R':
			sum += n - i - 1
		else:
			sum += i
		if i < n - i - 1 and str[i] == 'L':
			count.append(n - 1 - i - i)
		elif i > n - i - 1 and str[i] == 'R':
			count.append(i + i + 1 - n)
	count = sorted(count)[::-1]
	sm = 0
	for i in range(len(count)):
		sm += count[i]
		count1.append(sm + sum)
	for i in range(len(count), n):
		count1.append(sm + sum)
	for i in range(len(count1)):
		print(count1[i], end=' ')
	print()
t = int(input())
for i in range(t):
	solve()


class Line:

	def solve(self, N, arrangement):
		value = 0
		updates = []
		for i in range(N):
			if arrangement[i] == 'L':
				if N - i - 1 > i:
					updates.append(N - 2 * i - 1)
				value += i
			else:
				if i > N - i - 1:
					updates.append(2 * i - N + 1)
				value += N - i - 1
		updates.sort()
		for i in range(1, N + 1):
			if len(updates) > 0:
				value += updates.pop()
			print(value, end=' ')
		print()
		return
T = int(input())
while T:
	T -= 1
	N = int(input())
	arrangement = list(input())
	Line().solve(N, arrangement)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	new_arr = []
	ans = 0
	for i in range(n):
		if s[i] == 'L':
			new_arr.append(n - 1 - i - i)
			ans += i
		else:
			new_arr.append(i - (n - 1 - i))
			ans += n - 1 - i
	new_arr.sort()
	for i in new_arr[::-1]:
		if i >= 0:
			ans += i
			print(ans, end=' ')
		else:
			print(ans, end=' ')
	print()


from collections import Counter

def main():
	for _ in range(int(input())):
		n = int(input())
		string = input()
		half = n // 2
		arr = []
		for i in range(n):
			if string[i] == 'L':
				arr.append(i)
			else:
				arr.append(n - i - 1)
		arr.sort()
		sm = sum(arr)
		ans = []
		for i in range(n):
			if arr[i] < half:
				sm -= arr[i]
				sm += n - arr[i] - 1
				ans.append(sm)
			else:
				ans.append(sm)
		for i in ans:
			print(i, end=' ')
		print()
main()


t = int(input())
for i in range(t):
	n = int(input())
	q = input()
	l = len(q)
	m = l // 2
	it = 0
	for k in range(l):
		if q[k] == 'L':
			it += k
		else:
			it += l - k - 1
	c = 0
	for k in range(m):
		if q[k] == 'L':
			it += l - k - 1 - k
			print(it, end=' ')
			c += 1
		if q[l - k - 1] == 'R':
			it += l - k - 1 - (l - (l - k - 1) - 1)
			print(it, end=' ')
			c += 1
	for ee in range(l - c):
		print(it, end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	line = input()
	ans = 0
	change = [0] * n
	for i in range(n):
		if line[i] == 'L':
			ans += i
			change[i] = n - i - 1 - i
		else:
			ans += n - i - 1
			change[i] = i - (n - i - 1)
	change.sort()
	for i in range(n - 1, -1, -1):
		if change[i] > 0:
			ans += change[i]
		print(ans, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = input()
	ans = 0
	for i in range(n):
		if s[i] == 'L':
			ans += i
		else:
			ans += n - i - 1
	a = []
	for i in range(n // 2):
		if s[i] == 'L':
			a.append(n - i - i - 1)
		else:
			a.append(0)
	if n % 2 != 0:
		a.append(0)
	for i in range((n + 1) // 2, n):
		if s[i] == 'R':
			a.append(i - n + i + 1)
		else:
			a.append(0)
	a.sort(reverse=True)
	for x in a:
		ans += x
		print(ans, end=' ')
	print('')


for Pythonic__Python in range(int(input())):
	n = int(input())
	d = input()
	l = []
	ans = 0
	for i in range(n):
		if d[i] == 'L':
			l.append(n - 1 - i - i)
			ans += i
		else:
			l.append(i - (n - 1 - i))
			ans += n - 1 - i
	l.sort()
	for i in l[::-1]:
		if i >= 0:
			ans += i
			print(ans, end=' ')
		else:
			print(ans, end=' ')
	print()


testcase = int(input())
for _ in range(testcase):
	n = int(input())
	line = input()
	turnaround = list()
	originalsum = 0
	for i in range(n):
		if line[i] == 'L':
			turnaround.append(n - 1 - i - i)
			originalsum += i
		else:
			turnaround.append(i - (n - 1 - i))
			originalsum += n - 1 - i
	turnaround.sort(reverse=True)
	for i in range(n):
		if turnaround[i] > 0:
			originalsum += turnaround[i]
		print(originalsum, end=' ')
	print()


t = int(input())
for o in range(t):
	n = int(input())
	a = [0 for i in range(n)]
	s = input()
	(num, idx, ans) = (0, -1, 0)
	for j in range(n):
		if s[j] == 'L':
			num += j
			a[j] = n - j * 2 - 1
		else:
			num += n - j - 1
			a[j] = j * 2 + 1 - n
	a.sort()
	for i in range(n - 1, -1, -1):
		if a[i] > 0:
			num += a[i]
		print(num, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	line = 'R' * (n // 2) + ('R' if n % 2 == 1 else '') + 'L' * (n // 2)
	(b, e) = (0, len(s) - 1)
	k = 1
	res = sum([i if c == 'L' else n - i - 1 for (i, c) in enumerate(s)])
	while b < e:
		if (s[b], s[e]) == ('L', 'R'):
			res += n - 2 * b - 1
			b += 1
			print(res, end=' ')
			k += 1
			res += 2 * e - n + 1
			e -= 1
			print(res, end=' ')
			k += 1
		elif (s[b], s[e]) == ('R', 'R'):
			res += 2 * e - n + 1
			print(res, end=' ')
			b += 1
			e -= 1
			k += 1
		elif (s[b], s[e]) == ('L', 'L'):
			res += n - 2 * b - 1
			print(res, end=' ')
			b += 1
			e -= 1
			k += 1
		else:
			b += 1
			e -= 1
	for _ in range(n - k + 1):
		print(res, end=' ')
	print()


def getDifference(people):
	n = len(people)
	result = []
	for (index, person) in enumerate(people):
		if person == 'L':
			result.append(n - index - 1 - index)
		else:
			result.append(index - (n - index - 1))
	result.sort(reverse=True)
	return result

def getCurrentSum(people):
	n = len(people)
	totalSum = 0
	for (index, person) in enumerate(people):
		if person == 'L':
			totalSum += index
		else:
			totalSum += n - index - 1
	return totalSum
t = int(input())
for _ in range(t):
	n = int(input())
	people = list(input())
	oldSum = getCurrentSum(people=people)
	diffList = getDifference(people=people)
	for k in range(n):
		if diffList[k] > 0:
			currSum = oldSum + diffList[k]
		else:
			currSum = oldSum
		print(currSum, end=' ')
		oldSum = currSum
	print('')


for t in range(int(input())):
	n = int(input())
	s = input()
	a = []
	count = 0
	for i in range(n):
		l = i
		r = n - i - 1
		if s[i] == 'L':
			a.append(r - l)
			count += l
		else:
			a.append(l - r)
			count += r
	a = sorted(a, reverse=True)
	for i in range(n):
		if a[i] > 0:
			count += a[i]
		print(count, end=' ')
	print()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	string = str(input())
	lst = []
	curr_score = 0
	for i in range(len(string)):
		if string[i] == 'L':
			curr_score += i
			itm = n - i - 1 - i
		else:
			curr_score += n - i - 1
			itm = i - n + i + 1
		if n % 2 != 0 and i == int(n / 2):
			lst.append(0)
		else:
			lst.append(itm)
	lst.sort(reverse=True)
	for i in range(n):
		if lst[i] > 0:
			curr_score += lst[i]
		print(curr_score, end=' ')
	print()