Problem: There are various parking lots such as three-dimensional type and tower type in the city to improve the utilization efficiency of the parking lot. In some parking lots, a "two-stage parking device" as shown in the figure is installed in one parking space to secure a parking space for two cars. This two-stage parking device allows one to be placed on an elevating pallet (a flat iron plate on which a car is placed) and parked in the upper tier, and the other to be parked in the lower tier.

In a parking lot that uses such a two-stage parking device, it is necessary to take out the car parked in the lower tier and dismiss it each time to put in and out the car in the upper tier, so be sure to manage it. Keeps the key to the parked car and puts it in and out as needed.

| <image>
--- | ---

Tsuruga Parking Lot is also one of the parking lots equipped with such a two-stage parking device, but due to lack of manpower, the person who cannot drive the car has become the manager. Therefore, once the car was parked, it could not be moved until the customer returned, and the car in the upper tier could not be put out until the owner of the car in the lower tier returned.

Create a program that meets the rules of the Tsuruga parking lot to help the caretaker who has to handle the cars that come to park one after another.

Tsuruga parking lot facilities

* There is one or more parking spaces, all equipped with a two-stage parking device.
* Each parking space is numbered starting from 1.
* Initially, it is assumed that no car is parked in the parking lot.



Tsuruga parking lot adopts the following rules.

When to stop the car

* The caretaker will be informed of the parking time of the car to be parked.
* We will park first in the parking space where no car is parked.
* If there is no parking space where no car is parked, park in an empty parking space. However, if there are multiple such parking spaces, follow the procedure below to park.
1. If the remaining parking time of a parked car is longer than the parking time of the car you are trying to park, park in the parking space with the smallest difference.
2. If the remaining parking time of any parked car is less than the parking time of the car you are trying to park, park in the parking space with the smallest difference.
* If the car is full (no parking space available), the car you are trying to park will wait in turn until the parking space is available. As soon as it becomes available, we will park in order from the first car we were waiting for.



* Under each condition, if there are multiple applicable parking spaces, the parking space number will be the smallest. In addition, if there are cars leaving at the same time, parking will start after all the cars leaving at the same time, and as long as there are cars waiting, the cars that can be parked will be parked at the same time.

When the car leaves

* Cars that have passed the parking time notified by the manager will be shipped.
* If there are cars in multiple parking spaces that have passed the parking time at the same time, the car with the smallest parking space number will be shipped first.
* If the parking time of the car parked in the upper row has expired, you will have to wait until the car in the lower row leaves the garage. The upper car will be delivered at the same time after the lower car is delivered.



The figure below shows an example of how to park at Tsuruga Parking Lot. In this example, the number of parking spaces is 3, and cars B to E are already parked. Consider that car A, which has a parking time of 70 minutes, arrives there. You cannot park because two cars are already parked in parking space 3, and you will have to park in either parking space 1 or parking space 2 that is still vacant. Car B parked in parking space 1 has 50 minutes remaining and car C parked in parking space 2 has 22 minutes remaining, both of which are less than car A's parking time, so car A's parking Park in parking space 1 where car B, which has a smaller time difference, is parked. As a result, car B, which was parked earlier, will be in the upper row.

<image>


Create a program that inputs the number of parking spaces m, the number of cars parked n, and the parking time t of each car, and outputs the car reference numbers in the order in which they come out of the parking lot. However, cars are assigned an integer reference number starting with 1 in the order of input, and cars will come to park one by one every 10 minutes in the order of the reference number.



Input

A sequence of multiple datasets is given as input. The end of the input is indicated by two lines of zeros. Each dataset is given in the following format:


m n
t1
t2
::
tn


The first line gives the number of two-stage parking devices m (1 ≤ m ≤ 10) and the number of cars parked n (1 ≤ n ≤ 100). The next n lines are given the parking time ti (1 ≤ ti ≤ 120) for the i-th car.

The number of datasets does not exceed 20.

Output

The reference number of the car is output to one line in the order of coming out of the parking lot for each data set. Please output the reference numbers separated by blanks.

Example

Input

3 5
90
52
82
84
70
2 4
10
30
40
60
0 0


