/* Simon Gog */
#include<cstdio>

using namespace std;

int prefix;
int occ[100000];
char rest[1000000];
int main(){
	int c, n, a;

	//freopen("halloween.in", "r", stdin);
	while(scanf("%d%d\n",&c,&n)==2){
		if(c==0 && n==0)
			return 0;

		for(int i=0;i<n;++i) occ[i] = -1;
		prefix = 0;
		occ[0] = 0;
		int i=1;

		for(;i<=n;++i){
			scanf("%d", &a);
			prefix = (prefix+a)%c;
			if( occ[prefix] >=0 )
				break;
			else
				occ[prefix] = i;
		}
		gets(rest);
		for(int j=occ[prefix]+1; j<=i; ++j)
			printf("%d ",j);
		puts("");
	}
}
