文件目录

#include <iostream>
#include <stack>
using namespace std;
int f[550][550];
int k, a, b;
int d[550];
int l = 550, r = -1;
stack<int> s;
void dfs(int x)
{
    // cout<<x<<"\n";
    for (int i = l; i <= r; i++)
    {
        if (f[i][x])
        {
            f[i][x]--;
            f[x][i]--;
            dfs(i);
        }
    }
    s.push(x);
}
int main()
{
    cin >> k;
    for (int i = 1; i <= k; i++)
    {
        cin >> a >> b;
        f[a][b]++;
        f[b][a]++;
        d[a]++;
        d[b]++;
        l = min(l, min(a, b));
        r = max(r, max(a, b));
    }
    int m = l;
    for (int i = l; i <= r; i++)
    {
        if (d[i] % 2 == 1)
        {
            m = i;
            break;
        }
    }
    dfs(m);
    while (!s.empty())
    {
        cout << s.top() << endl;
        s.pop();
    }
    return 0;
}