#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


typedef queue <int> QUEUE;
const int SIZE = 101;
const int NONE = -1;
int m, n;
int T[SIZE]; 
int P[11][2]; 
int PC[11];
int R[SIZE]; 
QUEUE Q;
int t;
int L[SIZE];
int LC;

void init() {
    Q = QUEUE();
    t = 0;
    for ( int i = 0; i < 11; ++ i ) {
        for ( int j = 0; j < 2; ++ j ) {
            P[i][j] = NONE;
        }
    }
    for ( int i = 0; i < 11; ++ i ) {
        PC[i] = 0;
    }
    for ( int i = 0; i < SIZE; ++ i ) {
        R[i] = 0;
    }
    LC = 0;
    for ( int i = 0; i < SIZE; ++ i ) {
        L[i] = 0;
    }
}

void comeon( int k ) {
    Q.push( k );
}

void goaway() {
    for ( int i = 0; i < m; ++ i ) {
        if ( PC[i] == 2 ) {
            int id = P[i][0];
            if ( R[id] > 0 ) continue;
            R[id] = 0;
            L[LC++] = id;
            P[i][0] = P[i][1];
            P[i][1] = NONE;
            PC[i] --;
        }
        if ( PC[i] == 1 ) {
            int id = P[i][0];
            if ( R[id] > 0 ) continue;
            R[id] = 0;
            L[LC++] = id;
            P[i][0] = NONE;
            PC[i] --;
        }
    }
}

void parking( int id, int parkID, int d ) {
    R[id] = T[id];
    if ( d == 1 ) {
        P[parkID][1] = P[parkID][0];
        P[parkID][0] = id;
    } else {
        P[parkID][0] = id;
    }
    PC[parkID] ++;
    Q.pop();
}

void parking() {
    while ( ! Q.empty() ) {
        bool flag = false; 
        int id = Q.front();
        int minParkID = -1; 
        int minDiff = INT_MAX;
        
        for ( int i = 0; i < m; ++ i ) {
            if ( PC[i] != 0 ) continue;
            parking( id, i, 0 );
            flag = true;
            goto out_1;
        }
        
        minParkID = -1;
        minDiff = INT_MAX;
        for ( int i = 0; i < m; ++ i ) {
            if ( PC[i] != 1 ) continue;
            int pid = P[i][0]; 
            if ( R[pid] < T[id] ) continue;
            int diff = abs( T[id] - R[pid] );
            if ( diff < minDiff ) {
                minParkID = i;
                minDiff = diff;
            }
        }
        if ( minParkID != -1 ) {
            parking( id, minParkID, 1 );
            flag = true;
            goto out_1;
        }
        
        minParkID = -1;
        minDiff = INT_MAX;
        for ( int i = 0; i < m; ++ i ) {
            if ( PC[i] != 1 ) continue;
            int pid = P[i][0];
            if ( R[pid] >= T[id] ) continue;
            int diff = abs( T[id] - R[pid] );
            if ( diff < minDiff ) {
                minParkID = i;
                minDiff = diff;
            }
        }
        if ( minParkID != -1 ) {
            parking( id, minParkID, 1 );
            flag = true;
            goto out_1;
        }
        
    out_1:;
        if ( ! flag ) break;
    }
}

void advance() {
    int length = 1;
    for ( int i = 0; i < m; ++ i ) {
        for ( int j = 0; j < 2; ++ j ) {
            if ( P[i][j] == NONE ) continue;
            int id = P[i][j];
            R[id] -= length;
        }
    }
    t += length;
}

void debug() {
    cout << "# Debug" << endl;
    cout << "t = " << t << endl;
    for ( int i = 0; i < 2; ++ i ) {
        cout << "P" << i << ": ";
        for ( int j = 0; j < m; ++ j ) {
            cout << P[j][i] << ", ";
        }
        cout << endl;
    }
    cout << "R: ";
    for ( int i = 0; i < n; ++ i ) {
        cout << R[i] << ", ";
    }
    cout << endl;
    cout << "Q: ";
    QUEUE Q2 = Q;
    while ( ! Q2.empty() ) {
        cout << Q2.front() << ", ";
        Q2.pop();
    }
    cout << endl;
    
    cout << endl;
}

void solve() {
    init();

    int next_id = 0;
    while ( LC < n ) {
        if ( t % 10 == 0 && next_id < n ) comeon(next_id++);
        goaway();
        parking();
        advance();
    }
}

void input() {
    for ( int i = 0; i < n; ++ i ) {
        cin >> T[i];
    }
}

void output() {
    for ( int i = 0; i < n; ++ i ) {
        cout << L[i] + 1;
        if ( i + 1 < n ) cout << " ";
    }
    cout << endl;
}

int main() {
    while ( cin >> m >> n && m ) {
        input();
        solve();
        output();
    }
    return 0;
}

Measured memory_bytes: 0