Write a program that reads two numbers $X$ and $K$. The program first finds the factors of $X$ and then gives the sum of $K$th power of every factor. The program also finds the factor of $k$ and outputs the sum of $X$ times of every factor. 

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input, two integers $X, R$. 

-----Output:-----
For each testcase, output in a single line the factors of $X$ and the $K$th power of every factor, seperated by a space.

-----Constraints-----
- $1 \leq T \leq 1000$
- $2 \leq X, K \leq 10^9$

-----Sample Input:-----
1
8 6

-----Sample Output:-----
266304 88

-----EXPLANATION:-----
Factors of x = 8 are 2, 4, and 8. Also, factors of k = 6 are 2, 3, and 6.
2^6 + 4^6 + 8^6 = 266304 and 2 × 8 + 3 × 8 + 6 × 8 = 88.
(Where a ^b denotes a raised to the power of b).

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
try:
	for _ in range(int(input())):
		(s, s1) = (0, 0)
		(x, k) = [int(i) for i in input().split()]
		for i in range(2, x + 1):
			if x % i == 0:
				s = s + i ** k
		for i in range(2, k + 1):
			if k % i == 0:
				s1 += i * x
		print(s, s1)
except EOFError as e:
	pass


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list()
	var1 = 0
	for j in range(2, n + 1):
		if n % j == 0:
			arr.append(j)
			var1 = var1 + j ** k
	var2 = 0
	for j in range(2, k + 1):
		if k % j == 0:
			var2 = var2 + n * j
	print(var1, var2)


from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
T = int(input())
while T:
	(X, K) = input().split()
	(X, K) = (int(X), int(K))
	factors_X = factors(X)
	factors_K = factors(K)
	factors_X.remove(1)
	factors_K.remove(1)
	sum_X = 0
	sum_K = 0
	for i in factors_X:
		sum_X += i ** K
	for i in factors_K:
		sum_K += i * X
	print(sum_X, sum_K)
	T -= 1


T = int(input())
for testcase in range(T):
	(X, K) = list(map(int, input().split(' ')))

	def get_factors(N):
		res = []
		for i in range(2, N + 1):
			if N % i == 0:
				res.append(i)
		return res
	x_factors = get_factors(X)
	k_factors = get_factors(K)
	power_sum = sum([x ** K for x in x_factors])
	factor_sum = sum([k * X for k in k_factors])
	print(power_sum, factor_sum)


T = int(input())
res = []
for i in range(T):
	lis = []
	s = input()
	s = list(s.split())
	x = int(s[0])
	k = int(s[1])
	fac = []
	po = []
	n = 0
	m = 0
	for j in range(2, x + 1):
		if x % j == 0:
			n += j ** k
	fac.append(n)
	for j in range(2, k + 1):
		if k % j == 0:
			m += j * x
	fac.append(m)
	res.append(fac)
for i in range(T):
	print(res[i][0], res[i][1])


T = int(input())
for a in range(T):
	(X, K) = input().split(' ')
	X = int(X)
	K = int(K)
	s = 0
	su = 0
	for i in range(2, X + 1):
		if X % i == 0:
			s += i ** K
	for i in range(2, K + 1):
		if K % i == 0:
			su += i * X
	print(s, ' ', su)


import math
t = int(input())
i = 1
while i <= t:
	(x, k) = list(map(int, input().split()))
	lst1 = []
	lst2 = []
	for j in range(2, x + 1):
		if x % j == 0:
			lst1 += [j]
	for l in range(2, k + 1):
		if k % l == 0:
			lst2 += [l]
	a2 = sum(lst2) * x
	a1 = 0
	for p in range(0, len(lst1)):
		a1 = a1 + math.pow(lst1[p], k)
	print(int(a1), a2)
	i += 1


import math
for _ in range(int(input())):
	(x, k) = map(int, input().split())
	a = {x}
	b = {k}
	for i in range(2, int(math.sqrt(max(x, k)) + 2)):
		if i <= x and x % i == 0:
			a.add(i)
			a.add(int(x / i))
		if i <= k and k % i == 0:
			b.add(i)
			b.add(int(k / i))
	ans1 = 0
	ans2 = 0
	for i in a:
		if i != 1:
			ans1 += pow(i, k)
	for i in b:
		if i != 1:
			ans2 += i * x
	print(ans1, end=' ')
	print(ans2)


import math

def factor_x(m, n):
	res = 0
	st = 0
	for i in range(2, n + 1):
		if n % i == 0:
			st = 0
			st = math.pow(i, m)
			res = res + st
	return res

def factor_k(m, n):
	res = 0
	st = 0
	for i in range(2, n + 1):
		if n % i == 0:
			st = 0
			st = i * m
			res = res + st
	return res
