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