Problem Statement
It is 2042 and we are surrounded by cyborgs everywhere. Geneo is one such cyborg with a human body and an electronic brain. To monitor skills and health of Geneo he is posed with questions everyday. On one fine day Geneo was asked the following question.

You are given a string S of size N containing letters a to z. You are allowed to remove a character from the string and exchange it for a number signifying its position. i.e a -> 1, b -> 2, c -> 3, ... z -> 26. After some number of these operations you arrive at a final array A.

Power P of any such array is defined as: 
count of letters - count of numbers + (sum of numbers/K)
where K is a given integer and '/' denotes float division.

Geneo has to find maximum possible power P_{max} of such an array.
You want to test if Geneo is right. For this you have to generate correct answers for the question.

------ Input section ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of each test case contains a two space separated integers N and K.

The second line of each test case contains the string S of size N.

------ Output Section ------ 

For each test case, output a single line containing two space seperated integers a and b such that a / b = P_{max} - the maximum possible power achievable after transformation and gcd(a,b) = 1.

------ Input constraints ------ 

1 ≤ T ≤ 100
1 ≤ N ≤ 1000
1 ≤ K ≤ 1000

----- Sample Input 1 ------ 
2
10 6
abcdefghij
10 1
qwertyuiop
----- Sample Output 1 ------ 
10 1
159 1
----- explanation 1 ------ 
For the first test case, if we replace no character, we get an array comprising of letters only. This gives us the maximum power 10.

For the second test case, we get maximum power when we replace all the characters by respective numbers.

Difficulty: MEDIUM_HARD
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
from math import gcd

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

def si():
	return input().split()

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

def ip():
	return input()
dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
for tastcas in range(int(input())):
	(n, k) = li()
	a = ip()
	kk = 2 * k
	ans = n * k
	for i in a:
		if dic[i] > kk:
			ans += dic[i] - kk
	p = ans
	q = k
	g = gcd(p, q)
	print(p // g, q // g)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	ans = n * k
	for j in s:
		v = ord(j) - 96
		if v > 2 * k:
			ans += v - 2 * k
	n = ans
	d = k
	gcd = math.gcd(n, d)
	n //= gcd
	d //= gcd
	print(str(n) + ' ' + str(d))


import math
tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	s = input()
	ans = n * k
	for ch in s:
		val = ord(ch) - 96
		if val > 2 * k:
			ans += val - 2 * k
	num = ans
	den = k
	gcd = math.gcd(num, den)
	num = num // gcd
	den = den // gcd
	print(str(num) + ' ' + str(den))


import itertools

def map_to_values(s):
	return ord(s.lower()) - 71 - 25

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def a_b(Mpow, K):
	d = gcd(Mpow, K)
	Mpow //= d
	K //= d
	print(Mpow, K)
	pass

def max_power(S, K):
	S = list(S)
	S.sort()
	S.reverse()
	''.join(S)
	count_of_letters = len(S)
	count_of_numbers = 0
	sum_of_numbers = 0
	Mpow = len(S)
	for s in S:
		if count_of_letters - 1 - (count_of_numbers + 1) + (sum_of_numbers + map_to_values(s)) / K > Mpow:
			Mpow = count_of_letters - 1 - (count_of_numbers + 1) + (sum_of_numbers + map_to_values(s)) / K
			count_of_letters += -1
			count_of_numbers += 1
			sum_of_numbers += map_to_values(s)
		else:
			break
	a_b(K * (count_of_letters - count_of_numbers) + sum_of_numbers, K)
	pass
T = int(input().strip())
for i in range(T):
	lst = list(map(int, input().strip().split(' ')))
	N = lst[0]
	K = lst[1]
	S = input().strip()
	max_power(S, K)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
t = int(input())
for j in range(t):
	(n, k) = map(int, input().split(' ', 2)[:2])
	s = input()
	sum1 = 0
	icnt = 0
	ccnt = n
	for a in s:
		if (ord(a) - 96) / k > 2:
			icnt += 1
			ccnt -= 1
			sum1 += ord(a) - 96
	if sum1 % k == 0:
		ans = sum1 // k + ccnt - icnt
		print(ans, 1)
	else:
		gc = gcd(sum1 + k * (ccnt - icnt), k)
		ans = (sum1 + k * (ccnt - icnt)) // gc
		print(ans, k // gc)


from math import gcd
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = input()
	a = list(a)
	a.sort()
	power = n
	temp = n
	lettr = 0
	sum_n = 0
	for x in range(n - 1, -1, -1):
		lettr = ord(a[x]) - ord('a') + 1
		if lettr > 2 * k:
			sum_n += lettr
			temp -= 2
	power = k * temp + sum_n
	d = gcd(power, k)
	power /= d
	k /= d
	print(int(power), int(k))


from math import gcd
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	S = input()
	P = N
	cnt = 0
	num = 0
	for x in S:
		if ord(x) - 96 > 2 * K:
			num += ord(x) - 96
			cnt += 1
	P -= 2 * cnt
	f1 = P * K + num
	f2 = K
	d = gcd(f1, f2)
	f1 = f1 // d
	f2 = f2 // d
	print(f1, f2)


from sys import setrecursionlimit as limits
limits(10 ** 5)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	string = [x for x in input().strip()]
	string.sort(reverse=True)
	(m, s, nums, letters, sumNumbers, whole) = (n, 0, 0, n, 0, n)
	for i in range(n):
		ch = string[i]
		s += ord(ch) - 96
		curr = n - i - 1 - (i + 1) + s / k
		if m < curr:
			m = curr
			whole = n - i - 1 - (i + 1)
			sumNumbers = s
		(letters, nums) = (letters - 1, nums + 1)
	if sumNumbers % k == 0:
		print(whole + sumNumbers // k, 1)
	else:
		sumNumbers += k * whole
		_gcd = gcd(sumNumbers, k)
		print(sumNumbers // _gcd, k // _gcd)
	t -= 1


import sys
sys.setrecursionlimit(100000)

def gcd(a, b):
	if a == 0 or b == 0:
		False
	if a == b:
		return a
	if a > b:
		return gcd(a - b, b)
	return gcd(a, b - a)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	d = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	for i in s:
		d[i] += 1
	characters = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']
	ans = [n]
	fraction = [[n, 1]]
	summ = 0
	count = 0
	for i in characters:
		for j in range(d[i]):
			summ += ord(i) - ord('a') + 1
			count += 1
			ans.append(n - 2 * count + summ / k)
			fraction.append([k * (n - 2 * count) + summ, k])
	iii = ans.index(max(ans))
	if fraction[iii][0] > fraction[iii][1]:
		ggg = gcd(fraction[iii][0], fraction[iii][1])
	else:
		ggg = gcd(fraction[iii][0], fraction[iii][1])
	print(fraction[iii][0] // ggg, fraction[iii][1] // ggg)


from math import gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	pmax = n * k
	temp = list(input())
	str = [ord(x) - ord('a') + 1 - 2 * k for x in temp]
	for i in range(n):
		if str[i] > 0:
			pmax += str[i]
	print(pmax // gcd(pmax, k), k // gcd(pmax, k))


from fractions import Fraction
import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	S = input().strip()
	S = [ord(c) - 96 for c in S]
	S.sort()
	num = Fraction(n)
	s = 0
	t = 0
	index = n - 1
	while index >= 0 and S[index] / k >= 2:
		s += S[index]
		index -= 1
		t += 1
	num = (n - 2 * t) * k + s
	x = math.gcd(k, num)
	print(num // x, k // x)


from fractions import Fraction
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	S = input().strip()
	S = [ord(c) - 96 for c in S]
	S.sort(reverse=True)
	num = Fraction(n)
	s = 0
	for i in range(n):
		s += S[i]
		num = max(num, n - 2 * (i + 1) + Fraction(s, k))
	print(num.numerator, num.denominator)


from fractions import gcd

def fun():
	(n, k) = map(int, input().split())
	l = list(input())
	su = 0
	for i in l:
		t = ord(i) - 96
		if t > 2 * k:
			n -= 2
			su += t
	s = n * k + su
	g = 0
	g = gcd(s, k)
	print(int(s / g), int(k / g))
n = int(input())
for iii in range(n):
	fun()


import math
for nitish in range(int(input())):
	(n, k) = map(int, input().strip().split(' '))
	ss = input()
	cnt = n
	s = 0
	c = 0
	for i in ss:
		if ord(i) - 96 > 2 * k:
			cnt -= 1
			c += 1
			s += ord(i) - 96
	lol = (cnt - c) * k + s
	p = math.gcd(abs(lol), k)
	lol = lol // p
	k = k // p
	print(lol, k)


t = int(input())
for it in range(t):
	(n, k) = map(int, input().split())
	clst = list(input())
	clst.sort()
	num = 0
	den = k
	pure_int = n
	index = n - 1
	while index >= 0 and (ord(clst[index]) - 96) / den > 2:
		num += ord(clst[index]) - 96
		pure_int -= 2
		index -= 1
	num = den * pure_int + num
	for i in range(den, 1, -1):
		if den % i == 0 and num % i == 0:
			den //= i
			num //= i
	print(num, den)


from fractions import Fraction as F
T = int(input())
for each in range(T):
	(L, K) = map(int, input().split())
	str1 = sorted(input())[::-1]
	p = 0
	for i in str1:
		if ord(i) - 96 > 2 * K:
			p += ord(i) - 96
			L -= 2
		else:
			break
	ans = F(K * L + p, K)
	print(ans.numerator, ' ', ans.denominator, sep='')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def sol():
	(charcount, k) = map(int, input().split())
	(intcount, sum1) = (0, 0)
	s = input()
	for a in s:
		if (ord(a) - 96) / k > 2:
			intcount += 1
			charcount -= 1
			sum1 += ord(a) - 96
	if sum1 % k == 0:
		print(sum1 // k + charcount - intcount, 1)
	else:
		div = gcd(sum1 + k * (charcount - intcount), k)
		print((sum1 + k * (charcount - intcount)) // div, k // div)
for _ in range(int(input())):
	sol()


from fractions import gcd
for inm in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s0 = s
	s = list(s)
	s.sort(reverse=True)
	su = 0
	r = []
	for i in range(len(s)):
		l = s[:]
		su = 0
		for j in range(0, i + 1):
			l[j] = ord(l[j]) - 96
		su = su + sum(l[0:i + 1])
		r.append(n * k - 2 * (i + 1) * k + su)
	r.append(len(s0) * k)
	x1 = max(r)
	x2 = gcd(x1, k)
	if x2 == 1:
		print(str(x1) + ' ' + str(k))
	else:
		print(str(x1 // x2) + ' ' + str(k // x2))


from fractions import Fraction

def val(x):
	return ord(x) - ord('a') + 1
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	line = input()
	Pmax = 0
	for c in line:
		ax = val(c)
		y = -1.0 + float(ax) / k
		if y > 1:
			Pmax += y
		else:
			Pmax += 1
	fr = Fraction(Pmax).limit_denominator()
	print('{0} {1}'.format(fr.numerator, fr.denominator))


from math import *
from fractions import Fraction

def ascii(x):
	return ord(x) - ord('a') + 1
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	s = input()
	P = 0
	for ch in s:
		asci = ascii(ch)
		xz = -1.0 + float(asci) / k
		if xz > 1:
			P += xz
		else:
			P += 1
	fr = Fraction(P).limit_denominator()
	print('{0} {1}'.format(fr.numerator, fr.denominator))


def main():
	from sys import stdin, stdout
	from math import gcd
	rl = stdin.readline
	wl = stdout.write
	int1 = int
	str1 = str
	t = int1(rl())
	for i in range(t):
		a = b = m = 0
		(n, k) = [int1(x) for x in rl().split()]
		s = rl()
		for c in s:
			if ord(c) - 96 > 2 * k:
				b += ord(c) - 96
				m += 1
		a = (n - 2 * m) * k + b
		g = gcd(a, k)
		wl(str1(int1(a / g)) + ' ' + str1(int1(k / g)) + '\n')
main()


from fractions import gcd
for z in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	a.sort()
	a = a[::-1]
	maxi = -1
	ad = 1
	ad1 = 1
	for i in range(n):
		p = k * (n - i) + sum([ord(j) - 96 for j in a[0:i]]) - i * k
		if p > maxi:
			maxi = p
	m = sum([ord(i) - 96 for i in a[0:n]]) - n * k
	if maxi < m:
		maxi = m
	c = gcd(maxi, k)
	maxi = maxi // c
	k = k // c
	print(maxi, k)


import math as ma
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = list(input())
	s.sort()
	x = 0
	p = a
	xx = []
	for j in range(a - 1, -1, -1):
		x += ord(s[j]) - 96
		k = j * b - (a - j) * b + x
		xx.append(k)
	xx.sort()
	vv = xx[len(xx) - 1]
	gd = ma.gcd(vv, b)
	vv = vv // gd
	b = b // gd
	if vv / b > a:
		print(vv, b)
	else:
		print(a, 1)


from fractions import Fraction
tc = int(input())
for test in range(tc):
	(n, k) = map(int, input().split())
	arr = list(input())
	arr.sort(reverse=True)
	num_sum = temp_num_sum = 0
	t = i = temp_t = 0
	max_diff = 0
	while num_sum >= 2 * t * k and i < n:
		temp_num_sum += ord(arr[i]) - ord('a') + 1
		temp_t += 1
		i += 1
		if temp_num_sum >= 2 * temp_t * k:
			num_sum = temp_num_sum
			t = temp_t
		if num_sum - 2 * t * k >= max_diff:
			max_diff = num_sum - 2 * t * k
		else:
			break
	ans = Fraction(n * k + max_diff, k)
	print(ans.numerator, ans.denominator)


from fractions import Fraction
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split(' '))
	s = input()
	a1 = n
	a2 = 1
	p = k * n
	l = []
	for j in range(0, n):
		l.append(ord(s[j]) - ord('a') + 1)
	l.sort()
	l.reverse()
	sm = 0
	for j in range(0, n):
		sm += l[j]
		if k * k * (n - 2 * (j + 1)) + sm * k > k * p:
			p = k * (n - 2 * (j + 1)) + sm
			a1 = k * (n - 2 * (j + 1)) + sm
			a2 = k
		else:
			break
	if a1 % a2 == 0:
		print(str(a1 // a2) + ' 1')
	else:
		ans = str(Fraction(a1, a2))
		n1 = ''
		n2 = ''
		j = 0
		while ans[j] != '/':
			n1 += ans[j]
			j += 1
		j += 1
		while j != len(ans):
			n2 += ans[j]
			j += 1
		print(n1 + ' ' + n2)


def ip():
	return int(input())

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

def sar():
	return list(ipp())

def pars(a):
	print(' '.join(list(map(str, a))))
	print('\r')

def parl(a):
	print('\r'.join(list(map(str, a))))
	print('\r')
from fractions import gcd
from functools import reduce
T = 1
T = int(input().strip())
for _ in range(T):
	(n, k) = ipp()
	a = []
	a = input()
	sm = 0
	c1 = n
	c2 = 0
	highn = -k * 0 + k * n + 0
	highd = k
	high = highn / highd
	p = 0
	pn = 0
	pd = 0
	a = reduce(lambda x, y: x + y, sorted(a, reverse=True))
	for i in range(len(a)):
		sm += ord(a[i]) - ord('a') + 1
		c1 -= 1
		c2 += 1
		pn = k * c1 - k * c2 + sm
		p = pn / k
		if p > high:
			high = p
			highn = pn
	g = gcd(highn, k)
	print(highn // g, k // g)


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

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

def li():
	return list(mi())
from fractions import Fraction
for t in range(ii()):
	(n, k) = mi()
	s = input().strip()
	s = [ord(c) - 96 for c in s]
	s.sort(reverse=True)
	ans = Fraction(n)
	sm = 0
	for i in range(n):
		sm += s[i]
		ans = max(ans, n - 2 * (i + 1) + Fraction(sm, k))
	print(ans.numerator, ans.denominator)