import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { 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.pow2(), p / 2); } else { return pow(x, p - 1).multiply(x); } } static class Num { long value; long count; static int MAX = 1000000000; public Num(long value, long count) { this.value = value; this.count = count; normalize(); } public Num(long value) { this(value, 0); } private void normalize() { while (value > MAX) { value /= 10; count++; } } public Num pow2() { return new Num(value * value, count * 2); } public Num multiply(Num x) { return new Num(value * x.value, count + x.count); } public String toString() { StringBuilder sb = new StringBuilder(); if (value < 10) { return sb.append(value).append(" 0 ").append(count).toString(); } long x = value; long y = count; while (x >= 100) { x /= 10; y++; } return sb.append(x / 10).append(" ").append(x % 10).append(" ").append(y + 1).toString(); } } }