#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

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

const int INF = 1000000009;
const int MAX_M = 11;
int m,n,t;
int ct;
stack<P> park[MAX_M];
queue<P> wait;
vector<int> out;

bool parking() {
	if(wait.empty()) return false;

	P car = wait.front();
	// park
	rep(i,m) {
		if(park[i].empty()) {
			// printf("car %d parks at %d\n", car.second, i);
			park[i].push(P(car.first+ct, car.second));
			wait.pop();
			return true;
		}
	}

	// situation 1
	int p = -1;
	int minval = INF;
	rep(i,m) {
		if(park[i].size() == 1 && park[i].top().first >= ct + car.first) {
			if(minval > park[i].top().first - (ct + car.first)) {
				minval = park[i].top().first - (ct + car.first);
				p = i;
			}
		}
	}
	if(p >= 0) {
		// printf("car %d parks at %d\n", car.second, p);
		park[p].push(P(ct+car.first, car.second));
		wait.pop();
		return true;
	}

	// situation 2
	rep(i,m) {
		if(park[i].size() == 1 && park[i].top().first <= ct + car.first) {
			if(minval > ct + car.first - park[i].top().first) {
				minval = ct + car.first - park[i].top().first;
				p = i;
			}
		}
	}
	if(p >= 0) {
		// printf("car %d parks at %d\n", car.second, p);
		park[p].push(P(ct+car.first, car.second));
		wait.pop();
		return true;
	}
	return false;
}

bool leave() {
	int minval = INF;
	rep(i,m) {
		if(!park[i].empty() && minval > park[i].top().first) {
			minval = park[i].top().first;
		}
	}

	if(minval > ct) return false;
	
	bool update = false;
	rep(i,m) {
		if(!park[i].empty() && park[i].top().first == minval) {
			// printf("car %d leaves from %d\n", park[i].top().second, i);
			out.push_back(park[i].top().second);
			park[i].pop();
			update = true;
		}

		if(!park[i].empty() && park[i].top().first <= minval) {
			// printf("car %d leaves from %d\n", park[i].top().second, i);
			out.push_back(park[i].top().second);
			park[i].pop();
		}
	}
	return update;
}

int main() {
	while(scanf("%d%d", &m, &n), m|n) {
		ct = 0;
		out.clear();
		while(out.size() != n) {
			if(ct < 10 * n && ct % 10 == 0) {
				scanf("%d", &t);
				wait.push(P(t, ct/10+1));
			}
			while(leave()) {}
			while(parking()) {}
			ct++;
		}

		rep(i,n) {
			printf("%d%c", out[i], i==n-1 ? '\n' : ' ');
		}
	}
}