#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
const int INF = 0x3f3f3f3f;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
template <typename T>
inline void cmin(T &x, T y) {
  if (x > y) x = y;
}
template <typename T>
inline void cmax(T &x, T y) {
  if (x < y) x = y;
}
int n, m, vis[MAXN];
int fa[MAXN], bel[MAXN], cnt, istop[MAXN];
int f0[MAXN], f1[MAXN], f2[MAXN], g[MAXN];
int s[MAXN << 1], top, q[MAXN << 1], head, tail;
vector<int> e[MAXN], cir[MAXN];
void Tarjan(int u) {
  vis[u] = 1;
  for (auto v : e[u]) {
    if (v == fa[u]) continue;
    if (!vis[v]) {
      fa[v] = u;
      Tarjan(v);
    } else if (!bel[v]) {
      istop[v] = 1;
      bel[v] = ++cnt;
      cir[cnt].push_back(v);
      for (int x = u; x ^ v; x = fa[x]) {
        bel[x] = cnt;
        cir[cnt].push_back(x);
      }
    }
  }
  if (!bel[u]) {
    istop[u] = 1;
    bel[u] = ++cnt;
    cir[cnt].push_back(u);
  }
}
void DFS1(int u) {
  vis[u] = 1;
  for (auto v : e[u]) {
    if (vis[v]) continue;
    DFS1(v);
  }
  if (istop[u]) {
    int b = bel[u], sz = cir[b].size(), i = 0;
    for (auto v : cir[b]) {
      f1[v] = 0;
      f2[v] = -INF;
      for (auto w : e[v]) {
        if (w == fa[v] || bel[w] == b) continue;
        int val = f0[w] + 1;
        if (val > f1[v]) {
          f2[v] = f1[v];
          f1[v] = val;
        } else if (val > f2[v]) {
          f2[v] = val;
        }
      }
      cmax(f0[u], f1[v] + min(i, sz - i));
      ++i;
    }
  }
}
void DFS2(int u) {
  vis[u] = 1;
  if (istop[u]) {
    if (fa[u]) {
      if (f0[u] + 1 == f1[fa[u]]) {
        cmax(g[u], f2[fa[u]] + 1);
      } else {
        cmax(g[u], f1[fa[u]] + 1);
      }
      cmax(g[u], g[fa[u]] + 1);
    }
    cmax(f1[u], g[u]);
    int b = bel[u], sz = cir[b].size();
    top = 0;
    for (auto v : cir[b]) {
      s[++top] = v;
      s[sz + top] = v;
    }
    top += top;
    head = 1, tail = 0;
    for (int i = 1; i <= top; ++i) {
      if (i - q[head] > sz / 2) ++head;
      if (head <= tail) {
        cmax(g[s[i]], i - q[head] + f1[s[q[head]]]);
      }
      while (head <= tail && f1[s[q[tail]]] - q[tail] < f1[s[i]] - i) {
        --tail;
      }
      q[++tail] = i;
    }
    head = 1, tail = 0;
    for (int i = top; i >= 1; --i) {
      if (q[head] - i > sz / 2) ++head;
      if (head <= tail) {
        cmax(g[s[i]], q[head] - i + f1[s[q[head]]]);
      }
      while (head <= tail && f1[s[q[tail]]] + q[tail] < f1[s[i]] + i) {
        --tail;
      }
      q[++tail] = i;
    }
  }
  for (auto v : e[u]) {
    if (vis[v]) continue;
    DFS2(v);
  }
}
void init() {
  read(n);
  read(m);
  for (int i = 1, u, v; i <= m; ++i) {
    read(u);
    read(v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
}
void solve() {
  Tarjan(1);
  memset(vis, 0, sizeof(vis));
  DFS1(1);
  memset(vis, 0, sizeof(vis));
  DFS2(1);
  for (int i = 1; i <= n; ++i) {
    printf("%d ", max(f1[i], g[i]));
  }
}
int main() {
  init();
  solve();
  return 0;
}
