#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]; // ????????????, ??´?????????

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