#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Data{
	Data(){
		time = car_id = -1;
	}

	Data(int arg_time,int arg_car_id){
		time = arg_time;
		car_id = arg_car_id;
	}
	int time,car_id;
};

int M,N;
int out_time[100],length[100],park[10][2];




void func(){

	queue<Data> IN_Q;

	for(int i = 0; i < N; i++){
		scanf("%d",&length[i]);
		IN_Q.push(Data(10*i,i));
	}

	for(int i = 0; i < M; i++){
		park[i][0] = -1;
		park[i][1] = -1;
	}

	int now_time = 0,out_num = 0,minimum,min_index;
	vector<int> ANS;

	bool is_FULL = false,FLG;
	Data current;

	int tmp;

	while(true){

		for(int i = 0; i < M; i++){
			if(park[i][0] != -1){
				if(out_time[park[i][0]] <= now_time){
					ANS.push_back(park[i][0]);
					out_num++;
					park[i][0] = -1;
					if(park[i][1] != -1){
						if(out_time[park[i][1]] <= now_time){
							ANS.push_back(park[i][1]);
							out_num++;
						}else{
							park[i][0] = park[i][1];
						}
						park[i][1] = -1;
					}
				}
			}
		}

		if(out_num == N)break;

		while(IN_Q.size() > 0 && IN_Q.front().time <= now_time && is_FULL == false){

			current = IN_Q.front();

			FLG = false;

			for(int i = 0; i < M; i++){
				if(park[i][0] == -1){
					park[i][0] = current.car_id;
					out_time[current.car_id] = now_time + length[current.car_id];
					IN_Q.pop();
					FLG = true;
					break;
				}
			}
			if(FLG)continue;

			minimum = BIG_NUM;
			for(int i = 0; i < M; i++){
				if(park[i][1] != -1)continue;
				if(out_time[park[i][0]] >= now_time+length[current.car_id]){
					tmp = out_time[park[i][0]] - (now_time+length[current.car_id]);
					if(tmp < minimum){
						minimum = tmp;
						min_index = i;
					}
				}
			}

			if(minimum != BIG_NUM){
				park[min_index][1] = park[min_index][0];
				park[min_index][0] = current.car_id;
				out_time[current.car_id] = now_time + length[current.car_id];
				IN_Q.pop();
				continue;
			}

			for(int i = 0; i < M; i++){
				if(park[i][1] != -1)continue;
				if(out_time[park[i][0]] < now_time+length[current.car_id]){
					tmp = now_time+length[current.car_id] - out_time[park[i][0]];
					if(tmp < minimum){
						minimum = tmp;
						min_index = i;
					}
				}
			}

			if(minimum != BIG_NUM){
				park[min_index][1] = park[min_index][0];
				park[min_index][0] = current.car_id;
				out_time[current.car_id] = now_time + length[current.car_id];
				IN_Q.pop();
				continue;
			}

			is_FULL = true;
		}
		now_time++;
	}

	printf("%d",ANS[0]+1);
	for(int i = 1; i < ANS.size(); i++){
		printf(" %d",ANS[i]+1);
	}
	printf("\n");
}


int main(){

	while(true){
		scanf("%d %d",&M,&N);
		if(M == 0 && N == 0)break;

		func();
	}
	return 0;
}