#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXM = 11;
const int MAXN = 101;
const int INF = 1<<28;

int M, N;
int T[MAXN], U[MAXN];
int space1[MAXM];
int space2[MAXM];
vector<int> ans;

void out(int t) {
  for(int i = 0; i < M; ++i) {
    while(space1[i] != -1 && U[space1[i]] <= t) {
      ans.push_back(space1[i]);
      space1[i] = space2[i];
      space2[i] = -1;
    }
  }
}

void in(int t) {
  if(t % 10 != 0) return;
  int k = t / 10;
  if(k >= N) return;

  U[k] = t + T[k];

  for(int i = 0; i < M; ++i) {
    if(space1[i] == -1) {
      space1[i] = k;
      return;
    }
  }

  int id = -1;
  int mini = INF;
  for(int i = 0; i < M; ++i) if(space2[i] == -1) {
    int rem = U[space1[i]] - t;
    if(rem >= T[k]) {
      int diff = rem - T[k];
      if(mini > diff) {
        id = i;
        mini = diff;
      }
    }
  }
  if(id != -1) {
    space2[id] = space1[id];
    space1[id] = k;
    return;
  }
  for(int i = 0; i < M; ++i) if(space2[i] == -1) {
    int rem = U[space1[i]] - t;
    int diff = T[k] - rem;
    if(mini > diff) {
      id = i;
      mini = diff;
    }
  }
  space2[id] = space1[id];
  space1[id] = k;
}

int main() {
  while(cin >> M >> N && (M|N)) {
    for(int i = 0; i < N; ++i) {
      cin >> T[i];
    }
    ans.clear();
    fill(space1, space1+MAXM, -1);
    fill(space2, space2+MAXM, -1);
    for(int t = 0; t <= 120; ++t) {
      out(t);
      in(t);
    }
    for(int i = 0; i < ans.size(); ++i) {
      if(i) cout << " ";
      cout << ans[i]+1;
    }
    cout << endl;
  }
  return 0;
}