---
{"category_name":"easy","problem_code":"A4","problem_name":"The Rise and Fall of Power","languages_supported":{"0":"ADA","1":"ASM","2":"BASH","3":"BF","4":"C","5":"C99 strict","6":"CAML","7":"CLOJ","8":"CLPS","9":"CPP 4.3.2","10":"CPP 4.9.2","11":"CPP14","12":"CS2","13":"D","14":"FORT","15":"FS","16":"GO","17":"HASK","18":"ICK","19":"ICON","20":"JAVA","21":"JS","22":"LISP clisp","23":"LISP sbcl","24":"LUA","25":"NEM","26":"NICE","27":"NODEJS","28":"PAS fpc","29":"PAS gpc","30":"PERL","31":"PHP","32":"PIKE","33":"PRLG","34":"PYTH","35":"PYTH 3.4","36":"RUBY","37":"SCALA","38":"SCM guile","39":"SCM qobi","40":"ST","41":"TCL","42":"TEXT","43":"WSPC"},"max_timelimit":4,"source_sizelimit":50000,"problem_author":"admin","problem_tester":null,"date_added":"1-12-2008","tags":{"0":"admin"},"time":{"view_start_date":1367924777,"submit_start_date":1367924777,"visible_start_date":1367924777,"end_date":1735669800},"layout":"problem"}
---
<span class="solution-visible-txt">All submissions for this problem are available.</span><p>
Johnny was asked by his math teacher to compute <i>n</i><sup><i>n</i></sup> (<i>n</i> to the power of <i>n</i>, where <i>n</i> 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 <i>k</i> digits of the result before the teacher falls asleep, and then the last <i>k</i> digits when the teacher wakes up.
</p>
<p>Write a program to help Johnny to compute the digits he will need to read out.</p>
<h3>Input</h3>
<p>The first line contains <em>t</em>, the number of test cases (about 30000). Then <em>t</em> test cases follow.</p>
<p>Each test case consists of one line containing two numbers <i>n</i> and <i>k</i> (1 ≤ <i>n</i> ≤ 10<sup>9</sup>, 1 ≤ k ≤ 9). It is guaranteed that <i>k</i> is not more than the number of digits of <i>n<sup>n</sup></i>.</p>
<h3>Output</h3>
<p>For each test case, print out one line containing two numbers, separated by a space, which are the first and the last <i>k</i> digits of <i>n<sup>n</sup></i>.</p>
<h3>Example</h3>
<pre>
<b>Input</b>
2
4 2
9 3
<b>Output</b>
25 56
387 489
</pre>