func_code_string: #include <bits/stdc++.h>   using namespace std;   long long read() {     long long f = 1, x = 0;     char s = getchar();     while (s <  0  || s >  9 ) {       if (s ==  - ) f = -f;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = x * 10 + (s -  0 );       s = getchar();     }     return f * x;   }   int n, m, i, j, s, o, k;   vector<int> g[500005];   int cnt;   vector<int> bu[500005];   int bl[500005], rk[500005];   int vv[500005];   int d[500005], dpd[500005];   void dfs0(int x, int ff) {     d[x] = d[ff] + 1;     dpd[x] = 0x3f3f3f3f;     for (int i = 0; i < (int)g[x].size(); i++) {       int y = g[x][i];       if (y != ff) {         if (!d[y]) {           dfs0(y, x);           dpd[x] = min(dpd[x], dpd[y]);         } else {           dpd[x] = min(dpd[x], d[y]);         }       }     }     if (dpd[x] > d[x])       vv[x] = -1;     else       vv[x] = 1;     return;   }   void dfs00(int x, int ff) {     if (dpd[x] == d[x]) {       bu[++cnt].push_back(x);       rk[x] = 0;       bl[x] = cnt;     } else if (dpd[x] < d[x]) {       bl[x] = bl[ff];       bu[bl[x]].push_back(x);       rk[x] = (int)bu[bl[x]].size() - 1;     }     for (int i = 0; i < (int)g[x].size(); i++) {       int y = g[x][i];       if (y != ff && d[y] == d[x] + 1) {         dfs00(y, x);       }     }     return;   }   int dp1[500005], dp2[500005], dp0[500005];   vector<int> sm[500005];   void dfs(int x, int ff, int op) {     if (!op) {       dp1[x] = 0;       int nw = 0;       for (int i = 0; i < (int)g[x].size(); i++) {         int y = g[x][i];         sm[x].push_back(nw);         if (y != ff) {           dfs(y, x, vv[y] == 1 ? 1 : 0);           dp1[x] = max(dp1[x], dp1[y] + 1);           nw = max(nw, dp1[y] + 1);         }       }       return;     }     int id = bl[x], le = (int)bu[id].size();     int md = rk[x], ll = (md + le - (le / 2)) % le;     for (int ii = 0; ii < le; ii++) {       int t = bu[id][ii], nw = 0;       for (int i = 0; i < (int)g[t].size(); i++) {         int y = g[t][i];         sm[t].push_back(nw);         if (y != ff && bl[y] != id) {           dfs(y, t, vv[y] == 1 ? 1 : 0);           dp0[t] = max(dp0[t], dp1[y] + 1);           nw = max(nw, dp1[y] + 1);         }       }       dp1[t] = dp0[t];     }     for (int ii = (ll + 1) % le; ii != (md + 1) % le; ii = (ii + 1) % le) {       int pr = bu[id][(ii + le - 1) % le], t = bu[id][ii];       dp1[t] = max(dp1[t], dp1[pr] + 1);     }     for (int ii = (ll + le - 1) % le; ii != (md + le - 1) % le;          ii = (ii + le - 1) % le) {       int pr = bu[id][(ii + 1) % le], t = bu[id][ii];       if (ii != (ll + le - 1) % le) {         dp1[t] = max(dp1[t], dp1[pr] + 1);       }     }     return;   }   int as[500005];   int q[500005], hd, tl;   int ds(int x, int y, int le) { return (y + le - x) % le; }   void dfs2(int x, int ff, int op, int fdp) {     if (!op) {       dp2[x] = fdp + 1;       as[x] = max(dp2[x], dp1[x]);       int nw = 0;       for (int i = (int)g[x].size() - 1; i >= 0; i--) {         int y = g[x][i];         if (y != ff) {           dfs2(y, x, vv[y] == 1 ? 1 : 0, max(dp2[x], max(sm[x][i], nw)));           nw = max(nw, dp1[y] + 1);         }       }       return;     }     dp0[x] = max(dp0[x], fdp + 1);     int id = bl[x], le = (int)bu[id].size();     hd = 1;     tl = 0;     int ll2 = (le - (le / 2)) % le;     for (int i = ll2; i != 0; i = (i + 1) % le) {       int t = bu[id][i];       while (tl >= hd && dp0[bu[id][q[tl]]] + ds(q[tl], i, le) < dp0[t]) tl--;       q[++tl] = i;     }     for (int i = 0; i < le; i++, ll2 = (ll2 + 1) % le) {       int t = bu[id][i];       if (tl >= hd) dp2[t] = max(dp2[t], dp0[bu[id][q[hd]]] + ds(q[hd], i, le));       while (tl >= hd && dp0[bu[id][q[tl]]] + ds(q[tl], i, le) < dp0[t]) tl--;       q[++tl] = i;       if (tl >= hd && q[hd] == ll2) hd++;     }     ll2 = (le - 1 + le / 2) % le;     hd = 1;     tl = 0;     for (int i = ll2; i != le - 1; i = (i + le - 1) % le) {       int t = bu[id][i];       while (tl >= hd && dp0[bu[id][q[tl]]] + ds(i, q[tl], le) < dp0[t]) tl--;       q[++tl] = i;     }     for (int i = le - 1; i >= 0; i--, ll2 = (ll2 + le - 1) % le) {       int t = bu[id][i];       if (tl >= hd) dp2[t] = max(dp2[t], dp0[bu[id][q[hd]]] + ds(i, q[hd], le));       while (tl >= hd && dp0[bu[id][q[tl]]] + ds(i, q[tl], le) < dp0[t]) tl--;       q[++tl] = i;       if (tl >= hd && q[hd] == ll2) hd++;     }     for (int ii = 0; ii < le; ii++) {       int t = bu[id][ii], nw = 0;       as[t] = max(dp2[t], dp0[t]);       for (int i = (int)g[t].size() - 1; i >= 0; i--) {         int y = g[t][i], dpp = dp2[t];         if (t == x) dpp = max(dpp, fdp + 1);         if (y != ff && bl[y] != id) {           dfs2(y, t, vv[y] == 1 ? 1 : 0, max(dpp, max(nw, sm[t][i])));           nw = max(nw, dp1[y] + 1);         }       }     }     return;   }   int main() {     n = read();     m = read();     for (int i = 1; i <= m; i++) {       s = read();       o = read();       g[s].push_back(o);       g[o].push_back(s);     }     dfs0(1, 0);     cnt = 0;     dfs00(1, 0);     dfs(1, 0, vv[1] == 1 ? 1 : 0);     dfs2(1, 0, vv[1] == 1 ? 1 : 0, -1);     for (int i = 1; i <= n; i++) {       printf( %d  , as[i]);     }     putchar(  n );     return 0;   }   