#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define ld long double
#define fr first
#define sec second
#define mem(dp, x) memset(dp, x, sizeof dp)
#define loop(a, b, c) for (ll(a) = (b); a < (c); a++)
#define cin(v) \
for (auto &c : v) \
cin >> c
#define cout(v) \
for (auto &c : v) \
cout << c << " "; \
cout << endl;
#define coutpair(v) \
for (auto c : v) \
cout << c.fr << sp << c.sec << endl;
#define cingrid(grid, n, m) \
for (ll i = 0; i < n; ++i) \
for (ll j = 0; j < m; ++j) \
cin >> grid[i][j];
#define coutgrid (grid, n, m) for (ll i = 0; i < n; ++i) for (ll j = 0; j < m; ++j) cout << grid[i][j] << " ";
#define all(v) v.begin(), v.end()
#define nl cout << "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define sp " "
#define tt \
ll t; \
cin >> t; \
while (t--)
#define pb push_back
void fast()
{
cout << setprecision(18);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
const int N = 1e5+5;
vector<int> adj[N];
int main()
{
int n;
cin >> n;
set<int>st;
loop(i,1,n)
{
int u, v;
cin >> u >> v;
st.insert(u);
st.insert(v);
adj[u].pb(v);
adj[v].pb(u);
}
int maxx = 0,no_3=0;
vector<int> nodes;
for(auto i:st)
{
if(adj[i].size()>=3)
maxx=i, no_3++;
if (adj[i].size() == 1)
nodes.pb(i);
}
if(no_3>=2)
no;
else if(nodes.size()==2)
{
yes;
cout << 1 << endl;
cout << nodes[0] << " " << nodes[1] << endl;
}
else
{
yes;
cout << nodes.size() << endl;
for(auto c:nodes)
cout << maxx << " " << c << endl;
}
}
1676D - X-Sum | 1679A - AvtoBus |
1549A - Gregor and Cryptography | 918C - The Monster |
4B - Before an Exam | 545B - Equidistant String |
1244C - The Football Season | 1696B - NIT Destroys the Universe |
1674A - Number Transformation | 1244E - Minimizing Difference |
1688A - Cirno's Perfect Bitmasks Classroom | 219A - k-String |
952A - Quirky Quantifiers | 451B - Sort the Array |
1505H - L BREAK into program | 171E - MYSTERIOUS LANGUAGE |
630D - Hexagons | 1690D - Black and White Stripe |
1688D - The Enchanted Forest | 1674C - Infinite Replacement |
712A - Memory and Crow | 1676C - Most Similar Words |
1681A - Game with Cards | 151C - Win or Freeze |
1585A - Life of a Flower | 1662A - Organizing SWERC |
466C - Number of Ways | 1146A - Love "A" |
1618D - Array and Operations | 1255A - Changing Volume |