#include <bits/stdc++.h>

using namespace std;

const int INF = 10000000;
int RestTime[10][2], CarId[10][2], M, N, CurrentTime, RestNumberOfCars;
int CarStoppingTime[100];
queue<int> CarData;


int findParkingPosition(int currentTime){
	int pos, diff, tm;

	for (int i = 0; i < M; i++){
		if (RestTime[i][0] == 0 && RestTime[i][1] == 0) {
			return i;
		}
	}
	pos = -1;
	diff = INF;
	for (int i = 0; i < M; i++) {
		if (RestTime[i][0] != 0 && RestTime[i][1] != 0) {
			continue;
		}
		tm = (RestTime[i][0] == 0 ? RestTime[i][1] : RestTime[i][0]);
		if (tm > currentTime && (tm - currentTime) < diff) {
			diff = tm - currentTime;
			pos = i;
		}
	}
	if (pos != -1) {
		return pos;
	}

	for (int i = 0; i < M; i++){
		if (RestTime[i][0] != 0 && RestTime[i][1] != 0) {
			continue;
		}
		int tm = (RestTime[i][0] == 0 ? RestTime[i][1] : RestTime[i][0]);
		if (tm < currentTime && (currentTime - tm) < diff){
			diff = currentTime - tm;
			pos = i;
		}
	}
	return pos;
}

void Parking(int pos, int stoppingTime, int carId)
{
	if (RestTime[pos][0] != 0){
		RestTime[pos][1] = RestTime[pos][0];
		CarId[pos][1] = CarId[pos][0];
	}
	RestTime[pos][0] = stoppingTime;
	CarId[pos][0] = carId;
}

void checkLeaving(){
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < 2; j++) {
			if (j == 1 && RestTime[i][0] != 0) {
				break;
			}
			if (RestTime[i][j] == 0) {
				continue;
			}

			if (CurrentTime >= RestTime[i][j]) {
				cout << CarId[i][j] + 1;
				if (RestNumberOfCars != 1) {
					cout << " ";
				}
				RestTime[i][j] = 0;
				CarId[i][j] = 0;
				--RestNumberOfCars;
			}
		}
	}
}

int main(){
	int cnt, nowId, pos;
	
	while (cin >> M >> N, M) {
		for (int i = 0; i < N; i++) {
			cin >> CarStoppingTime[i];
		}
		memset(RestTime, 0, sizeof(RestTime));
		memset(CarId, 0, sizeof(CarId));

		cnt = 0;
		RestNumberOfCars = N;
		CurrentTime = 0;
		while (RestNumberOfCars > 0) {
			checkLeaving();
			if (cnt < N && CurrentTime % 10 == 0) {
				CarData.push(cnt++);
			}
			while (!CarData.empty())
			{
				nowId = CarData.front();
				pos = findParkingPosition(CurrentTime + CarStoppingTime[nowId]);
				if (pos == -1) {
					break;
				}
				Parking(pos, CurrentTime + CarStoppingTime[nowId], nowId);
				CarData.pop();
			}
			++CurrentTime;
		}
		cout << endl;
	}

	return 0;
}
