/// Problem: Fair Divison
/// Author:  Martin Bäuml

#include <iostream>
#include <algorithm>
#include <cassert>

using namespace std;

struct A {
    int pos;
    int max_amount;
    int contribution;
} persons[105];

bool byAmount(const A& a, const A& b) { return a.max_amount > b.max_amount; }
bool byPos(const A& a, const A& b)    { return a.pos < b.pos; }

// greedily assign each persons' contribution
int run_sol1(int price, int n)
{
    for (int ii = n; ii > 0; --ii) {
        persons[ii-1].contribution = min(persons[ii-1].max_amount, price/ii);
        price -= persons[ii-1].contribution;
    }
    return price;
}

// distribute amount cent by cent
int run_sol2(int price, int n)
{
    while (price > 0) {
        int ii = 0;
        for (; ii < n && price > 0; ++ii) {
            if (persons[ii].contribution == persons[ii].max_amount)
                break;
            ++persons[ii].contribution;
            --price;
        }
        if (ii == 0)
            break;
    }
    return price;
}

int main()
{
    int t;
    cin >> t;
    assert(1 <= t && t <= 100);

    while (t--) {
        int price, n;
        cin >> price >> n;
        assert(1 <= price && price <= 1000000);
        assert(2 <= n && n <= 100);

        for (int ii = 0; ii < n; ++ii) {
            persons[ii].pos = ii;
            persons[ii].contribution = 0;
            cin >> persons[ii].max_amount;
            assert(1 <= persons[ii].max_amount && persons[ii].max_amount <= 1000000);
        }
        stable_sort(persons, persons+n, byAmount);

        price = run_sol1(price, n);
        // price = run_sol2(price, n);

        if (price > 0)
            cout << "IMPOSSIBLE" << endl;
        else {
            sort(persons, persons+n, byPos);
            cout << persons[0].contribution;
            for (int ii = 1; ii < n; ++ii)
                cout << " " << persons[ii].contribution;
            cout << endl;
        }
    }

    return 0;
}
