#include<iostream>
#include<vector>
using namespace std;
struct PARK{
  int up_n;
  int down_n;
  int up_t;
  int down_t;
  bool up_done;
  bool down_done;
  PARK(){
    up_n = down_n = up_t = down_t = 0;
    up_done = down_done = false;
  }
};
int main(){
  int m,n;
  while(cin >>m>>n,m||n){
    int lot[130] = {0};
    PARK parking[10];
    vector<int> log;
    for(int i=0; i<n; i++){
      cin>>lot[i];
    }
    for(int t=0,c=0;;t++){
      if(c == n){break;}
      for(int i=0; i<m; i++){
	if(parking[i].up_done && parking[i].down_done){
	  if(parking[i].down_t <= t){
	    log.push_back(parking[i].down_n);
	    c++;
	    parking[i].down_done = false;
	    parking[i].down_n = 0;
	    parking[i].down_t = 0;
	  }
	}
	if(parking[i].up_done && !parking[i].down_done){
	  if(parking[i].up_t <= t){
	    log.push_back(parking[i].up_n);
	    c++;
	    parking[i].up_done = false;
	    parking[i].up_n = 0;
	    parking[i].up_t = 0;
	  }
	}
      }
      for(int i=0; i<=t/10; i++){
	if(lot[i] != 0){
	  for(int j=0; j<m; j++){
	    if(!parking[j].up_done){
	      parking[j].up_done = true;
	      parking[j].up_n = i+1;
	      parking[j].up_t = lot[i]+t;
	      lot[i] = 0;
	      break;
	    }
	  }
	  if(lot[i] != 0){
	    int dis = 0, p = 0;
	    for(int j=0; j<m; j++){
	      if(!parking[j].down_done){
		if(parking[j].up_t > lot[i]){
		  if(dis > parking[j].up_t){
		    dis = parking[j].up_t;
		    p = j;
		  }
		}
	      }
	    }
	    if(dis != 0){
	      parking[p].down_done = true;
	      parking[p].down_n = i+1;
	      parking[p].down_t = lot[i]+t;
	      lot[i] = 0;
	    }
	    else{
	      for(int j=0; j<m; j++){
		if(!parking[j].down_done){
		  if(dis < parking[j].up_t){
		    dis = parking[j].up_t;
		    p = j;
		  }
		}
	      }
	      if(dis != 0){
		parking[p].down_done = true;
		parking[p].down_n = i+1;
		parking[p].down_t = lot[i]+t;
		lot[i] = 0;
	      }
	    }
	  }
	}
      }
    }
    for(int i=0; i<log.size(); i++){
      cout <<log[i];
      if(i<log.size()-1){cout <<" ";}
      else{cout <<endl;}
    }
  }
  return 0;
}