#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0)
            return 0;

        queue<pair<int, int> > t;
        for(int i=0; i<n; ++i){
            int a;
            cin >> a;
            t.push(make_pair(i+1, a));
        }

        vector<vector<int> > car(2, vector<int>(m, -1));
        vector<vector<int> > rest(2, vector<int>(m));

        int next = 0;
        queue<pair<int, int> > wait;
        vector<int> ret;
        while(ret.size() < n){
            if(next == 0 && !t.empty()){
                wait.push(t.front());
                t.pop();
                next = 10;
            }
            -- next;

            for(int i=0; i<2; ++i){
                for(int j=0; j<m; ++j){
                    if(car[i][j] != -1)
                        -- rest[i][j];
                }
            }

            for(int j=0; j<m; ++j){
                if(car[0][j] != -1 && rest[0][j] <= 0){
                    ret.push_back(car[0][j]);
                    car[0][j] = -1;
                }
                if(car[0][j] == -1 && car[1][j] != -1 && rest[1][j] <= 0){
                    ret.push_back(car[1][j]);
                    car[1][j] = -1;
                }
            }

            while(!wait.empty()){
                bool ok = false;
                for(int i=0; i<m; ++i){
                    if(car[1][i] == -1){
                        car[1][i] = wait.front().first;
                        rest[1][i] = wait.front().second;
                        wait.pop();
                        ok = true;
                        break;
                    }
                }
                if(ok)
                    continue;

                int k = -1;
                for(int i=0; i<m; ++i){
                    if(car[0][i] == -1 && rest[1][i] >= wait.front().second && (k == -1 || rest[1][i] < rest[1][k]))
                        k = i;
                }

                if(k == -1){
                    for(int i=0; i<m; ++i){
                        if(car[0][i] == -1 && (k == -1 || (rest[1][i] > rest[1][k])))
                            k = i;
                    }
                }

                if(k == -1)
                    break;
                car[0][k] = wait.front().first;
                rest[0][k] = wait.front().second;
                wait.pop();
            }
        }

        cout << ret[0];
        for(int i=1; i<n; ++i)
            cout << ' ' << ret[i];
        cout << endl;
    }
}