#include <iostream>
#include <cstring>
using namespace std;

int a[50005];
bool vis[50005];

int main() {
	freopen("ahead.out", "w", stdout);
	int t;
	cin >> t;
	while(t--) {
		memset(vis, 0, sizeof(vis));
		int n, m;
		cin >> n >> m;
		for(int i = 1; i <= m; i++) {
			cin >> a[i];
			vis[a[i]] = true;
		}
		for(int i = m; i >= 1; i--) {
			cout << a[i] << ' ';
		}
		for(int i = 1; i <= n; i++) {
			if(!vis[i]) cout << i << ' ';
		}
		cout << '\n';
	}
	return 0;
}