Output

2 5 1 4 3
1 2 4 3

Solution (in CPP):

Solution:
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

double dp[101][101];
double table[100][100];

class SPACE{
private:
	int mUpTime;
	int mLoTime;
	int mUpCar;
	int mLoCar;
	bool mUpUsed;
	bool mLoUsed;

public:
	SPACE() : mUpTime(0),mLoTime(0),mUpUsed(false),mLoUsed(false),mUpCar(0),mLoCar(0){}
	void setUpTime(int time){ mUpTime = time;}
	void setLoTime(int time){ mLoTime = time;}
	void setUpCar(int car){ mUpCar = car;}
	void setLoCar(int car){ mLoCar = car;}
	void setIsUpUsed(bool flag) { mUpUsed = flag;}
	void setIsLoUsed(bool flag) { mLoUsed = flag;}

	int getUpTime() const{ return mUpTime;}
	int getLoTime() const{ return mLoTime;}
	int getUpCar() const{ return mUpCar;}
	int getLoCar() const{ return mLoCar;}
	int isUpUsed() const{ return mUpUsed;}
	int isLoUsed() const{ return mLoUsed;}
};

class PARK{
private:
	class SPACE* mSpace;
	int mNum;
	int mParked;

	int getLeastDiffIdx(int src){
		int res=-1;
		int diff = INF;
		for(int i=0;i<mNum;i++){
			if(!mSpace[i].isUpUsed() && mSpace[i].isLoUsed()){
				if(diff > abs(mSpace[i].getLoTime()-src)){
					diff = abs(mSpace[i].getLoTime()-src);
					res = i;
				}
			}
		}

		return res;
	}

	int getLeastTime(){
		int minTime = INF;
		for(int i=0;i<mNum;i++){
			if(mSpace[i].isLoUsed()){
				minTime=min(mSpace[i].getLoTime() <= 0 ? minTime : mSpace[i].getLoTime(),minTime);
			}

			if(mSpace[i].isUpUsed()){
				minTime=min(mSpace[i].getUpTime() <= 0 ? minTime : mSpace[i].getUpTime(),minTime);
			}
		}

		return minTime;
	}

public:
	PARK() : mSpace(NULL),mNum(0),mParked(0) {}
	PARK(SPACE* space,int num){
		mSpace = space;
		mNum = num;
	}
	SPACE getSpace(int idx) const{
		return mSpace[idx];
	}

	bool parkCar(int time,int id){
		for(int i=0;i<mNum;i++){
			if(!mSpace[i].isLoUsed() && !mSpace[i].isUpUsed()){
				mSpace[i].setLoCar(id);
				mSpace[i].setLoTime(time);
				mSpace[i].setIsLoUsed(true);
				return true;
			}
		}

		int idx=-1;
		int pos=-1;
		int diff = INF;

		for(int i=0;i<mNum;i++){
			if(!mSpace[i].isUpUsed() && mSpace[i].getLoTime() >= time){
				if(diff > abs(mSpace[i].getLoTime()-time)){
					diff = abs(mSpace[i].getLoTime()-time);
					idx = i;
					pos = 0;
				}
			}

			else if(!mSpace[i].isLoUsed() && mSpace[i].getUpTime() >= time){
				if(diff > abs(mSpace[i].getUpTime()-time)){
					diff = abs(mSpace[i].getUpTime()-time);
					idx = i;
					pos = 1;
				}
			}
		}

		if(idx!=-1){
			if(pos == 0){
				mSpace[idx].setUpTime(mSpace[idx].getLoTime());
				mSpace[idx].setUpCar(mSpace[idx].getLoCar());
				mSpace[idx].setIsUpUsed(true);

				mSpace[idx].setLoTime(time);
				mSpace[idx].setLoCar(id);
				mSpace[idx].setIsLoUsed(true);
				return true;
			}
			else if(pos==1){
				mSpace[idx].setLoTime(time);
				mSpace[idx].setLoCar(id);
				mSpace[idx].setIsLoUsed(true);
				return true;
			}
		}

		diff = INF;

		for(int i=0;i<mNum;i++){
			if(!mSpace[i].isUpUsed() && mSpace[i].getLoTime() < time){
				if(diff > abs(mSpace[i].getLoTime()-time)){
					diff = abs(mSpace[i].getLoTime()-time);
					idx = i;
					pos = 0;
				}
			}

			else if(!mSpace[i].isLoUsed() && mSpace[i].getUpTime() < time){
				if(diff > abs(mSpace[i].getUpTime()-time)){
					diff = abs(mSpace[i].getUpTime()-time);
					idx = i;
					pos = 1;
				}
			}
		}

		if(idx!=-1){
			if(pos==0){
				mSpace[idx].setUpTime(mSpace[idx].getLoTime());
				mSpace[idx].setUpCar(mSpace[idx].getLoCar());
				mSpace[idx].setIsUpUsed(true);
				mSpace[idx].setLoTime(time);
				mSpace[idx].setLoCar(id);
				return true;
			}
			else if(pos==1){
				mSpace[idx].setLoTime(time);
				mSpace[idx].setLoCar(id);
				mSpace[idx].setIsLoUsed(true);
				return true;
			}
		}

		return false;
	}

