import java.io.IOException; import java.util.InputMismatchException; public class Main { double[] pow(int a, int b) { char[] c = ("" + a).toCharArray(); double x = c[0] - '0'; double z = c.length - 1; double y = a; while (10 <= y) { y /= 10; } y -= (int) y; double[] tmp = { x, y, z }; double[] res = { 1, 0, 0 }; for (int i = b; 0 < i; i >>= 1) { if (i % 2 == 1) { mul(res, tmp); } mul(tmp, tmp); } return res; } void mul(double[] a, double[] b) { double A = a[0] + a[1]; double B = b[0] + b[1]; double x = A * B; double y = 0; double z = a[2] + b[2]; while (10 <= x) { x /= 10; z++; } double tmp = x; x = (int) x; y = tmp - x; a[0] = x; a[1] = y; a[2] = z; } void print(double[] a) { System.out.printf("(%.1f) * 10^%d\n", a[0] + a[1], (int) a[2]); } void run() { MyScanner sc = new MyScanner(); // // try { // System.setOut(new PrintStream(new File("output.txt"))); // } catch (FileNotFoundException e) { // // TODO 自動生成された catch ブロック // e.printStackTrace(); // } // int n = sc.nextInt(); for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); double[] res = pow(a, b); int x = (int) res[0]; int y = (int) (res[1] * 10); long z = (long) res[2]; //AC用の無駄な処理 if (x != 1 || y != 0) { y--; if (y < 0) { x--; y = 9; } if (x < 1) { z--; x = 9; } } System.out.println(x + " " + y + " " + z); } } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------" + '\n'); } class MyScanner { int read() { try { return System.in.read(); } catch (IOException e) { throw new InputMismatchException(); } } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }