import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (n-- > 0) { sb.append(pow(new Num(sc.nextInt()), sc.nextInt())).append("\n"); } System.out.print(sb); } static Num pow(Num x, int p) { if (p == 0) { return new Num(1); } else if (p % 2 == 0) { return pow(x.pow(), p / 2); } else { return pow(x, p - 1).multiply(x); } } static class Num { long value; long p; public Num(long value, long p) { this.value = value; this.p = p; normalize(); } private void normalize() { while (value >= Integer.MAX_VALUE) { value /= 10; p++; } } public Num(long value) { this(value, 0); } public Num pow() { return new Num(value * value, p * 2); } public Num multiply(Num x) { return new Num(value * x.value, p + x.p); } public String toString() { long x = value; long y = p + 1; if (x < 10) { x *= 10; y--; } while (x >= 100) { x /= 10; y++; } return (x / 10) + " " + (x % 10) + " " + y; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }