#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<climits>
#include<vector>
#include<algorithm>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 20

using namespace std;

typedef pair<int,int> ii;

int n,m;// n : the number of the space
deque<int> car,TIME;
deque<int> space[MAX];// tyusya space
deque<int> Index[MAX];
deque<ii> waiting;
vector<int> ANS; 

bool Insert1(int cindex,int cTIME){
  rep(i,n){
    if(space[i].size() >= 2)continue;
    if(space[i].empty()){
      space[i].push_back(cTIME);
      Index[i].push_back(cindex);
      return true;
    }
  }
  return false;
}

bool Insert2(int cindex,int cTIME){
  int pos = -1;
  rep(i,n){
    if(space[i].size() >= 2)continue;
    if(space[i].front() < cTIME)continue;
    if(pos == -1)pos = i;
    else {
      if( abs(space[i].front()-cTIME) < abs(space[pos].front()-cTIME) ){
	pos = i;
      }
    }
  }

  if(pos == -1)return false;

  space[pos].push_front(cTIME);
  Index[pos].push_front(cindex);
  return true;
}

bool Insert3(int cindex,int cTIME){
  int pos = -1;
  rep(i,n){
    if(space[i].size() >= 2)continue;
    if(space[i].front() >= cTIME){
      return false;
    }
    if(pos == -1)pos = i;
    else {
      if( abs(space[i].front()-cTIME) < abs(space[pos].front()-cTIME) ){
	pos = i;
      }
    }
  }

  if(pos == -1)return false;

  space[pos].push_front(cTIME);
  Index[pos].push_front(cindex);
  return true;
}

void compute(){
  int ctime = 0;
  while(true){

    //cout << endl <<  "ctime = " << ctime << "------------------" <<endl;
    // out
    rep(i,n){
      while(!space[i].empty() && space[i].front() <= ctime){
	//cout << Index[i].front() << "," << space[i].front()<< ","<< ctime << endl;
	ANS.push_back(Index[i].front());
	space[i].pop_front(), Index[i].pop_front();
      }
    }

    // IN


    //if(!car.empty()){
    if(!car.empty()){
      waiting.push_back(ii(car.front(),TIME.front()));
      car.pop_front(),TIME.pop_front();
    }
    //cout << "wait = " << waiting.size() << endl;
    deque<ii> next;
    while(!waiting.empty()){
      int cindex = waiting.front().first;
      int cTIME  = waiting.front().second; 
      waiting.pop_front();
      //cout << "is insert??? " << cindex << "," << cTIME << endl;

      if(Insert1(cindex,cTIME+ctime)){
	//ctime += 10;
	//cout << "out! p1" << endl;
	continue;
      }

      if(Insert2(cindex,cTIME+ctime)){
	//ctime += 10;
	//cout << "out! p2" << endl;
	continue;
      }

      if(Insert3(cindex,cTIME+ctime)){
	//ctime += 10;
	//cout << "out! p4" << endl;
	continue;
      }
      // it cannot be possible to insert the car
      //cout << cindex << " cannot insert " << endl;
      next.push_back(ii(cindex,cTIME));

      //car.push_front(cindex);
      //TIME.push_front(cTIME);
    }

    waiting = next;

      //}

    bool finish = true;
    rep(i,n)if(!space[i].empty()){
      finish = false;
      break;
    }
    if(car.empty() && finish)break;
    ctime += 10;
  }
}

int main(){

  while(cin >> n >> m,n|m){
    waiting.clear();
    ANS.clear();
    TIME.clear();
    rep(i,MAX)space[i].clear(),Index[i].clear();
    car.clear();
    rep(i,m){
      int tm;
      cin >> tm;
      car.push_back(i);
      TIME.push_back(tm);
    }

    compute();

    rep(i,ANS.size()){
      if(i)cout << " ";
      cout << ANS[i]+1;
    } cout << endl;

  }

  return 0;
}