// tzyt #include<bits/stdc++.h> usingnamespace std; #define ll long long constint MAXN = 2e5 + 10; vector<int> e[MAXN]; // k 个奇数大小的子树 int od_cnt[MAXN]; int n, k;
#include<bits/stdc++.h> usingnamespace std; #define ll long long #define pause system("pause") #define IINF 0x3f3f3f3f #define rg register // keywords:
structConstrain { int val, pos; booloperator<(Constrain b) const { if (pos != b.pos) return pos < b.pos; return val < b.val; } booloperator>(Constrain b) const { return b < *this; } };
intmain(){ int t; cin >> t; while (t--) { int n, m; cin >> n >> m; priority_queue<Constrain, vector<Constrain>, greater<Constrain>> pq; vector<int> ans; ans.reserve(n); set<int> ncons; for (int i = 1; i <= n; i++) { ncons.insert(i); } for (int i = 0; i < m; i++) { Constrain tmp; cin >> tmp.val >> tmp.pos; pq.push(tmp); ncons.erase(tmp.val); } while (pq.size()) { auto tp = pq.top(); pq.pop(); bool used = false; if (ans.size() >= tp.pos) { goto FAIL; } while (ans.size() < tp.pos - 1) { int ist = *ncons.begin(); if (tp.val < ist) { ans.push_back(tp.val); used = true; } else { ans.push_back(ist); ncons.erase(ist); } } if (!used) { ans.push_back(tp.val); } } while (ncons.size()) { int ist = *ncons.begin(); ans.push_back(ist); ncons.erase(ist); }
SUCC: for (int cur : ans) { cout << cur << ' '; } cout << '\n'; continue; FAIL: cout << "-1\n"; } pause; }