import java.io.*; import java.util.*; public class Main { static ArrayList xs = new ArrayList(); static ArrayList xn = new ArrayList(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); pre(x); int n = sc.nextInt(); long a = 0; for (int i = 0; i < n; i++) { a += empowerment(sc.nextLong()); } System.out.println(surplus(a)); } private static long surplus(long source) { return source % 1000003; } private static long empowerment(long a) { long tmpX = 1; for (int i = xn.size() - 1; i >= 0; i--) { long tmp = xn.get(i); if (a >= tmp) { tmpX = surplus(tmpX * xs.get(i)); a = a - tmp; } } return tmpX; } private static void pre(long x) { for (long i = 1; i < 1000000000; i = i + i) { xs.add(x); xn.add(i); x = surplus(x * x); } } }