#include <stdio.h> int main(int argc, char *argv[]) { int c = -1, n = -1; while (true) { scanf("%d%d",&c,&n); int arr[n],sum[n],b[n]; if (c + n == 0) { return 0; } for (int i = 0; i < n; i++) { scanf("%d",&arr[i]); b[i] = -1; } sum[0] = arr[0] % c; b[sum[0]] = 0; int temp = -1, temp1 = 0; for (int i = 1; i < n; i++) { sum[i] = sum[i - 1] + arr[i]; sum[i] %= c; if (sum[i] == 0) { temp = -1; temp1 = i; break; } if (b[sum[i]] == -1) { b[sum[i]] = i; } else { temp = b[sum[i]]; temp1 = i; break; } } for (int i = temp+1 ; i <= temp1; i++) { printf("%d%s",i+1," "); } printf(" "); } return 0; }