#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<pair<int,int>> seg(n);
for (int i = 0; i < n; i++) cin >> seg[i].first >> seg[i].second;
sort(seg.begin(), seg.end(), [](auto a, auto b) { if (a.second == b.second) return a.first < b.first; return a.second < b.second; });
vector<int> ans;
int last = -1;
for (auto &s : seg){
int x = max(last + 1, s.first);
if (x > s.second) { cout << "NO\n"; return; }
ans.push_back(x);
last = x;
}
cout << "YES\n";
for (auto x : ans) cout << x << " ";
cout << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) solve();
}