#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chkmin(T &a, T const &b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chkmax(T &a, T const &b) {
  return a < b ? a = b, true : false;
}
const int M = 500005;
struct Queue {
  int pos[M << 1], val[M << 1];
  int head, tail;
  void clear() { head = tail = 0; }
  void push(int r, int x) {
    while (head < tail and val[tail - 1] < x) --tail;
    pos[tail] = r;
    val[tail] = x;
    ++tail;
  }
  int maxn(int l) {
    if (head < tail and pos[head] < l) ++head;
    return head < tail ? val[head] : 0;
  }
} Q0, Q1;
struct edge {
  int to;
  edge *next;
} * E[M], *G[M << 1], Pool[M * 6], *allc = Pool;
int dfn[M], low[M], Fa[M], dep[M];
int Q[M], A[M][2], B[M], val[M * 3], id[M];
int n, m, top, dfn_cnt, scc_cnt;
void add_edge(int u, int v, edge **G) {
  *allc = (edge){v, G[u]};
  G[u] = allc++;
}
void solve_ring(int u, int v) {
  int w = ++scc_cnt;
  int len = dep[v] - dep[u] + 1;
  for (int x = v, d = 1; x != u; x = Fa[x], ++d) {
    add_edge(w, x, G);
    chkmax(B[w - n], A[x][0] + min(d, len - d));
  }
  int tmp = B[w - n];
  for (int k = (0), k_end__ = (2); k < k_end__; ++k)
    if (tmp > A[u][k]) swap(tmp, A[u][k]);
  add_edge(u, w, G);
}
void Tarjan(int u, int fa) {
  low[u] = dfn[u] = ++dfn_cnt;
  for (edge *e = u[E]; e; e = e->next) {
    int v = e->to;
    if (v == fa) continue;
    if (!v[dfn]) {
      dep[v] = dep[u] + 1;
      Tarjan(v, Fa[v] = u);
      chkmin(low[u], low[v]);
    } else
      chkmin(low[u], dfn[v]);
  }
  for (edge *e = u[E]; e; e = e->next) {
    if ((Fa[e->to] != u and low[e->to] == dfn[u]) or low[e->to] > dfn[u])
      solve_ring(u, e->to);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u, v, E);
    add_edge(v, u, E);
  }
  scc_cnt = n;
  Tarjan(1, -1);
  int l = 0, r = 0;
  Q[r++] = 1;
  while (l < r) {
    int u = Q[l++];
    for (edge *e = G[u]; e; e = e->next) {
      int w = e->to, sz = 0;
      Q0.clear(), Q1.clear();
      val[sz] = A[u][B[w - n] == A[u][0]];
      id[sz++] = u;
      for (edge *e = G[w]; e; e = e->next) {
        Q[r++] = id[sz] = e->to;
        val[sz] = A[e->to][0];
        ++sz;
      }
      for (int i = (0), i_end__ = (sz); i < i_end__; ++i)
        val[i + sz + sz] = val[i + sz] = val[i];
      int len0 = sz >> 1, pos0 = sz + 1;
      int len1 = sz - len0 - 1, pos1 = sz + len1 + 2;
      for (int i = (pos0 - len0), i_end__ = (pos0); i < i_end__; ++i)
        Q0.push(i, val[i] - i);
      for (int i = (pos1 - len1), i_end__ = (pos1); i < i_end__; ++i)
        Q1.push(i, val[i] + i);
      for (int i = (1), i_end__ = (sz); i < i_end__; ++i) {
        int u = id[i];
        int x = Q0.maxn(pos0 - len0) + i + sz;
        int y = Q1.maxn(pos1 - len1) - i - sz;
        for (int k = (0), k_end__ = (2); k < k_end__; ++k)
          if (x > A[u][k]) swap(x, A[u][k]);
        for (int k = (0), k_end__ = (2); k < k_end__; ++k)
          if (y > A[u][k]) swap(y, A[u][k]);
        Q0.push(pos0, val[pos0] - pos0), ++pos0;
        Q1.push(pos1, val[pos1] + pos1), ++pos1;
      }
    }
  }
  for (int i = (1), i_end__ = (n + 1); i < i_end__; ++i) printf("%d ", A[i][0]);
  puts("");
  return 0;
}
