#include<iostream>
#include<vector>
using namespace std;

const int NIL = -1;
const int INF = 12000;
enum {UNDER, ABOVE};

int count;

class Car {
public:
    int id, arrive, sojourn;
    int leave;
    Car(int i, int a, int s) :id(i), arrive(a), sojourn(s) {}
    void park(int t) {leave = t + sojourn;}
    int remain() {return leave - count;}
};

int main() {
    int n, m;
    while(cin >> m >> n, m | n) {
        vector<vector<int>> parking(2, vector<int>(m, NIL));
        vector<Car> car;
        for(int i = 0; i < n; ++i) {
            int t;
            cin >> t;
            car.push_back(Car(i, i * 10, t));
        }

        int head = 0;
        vector<int> answer;
        for(count = 0; answer.size() < n; ++count) {
            // leave
            while(true) {
                bool out = false;
                for(int i = 0; i < m; ++i) {
                    int id = parking[UNDER][i];
                    if(id == NIL) continue;
                    if(car[id].leave > count) continue;
                    answer.push_back(id + 1);
                    parking[UNDER][i] = parking[ABOVE][i];
                    parking[ABOVE][i] = NIL;
                    out = true;
                    break;
                }
                if(!out) break;
            }
            // park
            // empty
            while(head < n && car[head].arrive <= count) {
                bool in = false;
                for(int i = 0; i < m; ++i) {
                    int id = parking[UNDER][i];
                    if(id != NIL) continue;
                    parking[UNDER][i] = head;
                    car[head].park(count);
                    ++head;
                    in = true;
                    break;
                }
                if(!in) break;
            }
            // not empty
            while(head < n && car[head].arrive <= count) {
                int dif1 = INF, target1 = NIL;
                int dif2 = INF, target2 = NIL;
                for(int i = 0; i < m; ++i) {
                    if(parking[ABOVE][i] != NIL) continue;
                    int id = parking[UNDER][i];
                    if(car[id].remain() >= car[head].sojourn) {
                        if(dif1 > car[id].remain() - car[head].sojourn) {
                            dif1 = car[id].remain() - car[head].sojourn;
                            target1 = i;
                        }
                    } else {
                        if(dif2 > car[head].sojourn - car[id].remain()) {
                            dif2 = car[head].sojourn - car[id].remain();
                            target2 = i;
                        }
                    }
                }
                bool in = false;
                if(target1 != NIL) {
                    parking[ABOVE][target1] = parking[UNDER][target1];
                    parking[UNDER][target1] = head;
                    car[head].park(count);
                    ++head;
                    in = true;
                } else if (target2 != NIL) {
                    parking[ABOVE][target2] = parking[UNDER][target2];
                    parking[UNDER][target2] = head;
                    car[head].park(count);
                    ++head;
                    in = true;
                }
                if(!in) break;
            }
        }

        for(int i = 0; i < n; ++i) cout << (i == 0 ? "" : " ") << answer[i];
        cout << endl;
    }
}