#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct edge {
  int v, next;
} vs[1000010 << 1];
int n, m, ee, st[1000010], vis[1000010], id[1000010];
int cnt, fa[1000010], Ans[1000010], w[1000010];
int f1[1000010], f2[1000010], p1[1000010], p2[1000010];
vector<int> V[1000010];
struct segment_tree {
  int a[1000010], len, tree[1000010 << 2];
  inline void build(int l, int r, int rt) {
    if (l == r) {
      tree[rt] = a[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, rt << 1);
    build(mid + 1, r, rt << 1 | 1);
    tree[rt] = max(tree[rt << 1], tree[rt << 1 | 1]);
  }
  inline int Ask(int L, int R, int l, int r, int rt) {
    if (L <= l && r <= R) return tree[rt];
    int mid = (l + r) >> 1, res = 0;
    if (mid >= L) res = max(res, Ask(L, R, l, mid, rt << 1));
    if (mid < R) res = max(res, Ask(L, R, mid + 1, r, rt << 1 | 1));
    return res;
  }
} S1, S2;
inline void addedge(int u, int v) {
  vs[++ee].v = v;
  vs[ee].next = st[u];
  st[u] = ee;
}
void print(vector<int> v) {
  for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  puts("");
}
inline void dfs(int rt, int pr) {
  vis[rt] = 1;
  for (int i = st[rt]; i; i = vs[i].next) {
    if (vs[i].v == pr) continue;
    if (vis[vs[i].v]) {
      if (id[vs[i].v]) continue;
      id[vs[i].v] = ++cnt;
      int lx = rt;
      while (lx != vs[i].v) V[cnt].push_back(lx), id[lx] = cnt, lx = fa[lx];
      V[cnt].push_back(vs[i].v);
      reverse(V[cnt].begin(), V[cnt].end());
      continue;
    }
    fa[vs[i].v] = rt;
    dfs(vs[i].v, rt);
  }
}
inline void DFS(int rt, int pr) {
  p1[rt] = p2[rt] = -1;
  int G = 0, T = 0;
  for (int i = 1; i < (int)V[id[rt]].size(); i++) {
    int v = V[id[rt]][i], len = min((int)V[id[rt]].size() - i, i);
    for (int j = st[v]; j; j = vs[j].next) {
      if (id[vs[j].v] == id[rt] && id[rt]) continue;
      DFS(vs[j].v, v);
      int S = f1[vs[j].v] + 1, P = vs[j].v;
      if (S > f1[v]) swap(S, f1[v]), swap(P, p1[v]);
      if (S > f2[v]) swap(S, f2[v]), swap(P, p2[v]);
    }
    int S = f1[v] + len, P = v;
    if (S > G) G = S, T = P;
  }
  if (G > f1[rt]) swap(G, f1[rt]), swap(T, p1[rt]);
  if (G > f2[rt]) swap(G, f2[rt]), swap(T, p2[rt]);
  for (int i = st[rt]; i; i = vs[i].next) {
    if (id[vs[i].v] == id[rt] && id[rt]) continue;
    if (vs[i].v == pr) continue;
    DFS(vs[i].v, rt);
    int S = f1[vs[i].v] + 1, P = vs[i].v;
    if (S > f1[rt]) swap(S, f1[rt]), swap(P, p1[rt]);
    if (S > f2[rt]) swap(S, f2[rt]), swap(P, p2[rt]);
  }
}
inline int calc1(int s, int x, int y) {
  if (x <= y)
    return S1.Ask(x, y, 1, S1.len, 1) - s % S1.len;
  else
    return max(S1.Ask(x, S1.len, 1, S1.len, 1) - s,
               S1.Ask(1, y, 1, S1.len, 1) + S1.len - s);
}
inline int calc2(int s, int x, int y) {
  if (x >= y)
    return S2.Ask(y, x, 1, S2.len, 1) - (S2.len - s + 1) % S2.len;
  else
    return max(S2.Ask(1, x, 1, S2.len, 1) - (S2.len - s + 1),
               S2.Ask(y, S2.len, 1, S2.len, 1) + s - 1);
}
inline void SDFS(int rt, int pr, int prs) {
  for (int i = st[rt]; i; i = vs[i].next) {
    if (vs[i].v == pr) continue;
    if (id[vs[i].v] == id[rt] && id[rt]) continue;
    SDFS(vs[i].v, rt, max((p1[rt] == vs[i].v ? f2[rt] : f1[rt]), prs) + 1);
  }
  if (!id[rt]) {
    Ans[rt] = max(prs, f1[rt]);
  } else {
    w[1] = max((id[p1[rt]] == id[rt] ? f2[rt] : f1[rt]), prs);
    int len = V[id[rt]].size();
    for (int i = 1; i < len; i++) w[i + 1] = f1[V[id[rt]][i]];
    S1.len = S2.len = len;
    for (int i = 1; i <= len; i++) S1.a[i] = i + w[i];
    for (int i = 1; i <= len; i++) S2.a[len - i + 1] = i + w[len - i + 1];
    S1.build(1, len, 1);
    S2.build(1, len, 1);
    for (int i = 1; i <= len; i++) {
      int p = i + (len / 2);
      Ans[V[id[rt]][i - 1]] = max(
          calc1(i,
                (i + 1 < 1 ? i + 1 + len : (i + 1 > len ? i + 1 - len : i + 1)),
                (p < 1 ? p + len : (p > len ? p - len : p))),
          calc2(
              i,
              (i - 1 < 1 ? i - 1 + len : (i - 1 > len ? i - 1 - len : i - 1)),
              ((p < 1 ? p + len : (p > len ? p - len : p)) + 1 < 1
                   ? (p < 1 ? p + len : (p > len ? p - len : p)) + 1 + len
                   : ((p < 1 ? p + len : (p > len ? p - len : p)) + 1 > len
                          ? (p < 1 ? p + len : (p > len ? p - len : p)) + 1 -
                                len
                          : (p < 1 ? p + len : (p > len ? p - len : p)) + 1))));
    }
  }
  for (int i = 1; i < (int)V[id[rt]].size(); i++) {
    int v = V[id[rt]][i];
    for (int j = st[v]; j; j = vs[j].next) {
      if (id[vs[j].v] == id[v] && id[v]) continue;
      SDFS(vs[j].v, v, max(Ans[v], (vs[j].v == p1[v] ? f2[v] : f1[v])) + 1);
    }
  }
  for (int i = 0; i < (int)V[id[rt]].size(); i++)
    Ans[V[id[rt]][i]] = max(Ans[V[id[rt]][i]], f1[V[id[rt]][i]]);
  Ans[rt] = max(Ans[rt], prs);
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    addedge(u, v);
    addedge(v, u);
  }
  dfs(1, 0);
  DFS(1, 0);
  SDFS(1, 0, 0);
  for (int i = 1; i <= n; i++) printf("%d ", Ans[i]);
  puts("");
  return 0;
}
