#include <bits/stdc++.h>
#define F first
#define S second
#define el cout << '\n'
#define maxn 100005
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define For(i,a,b) for ( int i = a; i <= b; i++)
#define ll long long
#define MOD 100000007
using namespace std;
vector < int > a[maxn];
int m,n,s,t,check=0;
int trace[maxn];
int used[maxn];
void DFS(int s, int t)
{
used[s] = 1;
for(int v : a[s])
{
if (used[s] == 0)
{
trace[v] = s;
DFS(v, t);
}
}
if (used[t] == 1)
{
check = 1;
vector <int> res;
int u = t;
while (u != s)
{
res.push_back(u);
u = trace[u];
}
res.push_back(s);
cout << res.size(); el;
reverse(res.begin(), res.end());
for(int i : res) cout << i << " ";
cout << s;
}
}
int main()
{
faster
cin >> n;
For(i,1,n)
{
int u, v;
cin >> u >> v;
a[u].push_back(v);
a[v].push_back(u);
}
for(int u = 1; u <= n; u++)
{
for(int v : a[u])
{
DFS(u, v);
if (check == 1) break;
else
{
fill(trace, trace + n + 1, 0);
fill(used, used + n + 1, 0);
}
}
if (check == 1) break;
}
if (check == 0) cout << "NO";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgRiBmaXJzdAojZGVmaW5lIFMgc2Vjb25kCiNkZWZpbmUgZWwgY291dCA8PCAnXG4nCiNkZWZpbmUgbWF4biAxMDAwMDUKI2RlZmluZSBmYXN0ZXIgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoTlVMTCk7IGNvdXQudGllKDApOwojZGVmaW5lIEZvcihpLGEsYikgZm9yICggaW50IGkgPSBhOyAgaSA8PSBiOyBpKyspCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgTU9EIDEwMDAwMDAwNwp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdmVjdG9yIDwgaW50ID4gYVttYXhuXTsKaW50IG0sbixzLHQsY2hlY2s9MDsKaW50IHRyYWNlW21heG5dOwppbnQgdXNlZFttYXhuXTsKCnZvaWQgREZTKGludCBzLCBpbnQgdCkKewogICAgdXNlZFtzXSA9IDE7CiAgICBmb3IoaW50IHYgOiBhW3NdKQogICAgewogICAgICAgIGlmICh1c2VkW3NdID09IDApCiAgICAgICAgewogICAgICAgICAgICB0cmFjZVt2XSA9IHM7CiAgICAgICAgICAgIERGUyh2LCB0KTsKICAgICAgICB9CiAgICB9CgogICAgaWYgKHVzZWRbdF0gPT0gMSkKICAgIHsKICAgICAgICBjaGVjayA9IDE7CiAgICAgICAgdmVjdG9yIDxpbnQ+IHJlczsKICAgICAgICBpbnQgdSA9IHQ7CiAgICAgICAgd2hpbGUgKHUgIT0gcykKICAgICAgICB7CiAgICAgICAgICAgIHJlcy5wdXNoX2JhY2sodSk7CiAgICAgICAgICAgIHUgPSB0cmFjZVt1XTsKICAgICAgICB9CiAgICAgICAgcmVzLnB1c2hfYmFjayhzKTsKICAgICAgICBjb3V0IDw8IHJlcy5zaXplKCk7IGVsOwogICAgICAgIHJldmVyc2UocmVzLmJlZ2luKCksIHJlcy5lbmQoKSk7CiAgICAgICAgZm9yKGludCBpIDogcmVzKSBjb3V0IDw8IGkgPDwgIiAiOwogICAgICAgIGNvdXQgPDwgczsKICAgIH0KfQoKaW50IG1haW4oKQp7CiAgICBmYXN0ZXIKICAgIGNpbiA+PiBuOwogICAgRm9yKGksMSxuKQogICAgewogICAgICAgIGludCB1LCB2OwogICAgICAgIGNpbiA+PiB1ID4+IHY7CiAgICAgICAgYVt1XS5wdXNoX2JhY2sodik7CiAgICAgICAgYVt2XS5wdXNoX2JhY2sodSk7CiAgICB9CiAgICBmb3IoaW50IHUgPSAxOyB1IDw9IG47IHUrKykKICAgIHsKICAgICAgICBmb3IoaW50IHYgOiBhW3VdKQogICAgICAgIHsKICAgICAgICAgICAgREZTKHUsIHYpOwogICAgICAgICAgICBpZiAoY2hlY2sgPT0gMSkgYnJlYWs7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZmlsbCh0cmFjZSwgdHJhY2UgKyBuICsgMSwgMCk7CiAgICAgICAgICAgICAgICBmaWxsKHVzZWQsIHVzZWQgKyBuICsgMSwgMCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGNoZWNrID09IDEpIGJyZWFrOwogICAgfQogICAgaWYgKGNoZWNrID09IDApIGNvdXQgPDwgIk5PIjsKfQo=