#include <bits/stdc++.h>
using namespace std;
static const int N = 500004, M = 1000004;
int n, m;
int Head[N], V[M << 1], Next[M << 1], tot;
void Add_Edge(int u, int v) { Next[++tot] = Head[u], V[Head[u] = tot] = v; }
int F[N], F2[N], G[N], UPF[N];
int DFN[N], LOW[N], dfn, Fr[N];
int D[N << 1], cnt, Stk[N], top;
int Ql, Qr, Qx[N], QFl[N], Q[M];
inline void chkmax(int &a, const int &b) { a < b ? a = b : 0; }
inline void chkmin(int &a, const int &b) { b < a ? a = b : 0; }
void DFS(int x, int f) {
  Stk[++top] = x;
  DFN[x] = LOW[x] = ++dfn;
  int y;
  for (int i = Head[x]; i; i = Next[i])
    if ((y = V[i]) != f) {
      if (!DFN[y]) {
        DFS(y, x);
        chkmin(LOW[x], LOW[y]);
        if (LOW[y] >= DFN[y]) {
          cnt = 0, ++m;
          while (Stk[top] != y) Fr[D[cnt++] = Stk[top--]] = m;
          Fr[y] = m, top--;
          int mx = 0;
          chkmax(mx, F[y] + 1);
          for (int j = (0), j_end_ = (cnt); j < j_end_; ++j)
            chkmax(mx, F[D[j]] + min(j + 1, cnt - j) + 1);
          if (F[x] < mx)
            F2[x] = F[x], F[x] = mx;
          else if (F2[x] < mx)
            F2[x] = mx;
          UPF[m] = mx;
        }
      } else
        chkmin(LOW[x], DFN[y]);
    }
}
bool Vis[M];
void RDFS(int x) {
  Vis[D[cnt++] = x] = 1;
  for (int i = Head[x]; i; i = Next[i])
    if (Fr[V[i]] == Fr[x] && !Vis[V[i]]) RDFS(V[i]);
}
inline void BFS() {
  Qx[Qr] = 1, QFl[Qr++] = 0;
  while (Ql < Qr) {
    int x = Qx[Ql], Fl = QFl[Ql++];
    cnt = 0;
    RDFS(x);
    for (int i = (0), i_end_ = (cnt); i < i_end_; ++i)
      chkmax(G[D[i]], min(i, cnt - i) + Fl);
    if (cnt > 1) {
      int t2 = cnt << 1, lth = cnt >> 1;
      for (int i = (0), i_end_ = (cnt); i < i_end_; ++i) D[i + cnt] = D[i];
      int l = 0, r = -1;
      for (int i = (0), i_end_ = (t2); i < i_end_; ++i) {
        while (l <= r && Q[l] < i - lth) ++l;
        if (l <= r) chkmax(G[D[i]], F[D[Q[l]]] - Q[l] + i);
        while (l <= r && F[D[Q[r]]] - Q[r] < F[D[i]] - i) r--;
        Q[++r] = i;
      }
      l = 0, r = -1;
      for (int i = (t2 - 1), i_end_ = (-1); i > i_end_; --i) {
        while (l <= r && Q[l] > i + lth) ++l;
        if (l <= r) chkmax(G[D[i]], F[D[Q[l]]] + Q[l] - i);
        while (l <= r && F[D[Q[r]]] + Q[r] < F[D[i]] + i) r--;
        Q[++r] = i;
      }
    }
    for (int i = (0), i_end_ = (cnt); i < i_end_; ++i) {
      int a = D[i], b;
      for (int j = Head[a]; j; j = Next[j])
        if (!Vis[b = V[j]]) {
          Qx[Qr] = b;
          QFl[Qr++] = max((UPF[Fr[b]] == F[a] ? F2[a] : F[a]), G[a]) + 1;
        }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    Add_Edge(u, v);
    Add_Edge(v, u);
  }
  Add_Edge(0, 1);
  DFS(m = 0, 0);
  BFS();
  for (int i = (1), i_end_ = (n + 1); i < i_end_; ++i)
    printf("%d%c", max(F[i], G[i]), " \n"[i == n]);
  return 0;
}
