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:
#include<iostream>
#include<stdio.h>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;

#define INF (1<<24)

struct Event {
  int id,u,v,w;
  Event (int id=0,int u=0,int v=0,int w=0):id(id),u(u),v(v),w(w){}
  bool operator < (const Event &p)const{
    if(v==0&&p.v==0)return (u==p.u&&w==p.w&&id>p.id)||(u==p.u&&w>p.w)||(u>p.u);
    else return (u==p.u&&v==p.v&&id>p.id)||(u==p.u&&v>p.v)||(u>p.u);
  }
};

priority_queue<Event> Q;

int m,n;
int U[2][10],ID[2][10];

vector<int> ans;

bool init();
bool input();
int minimamU();
int check0();
int check1(Event);
void car_in(Event);
void car_out(Event);

int main(){
  Event event;
  while(init()&&input()){
    while(!Q.empty()){
      event=Q.top();Q.pop();
      
      if(event.v==1){
	car_in(event);
      }else if(event.v==0){
	car_out(event);
      }
      /*
      cout<<event.id<<' '<<event.u<<' '<<event.v<<' '<<event.w<<endl;
      for(int i=0;i<2;i++){
	for(int j=0;j<m;j++){
	  if(ID[i][j]!=INF){
	    printf("%2d %2d  ",ID[i][j],U[i][j]);
	  }else{
	    cout<<"       ";
	  }
	}
	cout<<endl;
      }
      cout<<endl;
      */
    }
      
    for(int i=0;i<(int)ans.size();i++){
      if(i)cout<<' ';
      cout<<ans[i];
    }
    cout<<endl;
  }

  return 0;
}


void car_in(Event event){
  int A=check0(),B;
  if(A!=INF){
    U[0][A]=event.u+event.w;
    ID[0][A]=event.id;
    Q.push(Event(ID[0][A],U[0][A],0,A));
  }else{
    B=check1(event);
    if(B==INF){
      event.u=minimamU();
      Q.push(event);
    }else{
      U[1][B]=max(U[0][B],event.u+event.w);
      ID[1][B]=ID[0][B];
      U[0][B]=event.u+event.w;
      ID[0][B]=event.id;
      Q.push(Event(ID[0][B],U[0][B],0,B));
    }
  }
}

void car_out(Event event){
  int I=-1,J=-1;
  for(int i=0;i<2;i++)
    for(int j=0;j<m;j++)
      if(U[i][j]==event.u&&ID[i][j]==event.id){
	I=i; J=j;
      }
  if(I==-1&&J==-1)return;
  if(I==1)return;

  U[I][J]=INF;
  ID[I][J]=INF;
  ans.push_back(event.id);

  if(ID[1][J]!=INF){
    swap(ID[0][J],ID[1][J]);
    swap(U[0][J],U[1][J]);
    Q.push(Event(ID[0][J],U[0][J],0,J));
  }
    

}

int check0(){
  for(int i=0;i<m;i++)if(ID[0][i]==INF)return i;
  return INF;
}
int check1(Event event){
  int mini=INF,miniI,x;
  for(int i=0;i<m;i++){
    if(ID[1][i]!=INF)continue;
    x=U[0][i]-(event.u+event.w);
    if(x<0)continue;
    if(x<mini){
      mini=x;
      miniI=i;
    }
  }
  if(mini!=INF)return miniI;
  
  
  for(int i=0;i<m;i++){
    if(ID[1][i]!=INF)continue;
    x=(event.u+event.w)-U[0][i];
    if(x<mini){
      mini=x;
      miniI=i;
    }
  }
  if(mini!=INF)return miniI;
  
  return INF;
}

bool init(){
  while(!Q.empty())Q.pop();
  for(int i=0;i<2;i++){
    for(int j=0;j<10;j++){
      U[i][j]=ID[i][j]=INF;
    }
  }
  ans.clear();
  return true;
}

bool input(){
  int a;
  cin>>m>>n;
  if(m==0&&n==0)return false;
  for(int i=0;i<n;i++){
    cin>>a;
    Q.push(Event(i+1,i*10,1,a));
  }
  return true;
}

int minimamU(){
  int res=INF;
  for(int i=0;i<2;i++){
    for(int j=0;j<m;j++){
      res=min(res,U[i][j]);
    }
  }
  return res;
}