pwmod x n m | n == 0 = 1 | even n = pwmod (x `prod'` x) (n `div` 2) m | otherwise = x `prod'` pwmod x (n - 1) m where prod' a b = (a * b) `mod` m m = 998244353 main = getLine >>= (\n -> print m >> print n) . solve where solve = (\v -> pwmod (head v) (v !! 1) m) . fmap (read :: String -> Int) . words