import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; public class Main { public static class Value { long val, zero; public Value(long val, long zero){ //System.out.println(val); this.val = val; this.zero = zero; } public Value(long val){ this(val, 0); } public Value(Value v){ this(v.val, v.zero); } public static Value mul(Value a, Value b){ long zero = a.zero + b.zero; BigInteger value = BigInteger.valueOf(a.val).multiply(BigInteger.valueOf(b.val)); while(value.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0){ // 18桁 zero += value.toString().length() - 18; value = new BigInteger(value.toString().substring(0, 18)); } return new Value(value.longValue(), zero); } public String toString(){ String str = Long.toString(this.val); //System.out.println(str); return str.charAt(0) + " " + (str.length() == 1 ? "0" : str.charAt(1)) + " " + (this.zero + Math.max(0, str.length() - 1)) ; } } public static Value pow(Value A, long B){ if(B == 1){ return new Value(A); } if(B % 2 != 0){ return Value.mul(A, pow(A, B - 1)); } //System.out.println("A = " + A); //System.out.println("B = " + B); final Value ret = pow(A, B / 2); //System.out.println("RET = " + ret); return Value.mul(ret, ret); } public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); for(int tt = 0; tt < N; tt++){ final long A = sc.nextLong(); final long B = sc.nextLong(); System.out.println(pow(new Value(A), B)); } } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public void close() throws IOException { br.close(); } } }