#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int M, N;
    while(cin >> M >> N && M){
        vector<int> T(N);
        REP(i, N) cin >> T[i];
        deque<int> parking[10];
        deque<int> time[10];
        deque<int> wait;
        vector<int> ans;
        for(int t = 0; (int)ans.size() < N; t++){
            //cout << t << ":" << endl;
            //REP(i, M) { printf("parking[%d]:", i); for(auto& pi : parking[i]) cout << pi << " "; cout << endl; }
            //REP(i, M) { printf("time[%d]:", i); for(auto& ti : time[i]) cout << ti << " "; cout << endl; }
            for(int i = 0; i < M; i++){
                while(!time[i].empty() && time[i].back() <= 0){
                    ans.push_back(parking[i].back());
                    parking[i].pop_back();
                    time[i].pop_back();
                }
            }

            if(t % 10 == 0 && t / 10 < N){
                wait.push_back(t / 10);
            }

            while(!wait.empty()){
                int id = wait.front(); wait.pop_front();
                if(any_of(parking, parking + M, [](deque<int>& d){ return d.empty(); })){
                    for(int i = 0; i < M; i++) if(parking[i].empty()){
                        parking[i].push_back(id);
                        time[i].push_back(T[id]);
                        break;
                    }
                }else{
                    vector<pair<int, int>> vp;
                    for(int i = 0; i < M; i++) if(time[i].size() == 1) vp.push_back(make_pair(time[i].front(), i));
                    if(vp.empty()){
                        wait.push_front(id);
                        break;
                    }else{
                        sort(vp.begin(), vp.end());
                        int k = 0;
                        while(k + 1 < (int)vp.size() && vp[k].first < T[id]) k++;
                        int c = vp[k].second;
                        parking[c].push_back(id);
                        time[c].push_back(T[id]);
                    }
                }
            }

            for(int i = 0; i < M; i++)
                for(auto& t : time[i])
                    t--;
        }
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] + 1;
            if(i == ans.size() - 1) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}