#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int M, N;
int T[100];
pii data[10][2]; // ????????????, ??´?????????
pii ud = pii(INF, 0);

int main() {
	while (cin >> M >> N, M || N) {
		REP(i, N) scanf("%d", T + i);
		
		fill(data[0], data[M], ud);
		
		queue<pii> in; // ???????????? time, number
		REP(i, N) in.push(pii(i * 10, i + 1));
		
		priority_queue<pip, vector<pip>, greater<pip> > out; // ????????????, ?§??????????, ???
		vector<int> ans;
		
		int t = 0;
		while (true) {
		
			while (!out.empty()) {
				int nt = out.top().fi;
				int snum = out.top().se.fi;
				int g = out.top().se.se;
				
				bool ok = false;
				
				if (nt <= t) {
					
					if (g == 1 && data[snum - 1][0] != ud) {
						out.pop();
						data[snum - 1][1].fi = data[snum - 1][0].fi;
						out.push(pip(data[snum - 1][0].fi, pii(snum, 1)));
					}
					else {
						ans.push_back(data[snum - 1][g].se);
						data[snum - 1][g] = ud;
						out.pop();
					}
				}
				else {
					break;
				}
			}
		
			while (!in.empty()) {
				int nt = in.front().fi;
				int num = in.front().se;
				
				if (nt <= t) {
					// ??¢????????????
					bool stop = false;
					
					// 1
					REP(i, M) {
						if (data[i][0] == pii(INF, 0) && data[i][1] == ud) {
							data[i][1] = pii(t + T[num - 1], num);
							out.push(pip(t + T[num - 1], pii(i + 1, 1)));
							stop = true;
							break;
						}
					}
					if (stop) { in.pop(); continue; }
					/////
					
					// 2,3
					pii mi1 = ud, mi2 = ud;
					REP(i, M) if (data[i][1] != ud && data[i][0] == ud) {
						int gotime = data[i][1].fi - t;
						if (gotime >= T[num - 1]) chmin(mi1, pii(abs(gotime - T[num - 1]), i + 1));
						else chmin(mi2, pii(abs(gotime - T[num - 1]), i + 1));
					}
					
					if (mi1 != ud) {
						data[mi1.se - 1][0] = pii(t + T[num - 1], num);
						out.push(pip(t + T[num - 1], pii(mi1.se, 0)));
						stop = true;
					}
					else if (mi2 != ud) {
						data[mi2.se - 1][0] = pii(t + T[num - 1], num);
						out.push(pip(t + T[num - 1], pii(mi2.se, 0)));
						stop = true;
					}
					
					if (stop) { in.pop(); continue; }
					
					break;
				}
				else {
					break;
				}
			}
			
			int nextt = INF;
			if (!in.empty()) chmin(nextt, in.front().fi);
			if (!out.empty()) chmin(nextt, out.top().fi);
			if (nextt == INF) break;
			
			chmax(nextt, t + 1);
			t = nextt;
		}
		
		REP(i, ans.size()) printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
		
	}
	return 0;
}