#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m, nd;
int par[N], sub[N];
int q[N], qq[N], v[N];
int dep[N], fa[N], vis[N];
vector<int> e[N], E[N];
void dfs(int x) {
  dep[x] = dep[fa[x]] + 1;
  for (auto i : e[x])
    if (i != fa[x]) {
      if (!dep[i]) {
        fa[i] = x;
        dfs(i);
        if (!vis[i]) {
          E[x].push_back(i);
          E[i].push_back(x);
        }
      } else if (dep[i] < dep[x]) {
        ++nd;
        for (int y = x;; y = fa[y]) {
          E[nd].push_back(y);
          E[y].push_back(nd);
          if (y == i) break;
          vis[y] = 1;
        }
      }
    }
}
void dfs1(int x) {
  for (auto i : E[x])
    if (i != fa[x]) {
      fa[i] = x;
      dfs1(i);
    }
  if (x > n) {
    int sz = E[x].size();
    for (int i = (int)(0); i <= (int)(sz - 2); i++)
      sub[x] = max(sub[x], sub[E[x][i]] + min(sz - 2 - i, i));
  } else
    for (auto i : E[x])
      if (i != fa[x]) sub[x] = max(sub[x], sub[i] + 1);
}
void dfs2(int x) {
  if (x <= n) {
    int mx1 = par[x], mx2 = 0;
    for (auto i : E[x])
      if (i != fa[x])
        if (sub[i] + 1 > mx1)
          mx2 = mx1, mx1 = sub[i] + 1;
        else
          mx2 = max(mx2, sub[i] + 1);
    for (auto i : E[x])
      if (i != fa[x])
        par[i] = (sub[i] + 1 == mx1 ? mx2 : mx1) + (i <= n ? 1 : 0);
  } else {
    assert(E[x][E[x].size() - 1] == fa[x]);
    int sz = E[x].size(), h = 1, t = 0;
    for (int i = (int)(0); i <= (int)(sz - 1); i++)
      q[i] = E[x][i], v[i] = (i == sz - 1 ? par[x] : sub[q[i]]);
    for (int i = (int)(sz / 2 + sz); i >= (int)(sz); i--) {
      for (; h <= t && v[i % sz] + i > v[qq[t] % sz] + qq[t]; --t)
        ;
      qq[++t] = i;
    }
    for (int i = (int)(sz - 1); i >= (int)(0); i--) {
      if (qq[h] - i > sz / 2) ++h;
      assert(h <= t);
      if (i % sz != sz - 1)
        par[q[i]] = max(par[q[i]], v[qq[h] % sz] + qq[h] - i);
      for (; h <= t && v[i % sz] + i > v[qq[t] % sz] + qq[t]; --t)
        ;
      qq[++t] = i;
    }
    h = 1;
    t = 0;
    for (int i = (int)(0); i <= (int)(sz / 2); i++) {
      for (; h <= t && v[i % sz] - i > v[qq[t] % sz] - qq[t]; --t)
        ;
      qq[++t] = i;
    }
    for (int i = (int)(sz / 2 + 1); i <= (int)(sz / 2 + sz); i++) {
      if (i - qq[h] > sz / 2) ++h;
      assert(h <= t);
      if (i % sz != sz - 1)
        par[q[i % sz]] = max(par[q[i % sz]], v[qq[h] % sz] - qq[h] + i);
      for (; h <= t && v[i % sz] - i > v[qq[t] % sz] - qq[t]; --t)
        ;
      qq[++t] = i;
    }
  }
  for (auto i : E[x])
    if (i != fa[x]) dfs2(i);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  nd = n;
  dfs(1);
  dfs1(1);
  dfs2(1);
  for (int i = (int)(1); i <= (int)(n); i++) printf("%d ", max(sub[i], par[i]));
}
