import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve 

solve :: [Int] -> Int 
solve [n, p]
    | n == 1 || p == 1 = p
    | otherwise = product $ pf n p

pf :: Int -> Int -> [Int]
pf n = loop [2..]
    where
        loop (x : xs) v 
            | v == 1 = []
            | y == 0 = loop xs w
            | otherwise = x ^ y : loop xs w
            where
                (w, z) = count v x
                y = z `div` n 

        count v x = cloop v 0
            where
                cloop w acc 
                    | w `mod` x == 0 = cloop (w `div` x) (acc + 1)
                    | otherwise = (w, acc)

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine