#include <bits/stdc++.h>
using namespace std;
int he[1000050 >> 1], ne[1000050 << 1], to[1000050 << 1], tot;
int n, m, ds;
const int inf = 1e9;
inline void addedge(int x, int y) {
  to[++tot] = y;
  ne[tot] = he[x];
  he[x] = tot;
}
vector<int> v[1000050], ve[1000050];
int dfn[1000050 >> 1], low[1000050 >> 1], cnt, st[1000050 >> 1], tp;
inline void tarjan(int g) {
  dfn[g] = low[g] = ++cnt;
  st[++tp] = g;
  for (int i = he[g]; i; i = ne[i]) {
    if (dfn[to[i]])
      low[g] = min(low[g], dfn[to[i]]);
    else {
      tarjan(to[i]);
      low[g] = min(low[g], low[to[i]]);
      if (low[to[i]] == dfn[g]) {
        ++ds;
        v[g].push_back(ds);
        while (1) {
          int t = st[tp--];
          v[ds].push_back(t);
          if (t == to[i]) break;
        }
      }
    }
  }
}
int len[1000050], a[1000050];
inline void dfs(int g) {
  len[g] = g <= n ? 1 : 0;
  for (int i = 0, to; i < v[g].size(); ++i) {
    to = v[g][i], dfs(to);
    if (g <= n) len[g] = max(len[g], len[to] + 1);
  }
  int sz = v[g].size();
  if (!sz) return;
  if (g > n) {
    a[sz] = 0;
    for (int i = sz - 1; ~i; --i)
      a[i] = max(len[v[g][i]] + sz - 1 - i, a[i + 1]);
    len[g] = a[0];
    for (int i = 0, ma = 0; i < sz; ++i) {
      ma = max(ma, len[v[g][i]] + i);
      len[g] = min(len[g], max(ma, a[i + 1]));
    }
  }
}
int ans[1000050 << 1];
int ma1[1000050 << 3], ma2[1000050 << 3];
inline void build(int g, int l, int r) {
  if (l == r) {
    ma1[g] = a[l] - l;
    ma2[g] = a[l] + l;
    return;
  }
  const int m = l + r >> 1;
  build(g << 1, l, m);
  build(g << 1 | 1, m + 1, r);
  ma1[g] = max(ma1[g << 1], ma1[g << 1 | 1]);
  ma2[g] = max(ma2[g << 1], ma2[g << 1 | 1]);
}
inline int ask1(int g, int l, int r, int x, int y) {
  if (l > y || r < x) return -inf;
  if (l >= x && r <= y) return ma1[g];
  const int m = l + r >> 1;
  int r1 = ask1(g << 1, l, m, x, y), r2 = ask1(g << 1 | 1, m + 1, r, x, y);
  return max(r1, r2);
}
inline int ask2(int g, int l, int r, int x, int y) {
  if (l > y || r < x) return -inf;
  if (l >= x && r <= y) return ma2[g];
  const int m = l + r >> 1;
  int r1 = ask2(g << 1, l, m, x, y), r2 = ask2(g << 1 | 1, m + 1, r, x, y);
  return max(r1, r2);
}
inline int getans(int id, int L, int R, int ma) {
  int l = L, r = R;
  while (l + 1 < r) {
    int mid = l + r >> 1;
    if (ask2(1, 1, ma, L, mid) - L <= ask1(1, 1, ma, mid + 1, R) + R)
      l = mid;
    else
      r = mid;
  }
  int l1 = ask2(1, 1, ma, L, l) - L, l2 = ask1(1, 1, ma, l + 1, R) + R;
  l1 = max(l1, l2);
  int r1 = ask2(1, 1, ma, L, r) - L, r2 = ask1(1, 1, ma, r + 1, R) + R;
  r1 = max(r1, r2);
  return min(l1, r1);
}
int sz, ma;
inline void dfs2(int g, int fa) {
  ans[g] = len[g] - 1;
  sz = v[g].size();
  if (!sz) return;
  ve[g].resize(sz);
  if (g <= n) {
    a[sz] = 0;
    for (int i = sz - 1; ~i; --i) a[i] = max(len[v[g][i]] + 1, a[i + 1]);
    for (int i = 0, ma = 0; i < sz; ++i) {
      len[g] = len[fa] + 1;
      len[g] = max(len[g], ma);
      len[g] = max(len[g], a[i + 1]);
      ma = max(ma, len[v[g][i]] + 1);
      ve[g][i] = len[g];
    }
    for (int i = 0; i < v[g].size(); ++i) len[g] = ve[g][i], dfs2(v[g][i], g);
    return;
  }
  ma = sz + sz;
  a[sz] = len[fa];
  for (int i = 0; i < sz; ++i) a[i] = a[i + sz + 1] = len[v[g][i]];
  build(1, 1, ma);
  for (int i = 0; i < sz; ++i) ve[g][i] = getans(i, i + 1, i + sz, ma);
  for (int i = 0; i < v[g].size(); ++i) {
    len[g] = ve[g][i];
    len[v[g][i]] = max(len[v[g][i]], ve[g][i] + 1);
    dfs2(v[g][i], g);
  }
}
int b[30];
inline void dfs3(int g, int fa) {
  ans[g] = len[g] - 1;
  sz = v[g].size();
  if (!sz) return;
  ve[g].resize(sz);
  if (g <= n) {
    a[sz] = 0;
    for (int i = sz - 1; ~i; --i) a[i] = max(len[v[g][i]] + 1, a[i + 1]);
    for (int i = 0, ma = 0; i < sz; ++i) {
      len[g] = len[fa] + 1;
      len[g] = max(len[g], ma);
      len[g] = max(len[g], a[i + 1]);
      ma = max(ma, len[v[g][i]] + 1);
      ve[g][i] = len[g];
    }
    for (int i = 0; i < v[g].size(); ++i) len[g] = ve[g][i], dfs3(v[g][i], g);
    return;
  }
  ma = sz + sz;
  a[sz] = len[fa];
  for (int i = 0; i < sz; ++i) a[i] = a[i + sz + 1] = len[v[g][i]];
  for (int i = 0; i < sz; ++i) {
    b[i + sz + 1] = 0;
    for (int j = i + sz; j > i; --j) b[j] = max(a[j] + i + sz - j, b[j + 1]);
    len[g] = b[i + 1];
    for (int j = i + 1, ma = 0; j <= i + sz; ++j) {
      ma = max(ma, a[j] + j - i - 1);
      len[g] = min(len[g], max(ma, b[j + 1]));
    }
    ve[g][i] = len[g];
  }
  for (int i = 0; i < v[g].size(); ++i) {
    len[g] = ve[g][i];
    len[v[g][i]] = max(len[v[g][i]], ve[g][i] + 1);
    dfs3(v[g][i], g);
  }
}
inline void work2(int rt) {
  dfs3(rt, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  puts("");
}
int main() {
  scanf("%d%d", &n, &m);
  ds = n;
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    addedge(x, y), addedge(y, x);
  }
  int rt = 1;
  tarjan(rt);
  int masize = 0;
  for (int i = 1; i <= ds; ++i)
    if (v[i].size() > masize) masize = v[i].size();
  dfs(rt);
  if (masize < 10) return work2(rt), 0;
  dfs2(rt, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  puts("");
  return 0;
}
