#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef pair<int, int> P;

int m, n;		// ÔXy[XÌ:m Ô·éÔÌä:n 
P t[105];	// ®ÌÔÔ
struct Park{
	int cn;	// ÔÌ®Ô
	int st;	// ÔÉÉüÁ½Ô
	int rt;	// cèÌÔ
};

Park park[2][100];

void init_park (void )
{
	rep (i, 2 ){
		rep (j, m ){
			park[i][j].cn = -1, park[i][j].st = -1, park[i][j].rt = -1;
		} // end rep
	} // end rep
}

int is_depart (int curr_t )
{
	int res = -1;
	rep (i, 2 ){
		rep (j, m ){
			int rtime = curr_t - park[i][j].st;
			if (park[i][j].cn != -1 && rtime >= park[i][j].rt ){
				if ((i == 0 ) ||  (i == 1 && park[0][j].cn == -1 ) ){
					res = park[i][j].cn;
					park[i][j].cn = -1, park[i][j].st = -1, park[i][j].rt = -1;
					return res;
				} // edn if
			} // end if
		} // end rep
	} // end rep

	return -1;
}

bool enter_park (P ct, int curr_t )
{
	rep (i, 2 )
		rep (j, m )
			if (i == 0 && park[i][j].cn == -1 ){
				park[i][j].cn = ct.first;
				park[i][j].st = curr_t;
				park[i][j].rt = ct.second;
				return true;
			} // end if
	// êäàÔ³êÄ¢È¢ÔXy[XªÈ¢ê
	int moremin = 1 << 30;
	int lessmin = 1 << 30;
	int rtime = 0;
	int moreid = -1;
	int lessid = -1;
	rep (j, m ){
		if (park[1][j].cn == -1 ){
			// ÔµÄ éÔÌcèÌÔÔ
			rtime = (curr_t - park[0][j].st >= park[0][j].rt ? 0 : park[0][j].rt - curr_t + park[0][j].st );
			if (rtime >= ct.second ){
				if (rtime - ct.second < moremin ){
					moremin = rtime - ct.second;
					moreid = j;
				} // end if
			}else{
				if (ct.second - rtime < lessmin ){
					lessmin = ct.second - rtime;
					lessid = j;
				} // end if
			} // end if
		} // end if
	} // end rep
	if (moreid != -1 ){
		park[1][moreid] = park[0][moreid];
		park[0][moreid].cn = ct.first;
		park[0][moreid].st = curr_t;
		park[0][moreid].rt = ct.second;
		return true;
	}else if (lessid != -1 ){
		park[1][lessid] = park[0][lessid];
		park[0][lessid].cn = ct.first;
		park[0][lessid].st = curr_t;
		park[0][lessid].rt = ct.second;
		return true;
	} // end if			

	return false;
} 

bool cmp (P a, P b )
{
	if (a.second != b.second ){
		return (a.second < b.second );
	} // end if

	return a.first < b.first;
}

bool all_empty (void )
{
	rep (i, 2 )
		rep (j, m )
			if (park[i][j].cn != -1 )
				return false;

	return true;
}

int main()
{
	while (cin >> m >> n && m && n ){
		init_park ();
		rep (i, n ){
			t[i].first = i;
			cin >> t[i].second;
		} // end rep
		int k = 0;
		int ct = 0;
		int dn;
		vector<int> res;
		while (k < n ){	// ÔÉÉüêé
			if (enter_park (t[k], ct ) ){
				k++;
			} // end if
			ct += 10;
			while ( (dn = is_depart (ct ) ) != -1 ){
				res.push_back (dn );
			} // end while
		} // end while
		while (!all_empty() ){
			ct++;
			while ( (dn = is_depart (ct ) ) != -1 ){
				res.push_back (dn );
			} // end while
		} // end while

		for (int i = 0; i < n; i++ ){
			cout << res[i] + 1;
			if (i != res.size() - 1 )
				cout << ' ';
		} // end for
		cout << endl;
	} // end loop
		
	return 0;
}