题目
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int maxn = 1e6 + 5;
const int inf = 1e9 + 5;
using namespace std;
int n, m;
void solve(){
int res = 0;
int q;
string s;
int k;
cin >> n >> q;
vector<int> L(n + 5), R(n + 5);
for(int i = 1; i <= n; i++){
L[i] = i - 1;
R[i] = i + 1;
}
int head = 1, tail = n;
while(q--){
int op, x;
cin >> op;
if(op == 1){
cin >> x;
}
else{
x = tail;
}
if(x == tail){
tail = L[x];
}
if(x == head) continue;//必须特判!!!!!!!!
R[L[x]] = R[x];
L[R[x]] = L[x];
R[x] = head;
L[x] = 0;
R[0] = x;
L[head] = x;
head = x;
}
if(n == 1){
cout << 1 << '\n';
return;
}
vector<int> a(n + 5);
int cur = head;
for(int i = 1; i <= n; i++){
// pos[i] = cur;
a[cur] = i;
cur = R[cur];
}
for(int i = 1; i <= n; i++){
cout << a[i] << " \n"[i == n];
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while(T--){
solve();
}
return 0;
}