#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;
const int INF = 1000000000;

int M, N;
vector<int> t;

bool input() {
  cin >> M >> N;
  if (!M && !N) {
    return false;
  }
  t.resize(N);
  for (int i = 0; i < N; ++i) {
    cin >> t[i];
  }
  return true;
}

void solve() {
  int time = 0;
  vector<int> answer;
  queue<int> tyusha_machi;
  vector<P> park_id;
  vector<P> park_time;
  park_id.resize(M);
  park_time.resize(M);
  for (int i = 0; i < M; ++i) {
    park_id[i].first = park_id[i].second = -1;
    park_time[i].first = park_time[i].second = -1;
  }

  while (answer.size() < N) {
    if (time % 10 == 0 && time / 10 < N) {
      tyusha_machi.push(time / 10);
    }

    // shukko
    for (int i = 0; i < M; ++i) {
      if (park_id[i].first != -1 && park_time[i].first <= time) {
        answer.push_back(park_id[i].first);
        park_id[i].first = -1;
        park_time[i].first = -1;
      }
      if (park_id[i].first == -1 && park_id[i].second != -1 && park_time[i].second <= time) {
        answer.push_back(park_id[i].second);
        park_id[i].second = -1;
        park_time[i].second = -1;
      }
    }

    // tyusha (try second floor)
    while (!tyusha_machi.empty()) {
      int space_id = -1;
      for (int i = 0; i < M; ++i) {
        if (park_id[i].first == -1 && park_id[i].second == -1) {
          space_id = i;
          break;
        }
      }
      if (space_id == -1) {
        break;
      }
      int car_id = tyusha_machi.front();
      tyusha_machi.pop();
      park_id[space_id].second = car_id;
      park_time[space_id].second = time + t[car_id];
    }

    // tyusha (try first floor)
    while (!tyusha_machi.empty()) {
      int space_id = -1;
      bool b = false;
      int tt = time + t[tyusha_machi.front()];
      for (int i = 0; i < M; ++i) {
        if (park_id[i].first != -1) {
          continue;
        }
        if (tt <= park_time[i].second) {
          b = true;
          break;
        }
      }
      if (b) {
        int min_t = INF;
        for (int i = 0; i < M; ++i) {
          if (park_id[i].first != -1) {
            continue;
          }
          if (tt <= park_time[i].second) {
            if (min_t > park_time[i].second) {
              min_t = park_time[i].second;
              space_id = i;
            }
          }
        }
      } else {
        int max_t = -1;
        for (int i = 0; i < M; ++i) {
          if (park_id[i].first != -1) {
            continue;
          }
          if (max_t < park_time[i].second) {
            max_t = park_time[i].second;
            space_id = i;
          }
        }
      }
      if (space_id == -1) {
        break;
      }
      int car_id = tyusha_machi.front();
      tyusha_machi.pop();
      park_id[space_id].first = car_id;
      park_time[space_id].first = time + t[car_id];
    }
    
    ++time;
  }

  for (int i = 0; i < N; ++i) {
    if (i) cout << " ";
    cout << answer[i] + 1;
  }
  cout << endl;
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}