#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
 
class Car{
public:
  int id, in_time, rem_time;
  Car(){}
  Car(int a, int b, int c): id(a), in_time(b), rem_time(c){}
};
 
const int INF = (1<<28);
 
int m, n;
queue<Car> que;
Car pa[20];
 
void init(){
  for(int i=0;i<m*2;i++) pa[i] = Car(-1, -1, -1);
}
 
void print(){
  for(int i=0;i<m*2;i++){
    cout << pa[i].id << ' ';
  }
  cout << endl;
  for(int i=0;i<m*2;i++){
    cout << pa[i].rem_time << ' ';
  }
  cout << endl;
}
 
main(){
  while(cin >> m >> n && (m|n)){
    init();
    for(int i=0;i<n;i++){
      Car in = Car(i+1, i*10, 0);
      cin >> in.rem_time;
      que.push(in);
    }
    int rem_car = 0;
    vector<int> ans;
    for(int t=0;;t+=10){
      if(t != 0 && rem_car <= 0) break;
      int di = 10;
      /*if(rem_car == m*2){
        int valm = INF;
        int ex_id = -1;
        for(int i=0;i<m*2;i++){
          if(pa[i].id == -1) continue;
          if(valm > pa[i].rem_time){
            valm = pa[i].rem_time;
            ex_id = i;
          }
        }
        di = pa[ex_id].rem_time;
      }else if(que.empty()){
        di = 100000;
      }*/
      for(int i=0;i<m*2;i++){
        if(pa[i].id == -1) continue;
        pa[i].rem_time -= di;
      }
      vector<pair<int, pair<int, int> > > t_vec;
      for(int i=0;i<m*2;i++){
        if(pa[i].id == -1) continue;
        if(pa[i].rem_time > 0) continue;
        t_vec.push_back(make_pair(pa[i].rem_time, make_pair(i, pa[i].id)));
      }
      if(t_vec.size() > 0){
        sort(t_vec.begin(), t_vec.end());
        for(int i=0;i<t_vec.size();i++){
          ans.push_back(t_vec[i].second.second);
          pa[t_vec[i].second.first] = Car(-1, -1, -1);
          rem_car--;
        }
      }
      //t += di;
      while(!que.empty()){
        Car c = que.front();
        if(c.in_time > t) break;
        int pos = -1;
        for(int i=1;i<m*2;i+=2){
          if(pos == -1 && pa[i].id == -1) pos = i;
        }
        if(pos != -1){
          pa[pos] = c;
          que.pop();
          rem_car++;
        }else{
          int valm = INF;
          for(int i=0;i<m*2;i+=2){
            if(pa[i].id != -1) continue;
            if(pa[i+1].rem_time >= c.rem_time){
              if(valm > abs(pa[i+1].rem_time - c.rem_time)){
                valm = abs(pa[i+1].rem_time - c.rem_time);
                pos = i;
              }
            }
          }
          if(pos != -1){
            pa[pos] = c;
            que.pop();
            rem_car++;
          }else{
            for(int i=0;i<m*2;i+=2){
            if(pa[i].id != -1) continue;
              if(valm > abs(pa[i+1].rem_time - c.rem_time)){
                valm = abs(pa[i+1].rem_time - c.rem_time);
                pos = i;
              }
            }
            if(pos != -1){
              pa[pos+1].rem_time = c.rem_time;
              pa[pos] = c;
              que.pop();
              rem_car++;
            }
          }
        }
        //cout << c.id << endl;
      }
      //cout << t << endl;
      //print();
    }
    cout << ans[0];
    for(int i=1;i<ans.size();i++) cout << " " << ans[i];
    cout << endl;
  }
}