/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming

Solution to Simons and Cakes for Success: https://codeforces.com/problemset/problem/2205/B
*/

#include <bits/stdc++.h>
using namespace std;

int solve(int n) {
    //Prime factorize n while tracking the product of distinct prime factors
    int res = 1, temp = n;
    //Loop until the square root of n
    for(int i = 2; i*i <= n; i++) {
        //If temp is divisible by i, multiply the answer by i
        if(temp % i == 0) {
            res *= i;
            //Remove all occurrences of this prime factor
            //This ensures that multiples of primes are not counted as separate factors later
            while(temp % i == 0) {
                temp /= i;
            }
        }
    }
    //If temp > 1, n was initially prime, so this counts as a prime factor too
    if(temp > 1) res *= temp;
    //Return the answer for this test case
    return res;
}

int main() {
    //Process test cases
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        //Use the solve function and print the answer
        cout << solve(n) << endl;
    }
}