#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int m, n;
  while(cin >> m>>n,m||n) {
    int t[n];
    REP(i,n) cin >> t[i];

    queue<int> Q;
    Q.push(0);
    int time = 0;
    int rest[m][2];
    int id[m][2];
    memset(rest, 0, sizeof(rest));
    memset(id, 0, sizeof(id));
    vector<int> ans;
    while(1) {
      int now;
      int mi = INF;
      int p = 0;

      bool f = 0;
      REP(i, m)
        if (id[i][0])
          f=1;
      if (!f && Q.empty() && time/10 >= n)
        break;
      if (Q.empty()) goto label;
      now = Q.front();
      // Ô
      REP(i, m) {
        if (id[i][0]==0) {
          id[i][0] = now+1;
          rest[i][0] = t[now];
          Q.pop();
          goto label;
        }
      }
      REP(i,m) {
        if (id[i][1]==0) {
          if (rest[i][0] >= t[now]) {
            if (mi > rest[i][0] - t[now]) {
              mi = rest[i][0] - t[now];
              p = i;
            }
          }
        }
      }
      if (mi != INF) {
        id[p][1] = id[p][0];
        id[p][0] = now+1;
        rest[p][1] = rest[p][0];
        rest[p][0] = t[now];
        Q.pop();
        goto label;
      }
      REP(i,m) {
        if (id[i][1]==0) {
          if (mi > t[now] - rest[i][0]) {
            mi = t[now] - rest[i][0];
            p = i;
          }
        }
      }
      if (mi != INF) {
        id[p][1] = id[p][0];
        id[p][0] = now+1;
        rest[p][1] = rest[p][0];
        rest[p][0] = t[now];
        Q.pop();
      }
      
    label:
      // Ôoß
      time++;
      REP(i,m) {
        REP(j,2)
          if (rest[i][j])
            rest[i][j]--;
      }
      // REP(i, m) {
      //   printf("%d %d  ", id[i][0], id[i][1]);
      // }cout << endl;
      // REP(i, m) {
      //   printf("%d %d  ", rest[i][0], rest[i][1]);
      // }cout << endl;
      // oÉ
      REP(i,m) {
        if (id[i][0] && rest[i][0] == 0) {
          ans.push_back(id[i][0]);
          id[i][0] = id[i][1];
          id[i][1] = 0;
          rest[i][0] = rest[i][1];
          rest[i][1] = 0;
          if (id[i][0] && rest[i][0] == 0) {
            ans.push_back(id[i][0]);
            id[i][0] = 0;
          }
        }
      }

      // Vµ¢Ô
      if (time%10==0 && time/10 < n)
        Q.push(time/10);
    }
    REP(i, ans.size()) {
      if (i)cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
}