#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  bool f = 1;
  char s = getchar();
  while ((s < '0' || s > '9') && s > 0) {
    if (s == '-') f ^= 1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') x = (x << 1) + (x << 3) + s - '0', s = getchar();
  return f ? x : -x;
}
int n, m, ans[500005];
int IN, dfn[500005], low[500005], bl[500005], tot;
stack<int> st;
int d1[500005], sd[500005], d2[500005], ccg[500005];
vector<int> G[500005], cl[500005];
inline void dfs0(int x, int fa) {
  dfn[x] = low[x] = ++IN, st.push(x);
  for (unsigned i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (v == fa) continue;
    if (!dfn[v])
      dfs0(v, x), low[x] = min(low[x], low[v]);
    else
      low[x] = min(low[x], dfn[v]);
  }
  if (low[x] == dfn[x]) {
    tot++;
    while (!st.empty() && dfn[st.top()] >= dfn[x])
      bl[st.top()] = tot, cl[tot].push_back(st.top()), st.pop();
  }
}
queue<int> q;
int db[500005];
inline void bfs1(int x) {
  for (int i = 1; i <= n; i++) db[i] = -1;
  db[x] = 0, q.push(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (unsigned i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (db[v] < 0) db[v] = db[u] + 1, q.push(v);
    }
  }
}
inline void dfs1(int x) {
  d1[x] = 1;
  for (unsigned i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (db[v] == db[x] + 1) {
      if (!d1[v]) dfs1(v);
      d1[x] = max(d1[x], d1[v] + 1);
    }
  }
}
struct node {
  int x, y;
  node() {}
  node(int X, int Y) { x = X, y = Y; }
};
int dq[500005 << 1], hd, tl;
bool vis[500005];
inline void dfs2(int x) {
  vis[x] = 1;
  int len = cl[x].size(), cj = len >> 1;
  for (int id = 0; id < len; id++) {
    int u = cl[x][id];
    sd[u] = ans[u] = 1;
    for (unsigned i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (bl[u] != bl[v]) sd[u] = max(sd[u], d1[v] + 1);
    }
  }
  hd = tl = 0;
  for (int i = cj, lim = len << 1; i < lim; i++) {
    int u = cl[x][i % len], p;
    while (hd < tl && i - dq[hd] > cj) hd++;
    if (hd < tl) p = dq[hd], ans[u] = max(ans[u], i - p + sd[cl[x][p % len]]);
    while (hd < tl && ((p = dq[tl - 1]) || 1) &&
           i - p + sd[cl[x][p % len]] < sd[u])
      tl--;
    dq[tl++] = i;
  }
  hd = tl = 0;
  for (int i = cj, g = (len << 1) - 1; i <= g; i++) {
    int u = cl[x][(g - i) % len], p;
    while (hd < tl && i - dq[hd] > cj) hd++;
    if (hd < tl)
      p = dq[hd], ans[u] = max(ans[u], i - p + sd[cl[x][(g - p) % len]]);
    while (hd < tl && ((p = dq[tl - 1]) || 1) &&
           i - p + sd[cl[x][(g - p) % len]] < sd[u])
      tl--;
    dq[tl++] = i;
  }
  for (int id = 0; id < len; id++) {
    int u = cl[x][id];
    hd = tl = 0;
    for (unsigned i = 0; i < G[u].size(); i++)
      if (bl[G[u][i]] != x) {
        int v = G[u][i];
        while (hd < tl && d1[dq[tl - 1]] < d1[v]) tl--;
        dq[tl++] = v;
      }
    for (unsigned i = 0; i < G[u].size(); i++)
      if (bl[G[u][i]] != x) {
        int v = G[u][i], cg = ans[u];
        if (hd < tl && dq[hd] == v) hd++;
        if (hd < tl) cg = max(cg, d1[dq[hd]] + 1);
        while (hd < tl && d1[dq[tl - 1]] < d1[v]) tl--;
        dq[tl++] = v;
        if (!vis[bl[v]]) ccg[v] = cg;
      }
    for (unsigned i = 0; i < G[u].size(); i++)
      if (bl[G[u][i]] != x) {
        int v = G[u][i];
        if (!vis[bl[v]]) swap(d1[u], ccg[v]), dfs2(bl[v]), swap(d1[u], ccg[v]);
      }
  }
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    G[u].push_back(v), G[v].push_back(u);
  }
  dfs0(1, 0);
  bfs1(1), dfs1(1);
  dfs2(bl[1]);
  for (int i = 1; i <= n; i++) printf("%d ", max(ans[i], sd[i]) - 1);
  return 0;
}
