#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<int> t(m);
        vector<int> ans;
        vector<pair<int, int>> A(n*2, {-1, -1});
        for (auto &&i : t) scanf("%d", &i);
        int cur = 0;
        for (int _ = 0; _ < 30000; ++_) {
            for (int i = 0; i < n; ++i) {
                if(~A[i].first && A[i].second <= _){
                    ans.emplace_back(A[i].first);
                    A[i] = A[i+n];
                    A[i+n] = {-1, -1};
                }
                if(~A[i].first && A[i].second <= _){
                    ans.emplace_back(A[i].first);
                    A[i] = A[i+n];
                    A[i+n] = {-1, -1};
                }
            }
            while(cur < m && cur*10 <= _){
                int ok = 0;
                for (int i = 0; i < n; ++i) {
                    if(!~A[i].first){
                        ok = 1;
                        A[i] = {cur+1, _+t[cur]};
                        cur++;
                        break;
                    }
                }
                if(ok) continue;
                int to = -1, too = -1;
                for (int i = 0; i < n; ++i) {
                    if(!~A[i+n].first){
                        if(A[i].second >= _+t[cur]){
                            if(!~to || A[i].second < A[to].second) to = i;
                        }
                        else {
                            if(!~too || A[i].second > A[too].second) too = i;
                        }
                    }
                }
                if(~to){
                    A[to+n] = A[to];
                    A[to] = {cur+1, _+t[cur]};
                    cur++;
                }else if(~too){
                    A[too+n] = A[too];
                    A[too] = {cur+1, _+t[cur]};
                    cur++;
                } else break;
            }
        }
        for (int i = 0; i < ans.size(); ++i) {
            if(i) printf(" ");
            printf("%d", ans[i]);
        }
        puts("");
    }
    return 0;
}
