main = do (x:_:exps) <- map read . words <$> getContents print (power x exps) power :: Integer -> [Integer] -> Integer power x exps = sum (map (pow x) exps) `mod` 1000003 where pow x n | n == 0 = 1 | n == 1 = x | odd n = x * pow x (n-1) | otherwise = (pow x (div n 2)) ^ 2