Johnny was asked by his math teacher to compute nn (n to the power of n, where n is an integer), and has to read his answer out loud. This is a bit of a tiring task, since the result is probably an extremely large number, and would certainly keep Johnny occupied for a while if he were to do it honestly. But Johnny knows that the teacher will certainly get bored when listening to his answer, and will sleep through most of it! So, Johnny feels he will get away with reading only the first k digits of the result before the teacher falls asleep, and then the last k digits when the teacher wakes up.

Write a program to help Johnny to compute the digits he will need to read out.

-----Input-----
The first line contains t, the number of test cases (about 30000). Then t test cases follow.
Each test case consists of one line containing two numbers n and k (1 ≤ n ≤ 109, 1 ≤ k ≤ 9). It is guaranteed that k is not more than the number of digits of nn.

-----Output-----
For each test case, print out one line containing two numbers, separated by a space, which are the first and the last k digits of nn.

-----Example-----
Input
2
4 2
9 3

Output
25 56
387 489

Difficulty: HARD

Solutions:
from decimal import *
for i in range(int(input())):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if x < 1000:
		q1 = str(x ** x)[:y]
	else:
		x = Decimal(x)
		q1 = str(int(10 ** (x * x.log10() % 1 + y - 1)))
	q2 = str(pow(x, x, 10 ** y)).zfill(y)
	print(q1 + ' ' + q2)


from decimal import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n >= 1000:
		q1 = str(int(pow(10, Decimal(n) * Decimal(n).log10() % 1 + k - 1)))
	else:
		q1 = str(n ** n)[:k]
	print(q1 + ' ' + str(pow(n, n, 10 ** k)).zfill(k))


from decimal import *

def firstkdigits(n, k):
	n = Decimal(n)
	product = n * n.log10()
	decimal_part = product % 1
	d = pow(10, decimal_part + k - 1)
	return str(int(d))
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	q2 = str(pow(n, n, 10 ** k)).zfill(k)
	if n >= 1000:
		q1 = firstkdigits(n, k)
	else:
		q1 = str(n ** n)[:k]
	print(q1 + ' ' + q2)


from math import log10
from decimal import Decimal

def solve(n, k):
	mod = 10 ** k
	x = Decimal(n)
	y = x * x.log10() % 1
	p = str(pow(10, y))
	c = 0
	first = ''
	for v in p:
		if c == k:
			break
		if v == '.':
			continue
		first += v
		c += 1
	last = str(pow(n, n, mod)).zfill(k)
	return (first, last)
queries = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	queries.append((n, k))
for (n, k) in queries:
	print('%s %s' % solve(n, k))