#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <sstream>
#include <climits>
#include <cstdlib>
using namespace std;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

class Car{
public:
	int id,time;

	Car(int tid,int ttime){
		id = tid;
		time = ttime;
	}
};

int n;
stack<Car> space[10];
queue<Car> q;
vector<int> ans;

void minusTime(int time){
	rep(i,n){
		stack<Car> tmp;

		while(!space[i].empty()){
			Car car = space[i].top();
			space[i].pop();
			car.time -= time;
			tmp.push(car);
		}

		while(!tmp.empty()){
			space[i].push(tmp.top());
			tmp.pop();
		}
	}
}

int leftCar(void){
	int res = 0;

	rep(i,n){
		while(!space[i].empty() && space[i].top().time <= 0){
			ans.push_back(space[i].top().id);
			space[i].pop();
			res++;
		}
	}

	return res;
}

int getParkingSpace(Car car){
	int min1 = INT_MAX - 1;
	int min2 = INT_MAX - 1;
	int minIdx1 = -1;
	int minIdx2 = -1;

	rep(i,n)if(space[i].size() != 2){
		int diff = abs(space[i].top().time - car.time);

		if(space[i].top().time >= car.time && min1 > diff){
			min1 = diff;
			minIdx1 = i;
		}
		else if(space[i].top().time < car.time && min2 > diff){
			min2 = diff;
			minIdx2 = i;
		}
	}

	if(min1 != INT_MAX - 1) return minIdx1;
	if(min2 != INT_MAX - 1) return minIdx2;
	return -1;
}

void parkCar(Car car){
	rep(i,n)if(space[i].empty()){
		space[i].push(car);
		return;
	}

	int spIdx = getParkingSpace(car);
	if(spIdx == -1) q.push(car);
	else space[spIdx].push(car);
}

void simulateOneMinute(void){
	minusTime(1);
	int res = leftCar();
	for(int k=0;!q.empty() && k<res;k++){
		parkCar(q.front());
		q.pop();
	}
}


int main(void){
	int m;

	while(cin>>n>>m && (n||m)){
		rep(i,n) while(!space[i].empty()) space[i].pop();
		ans.clear();

		REP(i,1,m+1){
			int time;
			cin>>time;
			rep(j,10) simulateOneMinute();
			parkCar(Car(i,time));
		}

		while(ans.size() != m) simulateOneMinute();

		rep(i,m-1) cout<<ans[i]<<" ";
		cout<<ans[m-1]<<endl;
	}

	return 0;
}