Aureole the Techno-cultural fest of JEC thought of conducting a workshop on big data, as the topic is hot everyone wants to take part but due to limited seats in the Jashan Auditorium there is a selection criteria, a problem is given.
the problem states a string is to be compressed when two or more consecutive characters are same they are to be compressed into one character and the original number count is to be written after it ex. aaabb -> a3b2
where every character is of 8bits and every integer is of 32bits
you are asked to find the difference in size between original string and compressed string

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input $S$ the string to be compressed. 

-----Output:-----
For each testcase, output in a single line The difference in size.

-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq |S| \leq 10^5$

-----Subtasks-----
- 40 points : S will contain only a-z
- 60 points : S will contain 0-9 characters also

-----Sample Input:-----
1
aaabb

-----Sample Output:-----
-40

-----EXPLANATION:-----
the resulting string will be a3b2 its size will be 80, original string size will be 40 so ans= 40-80

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
for _ in range(int(input())):
	s = input()
	n = len(s)
	if n == 1:
		if s[0].isalpha():
			print('-32')
		else:
			print(0)
	else:
		(num, ch) = (0, 0)
		(p, q) = (0, 0)
		c = 1
		x = s[0]
		ans = ''
		for i in range(1, n):
			if s[i - 1] == s[i]:
				c += 1
				if i == n - 1:
					ans += s[i - 1]
					ch += 1
					if c > 1:
						ans += str(c)
						num += 1
					c = 1
			else:
				ans += s[i - 1]
				ch += 1
				if c > 1:
					ans += str(c)
					num += 1
				c = 1
				if i == n - 1:
					ans += s[i]
					ch += 1
		sol = n * 8 - (num * 32 + ch * 8)
		print(sol)


t = int(input())
for _ in range(t):
	s = input()
	x = ''
	i = 0
	ans = 0
	while i < len(s):
		x = s[i]
		c = 1
		i += 1
		while i < len(s) and s[i] == x:
			i += 1
			c += 1
		if c == 1:
			ans += 8
		else:
			ans += 40
	m = 8 * len(s)
	print(m - ans)


t = int(input())
while t > 0:
	c = input()
	len1 = len(c)
	sum1 = 0
	l = []
	for i in range(len1):
		sum1 += 8
	sum2 = 8
	q = 1
	for i in range(1, len1):
		if c[i] != c[i - 1]:
			if q > 1:
				sum2 += 32
			q = 1
			sum2 += 8
		else:
			q += 1
	if q > 1:
		sum2 += 32
	print(sum1 - sum2)
	t -= 1


def compress(a):
	prev = None
	prev_c = 1
	ans_s = ''
	k = 0
	for x in a:
		if prev == x:
			prev_c += 1
		else:
			if prev != None:
				if prev_c != 1:
					ans_s = ans_s + str(prev) + str(prev_c)
					k += 40
				else:
					ans_s = ans_s + str(prev)
					k += 8
			prev_c = 1
			prev = x
	if prev_c != 1:
		ans_s = ans_s + str(prev) + str(prev_c)
		k += 40
	else:
		ans_s = ans_s + str(prev)
		k += 8
	return k
t = int(input())
while t:
	t = t - 1
	a = input()
	ans = compress(a)
	size = 8 * len(a)
	print(size - ans)


for _ in range(int(input())):
	s = input()
	curr = 0
	for i in range(len(s)):
		if s[i].isdigit():
			curr = curr + 32
		else:
			curr = curr + 8
	c = s[0]
	ans = s[0]
	count = 0
	d = dict()
	if c.isdigit():
		curr2 = 32
	else:
		curr2 = 8
	for i in range(len(s)):
		if c == s[i]:
			count += 1
		else:
			c = s[i]
			if count != 1:
				ans = ans + str(count)
				curr2 += 32
			ans = ans + str(s[i])
			if s[i].isdigit():
				curr2 += 32
			else:
				curr2 += 8
			count = 1
	if count != 1:
		ans = ans + str(count)
		curr2 += 32
	print(curr - curr2)


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	sm = 1
	total = 0
	for j in range(1, l):
		if s[j - 1] == s[j]:
			sm += 1
		else:
			if sm == 1:
				total += 8
			else:
				total += 8
				total = total + 32
			sm = 1
	if s[j - 1] == s[j]:
		sm += 1
		total += 8
		total = total + 32
	elif sm == 1:
		total += 8
	else:
		total += 8
		total = total + 32
	print(l * 8 - total)


t = int(input())
while t:
	t -= 1
	string = input()
	l = len(string)
	temp = string[0]
	occ = 1
	pre = 0
	this = 0
	for i in range(1, l):
		if string[i] == temp:
			occ += 1
		else:
			if occ != 1:
				pre += occ * 8
				this += 40
			else:
				pre += 8
				this += 8
			occ = 1
			temp = string[i]
	if occ == 1:
		pre += 8
		this += 8
	else:
		pre += 8 * occ
		this += 40
	print(pre - this)


