import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
scan.nextLine();
while( t > 0){
String[] val = scan.nextLine().split(" ");
double n = Double.valueOf(val[0]);
double k = Double.valueOf(val[1]);
double antilog = Math.log(n)/k;
int result = (int) Math.exp(antilog);
System.out.println(result);
t--;
}
}
}
