#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>

using namespace std;

void solve(int test_ind){
	int n, m;
	cin >> n >> m;
	int c = 0;
	for (int i=0;i<m;++i) {
		int u, v;
		cin >> u >> v;
		if (u < v) c++;
	}
	if (c >= (m+1)/2) {
		for (int i=0;i<n;++i) cout << i + 1 << " ";
		cout << endl;
	} else {
		for (int i=0;i<n;++i) cout << n - i << " ";
		cout << endl;
	}
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int t=1;
	cin >> t;
	for(int i=0;i<t;i++){
		solve(i);
	}
	return 0;
}
