#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int m,n;
  while(cin>>m>>n&&(m||n)){
    int a[10],b[10],c[10],d[10];
    memset(a,-1,sizeof(a));
    memset(b,-1,sizeof(b));
    list<pair<int,pair<int,int> > > p;
    for(i=0;i<n;i++){
      int t;
      cin>>t;
      p.push_back(make_pair(i,make_pair(i*10,t)));
    }
    while(n){
      for(i=0;i<m;i++){
	if(a[i]==-1){
	  if(b[i]!=-1&&d[i]==0){
	    if(n!=1)
	      cout<<b[i]+1<<" ";
	    else
	      cout<<b[i]+1<<endl;
	    b[i]=-1;
	    n--;
	  }
	}else{
	  if(c[i]==0){
	    if(n!=1)
	      cout<<a[i]+1<<" ";
	    else
	      cout<<a[i]+1<<endl;
	    a[i]=-1;
	    n--;
	    if(d[i]==0){
	      if(n!=1)
		cout<<b[i]+1<<" ";
	      else
		cout<<b[i]+1<<endl;
	      b[i]=-1;
	      n--;
	    }
	  }
	}
      }
      if(n==0)
	break;
      h=1;
      while(p.empty()==0&&p.front().second.first==0&&h){
	h=0;
	for(i=0;i<m&&b[i]!=-1;i++);
	if(i!=m){
	  b[i]=p.front().first;
	  d[i]=p.front().second.second;
	  p.pop_front();
	  h=1;
	}else{
	  int mn=-1,mx=-1;
	  for(i=0;i<m;i++){
	    if(a[i]==-1){
	      if(p.front().second.second<=d[i]){
		if(mn==-1||d[mn]>d[i])
		  mn=i;
	      }else{
		if(mx==-1||d[mx]<d[i])
		  mx=i;
	      }
	    }
	  }
	  if(0){
	  }else if(mn!=-1){
	    a[mn]=p.front().first;
	    c[mn]=p.front().second.second;
	    p.pop_front();
	    h=1;
	  }else if(mx!=-1){
	    a[mx]=p.front().first;
	    c[mx]=p.front().second.second;
	    p.pop_front();
	    h=1;
	  }
	}
      }
      unsigned mn=-1;
      for(i=0;i<m;i++){
	if(a[i]==-1){
	  if(b[i]!=-1)
	    mn=min(mn,(unsigned)d[i]);
	}else{
	  mn=min(mn,(unsigned)c[i]);
	}
      }
      if(p.empty()==0&&p.front().second.first)
	mn=min(mn,(unsigned)p.front().second.first);
      for(i=0;i<m;i++){
	if(a[i]==-1){
	  if(b[i]!=-1)
	    d[i]=max(0,d[i]-(int)mn);
	}else{
	  c[i]=max(0,c[i]-(int)mn);
	  d[i]=max(0,d[i]-(int)mn);
	}
      }
      list<pair<int,pair<int,int> > >::iterator it;
      for(it=p.begin();it!=p.end();it++)
	(*it).second.first=max(0,(*it).second.first-(int)mn);
    }
  }
  return 0;
}