/* NWERC 2010: Sample solution to "Fair Division"
 * Author: Sean Lip
 *
 * Algorithm: 
 * 
 * Distribute coins one by one. Runs in O(P+N) time.
 * A faster algorithm might use binary search.
 */

#include <iostream>

using namespace std;

int main()
{
	int T;
	cin >> T;
	
	for(int i = 0; i < T; i++)
	{
		int P, N, cap[100];
		cin >> P >> N;
		for(int j = 0; j < N; j++)
			cin >> cap[j];
		int ind[100];
		for(int j = 0; j < N; j++)
			ind[j] = j;
	
		for(int j = 0; j < N; j++)
			for(int k = 0; k < j; k++)
			if(cap[j] > cap[k] || (cap[j] == cap[k] && ind[j] < ind[k]))
				swap(cap[j], cap[k]), swap(ind[j], ind[k]);
		
		int tot = 0;
		for(int j = 0; j < N; j++)
			tot += cap[j];
		if(tot < P)
		{
			cout << "IMPOSSIBLE\n";
			continue;
		}
			
		int ans[100];
		for(int j = 0; j < N; j++)
			ans[j] = 0;
		
		int pos = 0;
		for(int j = 0; j < P; j++)
		{
			if(pos == N || ans[pos] == cap[pos])
			{
				pos = 0;
				j--;
				continue;
			}
			
			ans[pos]++;
			pos++;
		}
		
		int ansind[100];
		for(int j = 0; j < N; j++)
			ansind[ind[j]] = ans[j];
					
		for(int j = 0; j < N; j++)
		if(j == 0) cout << ansind[j];
		else cout << " " << ansind[j];
		cout << endl;
	}
	return 0;
}
