#include <bits/stdc++.h>

using namespace std;
????
class Car{
public:
????int id, in_time, rest_time;
????Car(){}
????Car(int a, int b, int c): id(a), in_time(b), rest_time(c){}
};
????
const int INF = (1<<28);
????
int m, n;
queue<Car> que;
Car pa[20];
vector<int> ans;
????
void init(){
????for(int i=0;i<m*2;i++) pa[i] = Car(-1, -1, -1);
????while(!que.empty()) que.pop();
????ans.clear();
}
????
bool full_park(){
????for(int i=0;i<m*2;i++) if(pa[i].id == -1) return false;
????return true;
}
??
void car_in(int t){
????while(!que.empty()){
????????Car c = que.front();
????????if(c.in_time > t || full_park()) break;
????????int pos = -1;
????????for(int i=1;i<m*2;i+=2){
????????????if(pos == -1 && pa[i].id == -1 && pa[i-1].id == -1) pos = i;
????????}
????????if(pos != -1){
????????????pa[pos] = c;
????????????que.pop();
????????????continue;
????????}
????????int valm = INF;
????????pos = -1;
????????for(int i=0;i<m*2;i+=2){
????????????if(pa[i].id != -1) continue;
????????????if(pa[i+1].rest_time >= c.rest_time){
????????????????if(valm > abs(pa[i+1].rest_time - c.rest_time)){
????????????????????valm = abs(pa[i+1].rest_time - c.rest_time);
????????????????????pos = i;
????????????????}
????????????}
????????}
????????if(pos != -1){
????????????pa[pos] = c;
????????????que.pop();
????????????continue;
????????}
????????valm = INF;
????????pos = -1;
????????for(int i=0;i<m*2;i+=2){
????????????if(pa[i].id != -1) continue;
????????????if(valm > abs(pa[i+1].rest_time - c.rest_time)){
????????????????valm = abs(pa[i+1].rest_time - c.rest_time);
????????????????pos = i;
????????????}
????????}
????????if(pos != -1){
????????????pa[pos+1].rest_time = c.rest_time;
????????????pa[pos] = c;
????????????que.pop();
????????????continue;
????????}
????}
}
??
void car_out(int t){
????while(1){
????????int valm = INF;
????????int ex_pos = -1;
????????for(int i=0;i<m*2;i++){
????????????if(pa[i].id == -1) continue;
????????????if(pa[i].rest_time > 0) continue;
????????????if(valm > pa[i].rest_time){
????????????????valm = pa[i].rest_time;
????????????????ex_pos = i;
????????????}
????????}
????????if(ex_pos == -1) break;
????????ans.push_back(pa[ex_pos].id);
????????pa[ex_pos] = Car(-1, -1, -1);
????}
}
??
bool is_empty(){
????for(int i=0;i<m*2;i++) if(pa[i].id != -1) return false;
????return true;
}
??
main(){
????while(cin >> m >> n && (m|n)){
????????init();
????????for(int i=0;i<n;i++){
????????????Car in = Car(i+1, i*10, 0);
????????????cin >> in.rest_time;
????????????que.push(in);
????????}
????????for(int t=0;;t+=1){
????????????if(t > 0 && is_empty()) break;
????????????for(int i=0;i<m*2;i++){
????????????????if(pa[i].id == -1) continue;
????????????????pa[i].rest_time -= 1;
????????????}
????????????car_out(t);
????????????car_in(t);
????????}
????????cout << ans[0];
????????for(int i=1;i<ans.size();i++) cout << " " << ans[i];
????????cout << endl;
????}
}