for _ in range(int(input())):
	s = input()
	size1 = 8 * len(s)
	size2 = 8
	i = 1
	while i < len(s):
		if s[i] == s[i - 1]:
			while s[i] == s[i - 1]:
				i += 1
				if i >= len(s):
					break
			size2 += 32
		else:
			size2 += 8
			i += 1
	print(size1 - size2)


n = int(input())
for i in range(n):
	s = str(input())
	o_l = len(s) * 8
	n_l = 0
	t = 0
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			t += 1
		else:
			if t >= 1:
				n_l += 32 + 8
			else:
				n_l += 8
			t = 0
	if t >= 1:
		n_l += 32 + 8
	else:
		n_l += 8
	print(o_l - n_l)


temp = []
t = int(input())
for _ in range(t):
	s = input()
	l = list(s)
	x = len(l) * 8
	i = 0
	y = 0
	while i < len(l):
		count = 0
		while i < len(l) - 1 and l[i] == l[i + 1]:
			count += 1
			i += 1
		if count == 0:
			y += 8
		else:
			y += 40
		i = i + 1
	temp.append(x - y)
for i in temp:
	print(i)


from collections import Counter
for _ in range(int(input())):
	S = list(map(str, input()))
	original = 8
	new = 0
	if S[0].isdigit():
		original = 32
	lst = [S[0]]
	lst1 = [1]
	b = 0
	for i in range(1, len(S)):
		if S[i].isdigit():
			original += 32
		else:
			original += 8
		if S[i] == lst[-1]:
			lst1[-1] += 1
		else:
			lst.append(S[i])
			lst1.append(1)
	for i in range(len(lst)):
		if lst[i].isdigit():
			if lst1[i] > 1:
				new += 64
			else:
				new += 32
		elif lst1[i] > 1:
			new += 40
		else:
			new += 8
	print(original - new)


from collections import Counter
for _ in range(int(input())):
	S = list(map(str, input()))
	original = 8
	new = 8
	if S[0].isdigit():
		original = 32
		new = 32
	a = S[0]
	b = 0
	for i in range(1, len(S)):
		if S[i].isdigit():
			original += 32
		else:
			original += 8
		if S[i] == a:
			b = 32
		else:
			new += b
			b = 0
			a = S[i]
			if S[i].isdigit():
				new += 32
			else:
				new += 8
	new += b
	print(original - new)


try:
	for _ in range(int(input())):
		s = input()
		l = len(s)
		k = 8 * l
		p = 8
		t = 0
		for i in range(1, l):
			if s[i] == s[i - 1]:
				if t == 0:
					p += 32
					t = 1
			else:
				p += 8
				t = 0
		print(k - p)
except EOFError as e:
	pass


test = int(input())
for t in range(test):
	s = input()
	prev = s[0]
	total = 0
	count = 0
	for i in s:
		if i == prev:
			count += 1
		else:
			if count == 0 or count == 1:
				total += 8
			else:
				total += 40
			count = 1
		prev = i
	if s[len(s) - 1] == s[len(s) - 2]:
		total += 40
	else:
		total += 8
	diff = len(s) * 8 - total
	print(diff)


def fac(a):
	s = 1
	for i in range(1, a + 1):
		s = s * i
	return s

def prime(n):
	n = int(n)
	if n == 2 or n == 3:
		return 1
	k = n ** (1 / 2)
	for i in range(2, int(k) + 2):
		if n % i == 0:
			return 0
	return 1

def sieve(n):
	arr = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n):
		if prime[p]:
			arr.append(p)
	return arr
t = int(input())
for ii in range(t):
	s = input()
	prev = s[0]
	ss = []
	c = 1
	for i in s[1:]:
		if i != prev:
			if c == 1:
				ss.append('p' + prev)
			else:
				ss.append('p' + prev)
				ss.append(str(c))
			prev = i
			c = 1
		else:
			c += 1
	if c == 1:
		ss.append('p' + prev)
	else:
		ss.append('p' + prev)
		ss.append(str(c))
	hah = '0987654321'
	s1 = 0
	s2 = 0
	s1 = 8 * len(s)
	for i in ss:
		if i[0] in hah:
			s2 += 32
		else:
			s2 += 8
	print(s1 - s2)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return list(map(int, stdin.readline().split()))

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		s = input()
		st = s[0]
		i = 1
		(c1, c2) = (1, 0)
		while i < len(s):
			if s[i] == s[i - 1]:
				j = i
				c = 0
				while j < len(s) and s[j] == s[i - 1]:
					c += 1
					j += 1
				if c != 0:
					c2 += 1
					i = j - 1
					st += str(c + 1)
			else:
				st += s[i]
				c1 += 1
			i += 1
		print(len(s) * 8 - (c1 * 8 + c2 * 32))

def __starting_point():
	main()
__starting_point()