import strutils, sequtils, math const M = 10 ^ 6 + 3 let xN, a = stdin.readLine.split.map parseInt (x, N) = (xN[0], xN[1]) var ttl = newSeq[int](N) for i, ai in a: var j = 0 while x ^ j < int.high div x: j += 1 let j0 = j - 1 var y = 1 for j in 0 ..< (ai div j0): y *= ((x ^ j0) mod M) mod M y *= x ^ (ai mod j0) y = y mod M ttl[i] = y echo ttl.sum mod M