	void subTime(int t){
		for(int i=0;i<mNum;i++){
			int utmp = mSpace[i].getUpTime();
			int ltmp = mSpace[i].getLoTime();
			if(mSpace[i].isUpUsed()) mSpace[i].setUpTime(utmp-t);
			if(mSpace[i].isLoUsed()) mSpace[i].setLoTime(ltmp-t);
		}
	}

	queue<int> outCar(){
		queue<int> res;
		for(int i=0;i<mNum;i++){

			if(mSpace[i].isLoUsed() && mSpace[i].getLoTime()<=0){
				res.push(mSpace[i].getLoCar());
				mSpace[i].setIsLoUsed(false);
				mSpace[i].setLoTime(0);

				if(mSpace[i].isUpUsed() && mSpace[i].getUpTime()<=0){
					res.push(mSpace[i].getUpCar());
					mSpace[i].setIsUpUsed(false);
					mSpace[i].setUpTime(0);
				}
			}
			else if(!mSpace[i].isLoUsed() && mSpace[i].isUpUsed()){
				if(mSpace[i].getUpTime()<=0){
					res.push(mSpace[i].getUpCar());
					mSpace[i].setIsUpUsed(false);
					mSpace[i].setUpTime(0);
				}
			}
		}
		return res;
	}

	int getParked(){
		int res=0;
		for(int i=0;i<mNum;i++){
			if(mSpace[i].isLoUsed()) res++;
			if(mSpace[i].isUpUsed()) res++;
		}

		return res;
	}

	void printState(){
		for(int i=0;i<mNum;i++){
			printf("space %d\n",i);
			printf("used=%d lower id=%d  remain time=%d\n",
				mSpace[i].isLoUsed(),mSpace[i].getLoCar(),mSpace[i].getLoTime());
			printf("used=%d upper id=%d  remain time=%d\n",
				mSpace[i].isUpUsed(),mSpace[i].getUpCar(),mSpace[i].getUpTime());			
		}
		printf("\n");
	}
};

int main(){

	int n,m;
	while(~scanf("%d %d",&m,&n)){
		if(m==n && n==0) break;
		int* car = new int[n+1];
		for(int i=1;i<=n;i++){
			scanf("%d",car+i);
		}
		SPACE* space = new SPACE[m];
		PARK park(space,m);

		queue<int> res;
		queue<P> que;

		for(int time=0,i=1;;time++){
			if(res.size() == n) break;

			if(time == 10 && i <= n){
				que.push(P(i,car[i]));
				i++;
				time=0;
			}

			while(!que.empty()){
				int id = que.front().first;
				int stay = que.front().second;				
				if(!park.parkCar(stay,id)) break;
				que.pop();
			}

			park.subTime(1);
			queue<int> tmp = park.outCar();
			while(!tmp.empty()){ res.push(tmp.front()); tmp.pop(); }
			
		}

		vector<int> ans;
		while(!res.empty()){
			ans.push_back(res.front());
			res.pop();
		}

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

		delete[] car;
		delete[] space;
	}
}