#include<iostream>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int m,n,s,car,c[110],t[110],p[30];
queue<pair<int,int> > w,nl;
void parking(int time){
	NEXT:while(!w.empty()){
				int ti=w.front().first,ts=w.front().second,mxt,mnt,mi;
				if(car==2*m)break;
				w.pop(),car++;
				rep(j,m)if(!p[2*j]&&!p[2*j+1]){
 					p[2*j]=ti; c[ti]=2*j; t[ti]=time+ts; goto NEXT;
				}
				mnt=1<<30,mi=-1;
				rep(j,m)if(!p[2*j+1]&&t[p[2*j]]>=time+ts&&mnt>t[p[2*j]])
				mnt=t[p[2*j]],mi=2*j;
				if(mi>=0){
					c[p[mi]]++,p[mi+1]=p[mi];
					c[ti]=mi,p[mi]=ti,t[ti]=time+ts; goto NEXT;
				}
				mxt=0;
				rep(j,m)if(!p[2*j+1]&&mxt<t[p[2*j]])mxt=t[p[2*j]],mi=2*j;
				c[p[mi]]++,p[mi+1]=p[mi];
				c[ti]=mi,p[mi]=ti,t[ti]=time+ts;
			}
}
int main(){
	while(cin>>m>>n,m){
		rep(i,n+1)c[i]=-1,t[i]=0;rep(i,2*m)p[i]=0;
		w=nl;car=0;
		for(int i=0;i<n||car!=0;i++){
			if(i<n)cin>>s;
			for(int f=0;!f;){
				f=1;
				for(int j=1;j<n+1;j++)if(c[j]>=0&&t[j]<=10*i&&c[j]%2==0){
					if(p[c[j]+1])p[c[j]]=p[c[j]+1],p[c[j]+1]=0,c[p[c[j]]]--;
					else p[c[j]]=0;
					f=0,car--,c[j]=-1,cout<<j<<(car==0&&i>=n?"\n":" ");
					parking(t[j]);
					break;
				}
			}
			if(i<n)w.push(make_pair(i+1,s));
			parking(10*i);
		}
	}
	return 0;
}