from fractions import gcd from heapq import* import math from collections import defaultdict, Counter import sys sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 inf = float("inf") def main(): x, n = map(int, input().split()) a = list(map(int, input().split())) def modpow(a, n, mod): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res ans = 0 for i in range(n): print(modpow(x, a[i], 1000003)) ans += modpow(x, a[i], 1000003) print(ans) if __name__ == '__main__': main()