#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int n,m;
int ans[100],na;

struct S{
	int t[2],id[2];
	S()
	{
		rep(i,2)id[i]=0;
	}
	void next()
	{
		rep(i,2)if(id[i])t[i]--;
		rep(i,2)if(id[i])
		{
			if(t[i]<=0)ans[na++]=id[i],id[i]=0;
			return;
		}
	}
	void put(int cid,int time)
	{
		int p=id[1]?0:1;
		id[p]=cid; t[p]=time;
	}
	int diff(int time)
	{
		return abs(time-t[1]);
	}
};

S spc[10];

int pfind(queue<int> &Data)
{
	rep(i,m)if(!spc[i].id[1])return i;
	
	int mn=inf,nTime=Data.front(),ret=-1;
	rep(i,m)if(!spc[i].id[0]&&spc[i].t[1]>=nTime)
	if(mn>spc[i].diff(nTime))
	{
		mn=spc[i].diff(nTime); ret=i;
	}
	if(ret!=-1)return ret;
	
	rep(i,m)if(!spc[i].id[0]&&mn>spc[i].diff(nTime))
	mn=spc[i].diff(nTime),ret=i;
	
	return ret;
}

int main()
{
	while(scanf("%d%d",&m,&n),m)
	{
		int time=0,id=1; na=0;
		queue<int> ID,Data;
		while(na<n)
		{
			if(id<=n&&time==0)
			{
				int tmp; scanf("%d",&tmp);
				ID.push(id); Data.push(tmp); id++;
			}
			while(!ID.empty())
			{
				int next=pfind(Data);
				
				if(next==-1)break;
				
				spc[next].put(ID.front(),Data.front());
				ID.pop(); Data.pop();
			}
			time++;
			if(time==10)time=0;
			rep(i,m)spc[i].next();
		}
		rep(i,na)printf("%d%c",ans[i],i==n-1?'\n':' ');
	}
	return 0;
}