#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int cnt;
bool first;
const int INF = 1000000;

class Park{
public:
  int leftTime[2];
  int ID[2];
  bool car[2];

  Park(){
    rep(i, 2)car[i] = false;
  }
  
  void next(){ 
    rep(i, 2){
      if(car[i]){
	leftTime[i]--;
      }
    }
    rep(i, 2){
      if(car[i] && leftTime[i] <= 0){
	if(first){
	  first = false;
	}
	else cout << ' ';
	cnt++;
	cout << ID[i]+1;
	car[i] = false;
      }
      if(car[i])return;
    }
    return;
  }
  
  void put(int id, int time){
    int tmp = 1;
    if(car[1])tmp = 0;
    car[tmp] = true;
    ID[tmp] = id;
    leftTime[tmp] = time;
    return;
  }

  int diff(int time){
    return abs(time - leftTime[1]);
  }
};
  
main(){
  
  int n, m;
  while(cin >> m >> n){
    if(m + n == 0)break;
    Park p[m];
    first = true;
    int time = 0, id = 0;
    cnt = 0;
    queue<int> ID, Data;
    while(cnt < n){
      if(id < n && time == 0){
	int tmp;
	cin >> tmp;
	ID.push(id);
	Data.push(tmp);
	id++;
      }

      while(!ID.empty()){
	int next = -1;
	rep(i, m){
	  if(p[i].car[1])continue;
	  next = i;
	  break;
	}
	if(next != -1){
	  p[next].put(ID.front(), Data.front());
	  ID.pop();Data.pop();
	  continue;
	}
	
	int mini = INF, nTime = Data.front();
	rep(i, m){
	  if(p[i].car[0])continue;
	  if(p[i].leftTime[1] < nTime)continue;
	  if(mini > p[i].diff(nTime)){
	    mini = p[i].diff(nTime);
	    next = i;
	  }
	}
	if(next != -1){
	  p[next].put(ID.front(), Data.front());
	  ID.pop();Data.pop();
	  continue;
	}
	
	rep(i, m){
	  if(p[i].car[0])continue;
	  if(mini > p[i].diff(nTime)){
	    mini = p[i].diff(nTime);
	    next = i;
	  }
	}
	if(next != -1){
	  p[next].put(ID.front(), Data.front());
	  ID.pop();Data.pop();
	  continue;
	}
	break;
      }
      time++;
      if(time == 10)time = 0;
      rep(i, m)p[i].next();
    }
    cout << endl;
  }	  
}