import java.util.*; public class Yukicoder219{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for(int i = 0;i < n;i++){ a[i] = scan.nextInt(); b[i] = scan.nextInt(); } for(int i = 0;i < n;i++){ int value = (int)(Math.pow(a[i] , b[i])); String str = "" + value; int z = str.length() - 1; int x = Integer.parseInt(str.substring(0,1)); int y = Integer.parseInt(str.substring(1,2)); System.out.println(x + " " + y + " " + z); } } }