/* Walter Guttmann */
#include <fstream>
#include <iostream>

using namespace std;

//ifstream in("halloween.in");
#define in cin

const int MAX = 1<<20;

bool b[MAX];
int ix[MAX];

int main() {
  int c, n;
  while (in >> c >> n) {
    if (c == 0 && n == 0)
      break;
    for (int i=0 ; i<c ; i++)
      b[i] = false;
    b[0] = true;
    ix[0] = 0;
    int ps = 0;
    for (int i=0 ; i<n ; i++) {
      int a;
      in >> a;
      ps += a;
      ps %= c;
      if (b[ps]) {
        for (int j=ix[ps] ; j<=i ; j++)
          cout << j+1 << " ";
        cout << endl;
        for (i++ ; i<n ; i++)
          in >> a;
        break;
      }
      b[ps] = true;
      ix[ps] = i+1;
    }
  }
  return 0;
}

