import sys def input(): return sys.stdin.readline().rstrip() def xor128(): x, y, z, w = 123456789, 362436069, 521288629, 88675123 while True: t = (x ^ (x << 11)) & 0xFFFFFFFF x = y y = z z = w w ^= (w >> 19) ^ t ^ (t >> 8) yield w def main(): N, Q = map(int, input().split()) qv = [int(input()) for i in range(Q)] MOD = 100003 X = xor128() A = [next(X) % MOD for i in range(N)] if N**2 < MOD: print(*(max(map(lambda x: (x*q) % MOD, A)) for q in qv), sep='\n') else: cnt = [False]*MOD for i in A: cnt[i] = True ans = {} for q in qv: if q == 0: print(0) continue if q in ans: print(ans[q]) continue qinv = pow(q, -1, MOD) cur = MOD-qinv while True: if cnt[cur]: ans[q] = cur * q % MOD print(ans[q]) break else: cur = cur - qinv if cur - qinv > 0 else cur - qinv + MOD if __name__ == '__main__': main()