#include<iostream>
#include<vector>
using namespace std;
/*
#define
#define
*/
vector < int > Graph[100000];
int visit[100000];
int dis[100000], baack[100000];
int timer;
int component;
int root, degreeOfRoot;
void findArt(int u)
{
visit[u] = 1;
timer++;
baack[u]=dis[u]=timer;
for(int i=0; i<Graph[u].size(); i++)
{
int v = Graph[u][i];
if(!visit[v])
{
findArt(v);
if(u==root) degreeOfRoot++;
if(degreeOfRoot>=2) cout << u << " ";
baack[u] = min(baack[u], baack[v]);
if(baack[v]>=dis[u] && u!=root) cout << u << " ";
}
else
baack[u] = min(baack[u], dis[v]);
}
}
int main()
{
int i, j, k;
int n, u, v;
//init(n);
cin >> n;
while(cin>>u>>v)
{
Graph[u].push_back(v);
Graph[v].push_back(u);
}
root = 1;
findArt(root);
cout << endl;
for(i=1; i<=n; i++) cout << baack[i] << " ";
return 0;
}
/*
9
1 2
1 5
1 4
2 3
3 4
4 5
4 6
4 9
6 9
6 7
6 8
7 8
8 9
*/
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHZlY3Rvcj4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKLyoKI2RlZmluZQojZGVmaW5lCiovCnZlY3RvciA8IGludCA+IEdyYXBoWzEwMDAwMF07CmludCB2aXNpdFsxMDAwMDBdOwppbnQgZGlzWzEwMDAwMF0sIGJhYWNrWzEwMDAwMF07CmludCB0aW1lcjsKaW50IGNvbXBvbmVudDsKaW50IHJvb3QsIGRlZ3JlZU9mUm9vdDsKCnZvaWQgZmluZEFydChpbnQgdSkKewogICAgdmlzaXRbdV0gPSAxOwogICAgdGltZXIrKzsKICAgIGJhYWNrW3VdPWRpc1t1XT10aW1lcjsKICAgIGZvcihpbnQgaT0wOyBpPEdyYXBoW3VdLnNpemUoKTsgaSsrKQogICAgewogICAgICAgIGludCB2ID0gR3JhcGhbdV1baV07CiAgICAgICAgaWYoIXZpc2l0W3ZdKQogICAgICAgIHsKICAgICAgICAgICAgZmluZEFydCh2KTsKICAgICAgICAgICAgaWYodT09cm9vdCkgZGVncmVlT2ZSb290Kys7CiAgICAgICAgICAgIGlmKGRlZ3JlZU9mUm9vdD49MikgY291dCA8PCB1IDw8ICIgIjsKCiAgICAgICAgICAgIGJhYWNrW3VdID0gbWluKGJhYWNrW3VdLCBiYWFja1t2XSk7CiAgICAgICAgICAgIGlmKGJhYWNrW3ZdPj1kaXNbdV0gJiYgdSE9cm9vdCkgY291dCA8PCB1IDw8ICIgIjsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIGJhYWNrW3VdID0gbWluKGJhYWNrW3VdLCBkaXNbdl0pOwogICAgfQp9CgppbnQgbWFpbigpCnsKICAgIGludCBpLCBqLCBrOwogICAgaW50IG4sIHUsIHY7CgogICAgLy9pbml0KG4pOwogICAgY2luID4+IG47CgogICAgd2hpbGUoY2luPj51Pj52KQogICAgewogICAgICAgIEdyYXBoW3VdLnB1c2hfYmFjayh2KTsKICAgICAgICBHcmFwaFt2XS5wdXNoX2JhY2sodSk7CiAgICB9CgoKICAgIHJvb3QgPSAxOwogICAgZmluZEFydChyb290KTsKICAgIGNvdXQgPDwgZW5kbDsKICAgIGZvcihpPTE7IGk8PW47IGkrKykgY291dCA8PCBiYWFja1tpXSA8PCAiICI7CgogICAgcmV0dXJuIDA7Cn0KLyoKOQoxIDIKMSA1CjEgNAoyIDMKMyA0CjQgNQo0IDYKNCA5CjYgOQo2IDcKNiA4CjcgOAo4IDkKKi8KCg==