/* Robin Nittka */
#include <fstream>
#include <vector>
#include <iostream>

using namespace std;

#define in cin

int main()
{
	//ifstream cin("halloween.in");
	int c, n;
	while (cin >> c >> n && c)
	{
		int vis[128 * 1024] = { 0 };
		int part = 0;
		int i;
		vector<int> a(n+1);
		for (int i = 0; i < n; i++)
			cin >> a[i+1];
		for (int i = 1; i <= n; i++)
		{
			int x = a[i];
			part = (part + x) % c;
			if (part == 0)
			{
				for (int j = 1; j < i; j++)
					cout << j << " ";
				cout << i << endl;
				goto done;
			}
			if (vis[part])
			{
				for (int j = vis[part]+1; j < i; j++)
					cout << j << " ";
				cout << i << endl;
				goto done;
			}
			vis[part] = i;
		}
		abort();
done:	;
	}
	return 0;
}
