#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;
typedef vector<pld> vpld;
#define int ll
#define all(it) it.begin(),it.end()
#define ord_set(T) tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>
void work(){
int n;
cin >> n;
vpll v(n);
for (auto &[a,b] : v) cin >> a >> b;
sort(all(v));
vll res;
int last = 1;
for (int i=0;i<n;i++){
int start = i;
priority_queue<int> pq;
pq.push(-v[start].second);
while (i+1 < n && v[i+1].first == v[start].first) i++, pq.push(-v[i].second);
last = max(v[start].first,last);
while (pq.size()){
auto cur = -pq.top();
pq.pop();
if (cur < last){
cout << "NO\n";
return;
}
res.push_back(last++);
}
}
cout << "YES\n";
for (auto &c : res) cout << c << ' ';
cout << '\n';
}
int32_t main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
while (n--) work();
return 0;
}