/*
* Copyright (c) 2025 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b){
if(a.second == b.second) return a.first<b.first;
return a.second<b.second;
}
void solve()
{
int n; cin >> n;
vector<pair<int,int>> v;
for(int i=0;i<n;i++)
{
int l,r; cin >> l >> r;
v.push_back({l,r});
}
sort(v.begin(),v.end(),cmp);
set<int> ans;
int taken=0;
for(auto e:v)
{
int r = e.second;
int l = e.first;
if(taken >= r)
{
cout<<"NO"<<endl;
return;
}
int lo=l,hi=r,mid,x;
while(lo<=hi)
{
mid = (lo+hi)/2;
if(mid>taken)
{
x = mid;
hi = mid-1;
}else lo=mid+1;
}
ans.insert(x);
taken = x;
}
cout<<"YES"<<endl;
for(auto e:ans) cout<<e<<' '; cout<<endl;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(nullptr);
int t; cin >> t; while(t--) solve();
}