#include <bits/stdc++.h>
using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	bool ok = false;
	while (tt--) {
	    if (ok)
		    cout << "\n";
		int m, n;
		cin >> m >> n;
		vector<vector<int>> hash(m);
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			hash[x % m].push_back(x);
		}
		for (int i = 0; i < m; i++) {
			cout << i << " -> ";
			for (auto x : hash[i])
				cout << x << " -> ";
			cout << "\\\n";
		}
		ok = true;
	}
}