x_fac = 0
k_fac = 0
cycle = int(input())
cy = 0
while cy < cycle:
	(x, k) = input().split()
	(x, k) = (int(x), int(k))
	x_fac = factor_x(k, x)
	k_fac = factor_k(x, k)
	print(int(x_fac), ' ', int(k_fac))
	x_fac = 0
	k_fac = 0
	cy = cy + 1


for _ in range(int(input())):
	(x, r) = list(map(int, input().split(' ')))
	m = []
	c = 0
	d = 0
	for i in range(2, x + 1):
		if x % i == 0:
			m.append(i)
			c = c + i ** r
	l = []
	for i in range(2, r + 1):
		if r % i == 0:
			l.append(i)
			d = d + i * x
	print(c, d)


t = int(input())
for i in range(t):
	s = input().split()
	x = int(s[0])
	k = int(s[1])
	factor_x = list()
	factor_k = list()
	for i in range(2, max(x, k) + 1):
		if x % i == 0:
			factor_x.append(i)
		if k % i == 0:
			factor_k.append(i)
	res_a = 0
	for i in factor_x:
		res_a += i ** k
	res_b = 0
	for j in factor_k:
		res_b += j * x
	print(res_a, res_b)


import math
t = int(input())
for cases in range(t):
	(x, k) = map(int, input().split())
	fx = []
	fk = []
	for i in range(2, x + 1):
		if x % i == 0:
			fx.append(i)
	for i in range(2, k + 1):
		if k % i == 0:
			fk.append(i)
	o1 = 0
	for i in fx:
		o1 += pow(i, k)
	o2 = 0
	for i in fk:
		o2 += i * x
	print(o1, o2)


for _ in range(int(input())):
	(x, k) = map(int, input().split(' '))
	s = 0
	for i in range(2, x + 1):
		if x % i == 0:
			s += i ** k
	s1 = 0
	for i in range(2, k + 1):
		if k % i == 0:
			s1 += i * x
	print(s, s1)


from numpy import array
t = int(input())

def factor(n):
	l = []
	for i in range(2, n + 1):
		if n % i == 0:
			l.append(i)
	return l
while t > 0:
	(x, k) = list(map(int, input().split(' ')))
	xF = factor(x)
	kF = factor(k)
	arr1 = array(xF)
	arr2 = array(kF)
	xS = arr1 ** array([k] * len(xF))
	kS = arr2 * array([x] * len(kF))
	print(sum(xS), sum(kS))
	t -= 1


for t in range(int(input())):
	(X, K) = input().split()
	(X, K) = (int(X), int(K))
	l = []
	l1 = []
	for i in range(2, X + 1):
		if X % i == 0:
			l.append(i ** K)
	for j in range(2, K + 1):
		if K % j == 0:
			l1.append(j * X)
	print(sum(l), sum(l1))


for _ in range(int(input())):
	(X, R) = map(int, input().split())
	a = []
	b = []
	for i in range(2, X + 1):
		if X % i == 0:
			a.append(i ** R)
	for j in range(2, R + 1):
		if R % j == 0:
			b.append(j * X)
	print(sum(a), sum(b))


t = int(input())
while t:
	t = t - 1
	l = list(map(int, input().split()))
	X = l[0]
	K = l[1]
	sum1 = 0
	sum2 = 0
	for i in range(2, X + 1):
		if X % i == 0:
			sum1 = sum1 + i ** K
	for i in range(2, K + 1):
		if K % i == 0:
			sum2 = sum2 + X * i
	print(str(sum1) + ' ' + str(sum2))


try:
	t = int(input())
	for _ in range(t):
		p = list(map(int, input().split()))
		(x, k) = (p[0], p[1])
		(c1, c2) = (0, 0)
		for i in range(2, x + 1):
			if x % i == 0:
				c1 += pow(i, k)
		for i in range(2, k + 1):
			if k % i == 0:
				c2 += x * i
		print(c1, c2)
except:
	pass


t = int(input())
for _ in range(t):
	(x, r) = map(int, input().split())
	i = 2
	l = []
	l1 = []
	while i <= x:
		if x % i == 0:
			l.append(i)
		i = i + 1
	i = 2
	while i <= r:
		if r % i == 0:
			l1.append(i)
		i = i + 1
	su = 0
	for i in range(len(l)):
		su += pow(l[i], r)
	su1 = 0
	for i in range(len(l1)):
		su1 += l1[i] * x
	print(su, su1, sep=' ')


def divs(n):
	x = []
	i = 2
	while i <= n:
		if n % i == 0:
			x.append(i)
		i += 1
	return x
for _ in range(int(input())):
	(x, k) = map(int, input().split())
	xd = divs(x)
	kd = divs(k)
	(a, b) = (0, 0)
	for i in xd:
		a += pow(i, k)
	for i in kd:
		b += i * x
	print(a, b)