#include <bits/stdc++.h>
template <typename Y>
inline bool updmin(Y &a, Y b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline bool updmax(Y &a, Y b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline Y abs(Y a) {
  if (a < 0) a = -a;
  return a;
}
template <typename Y>
inline Y sqr(Y a) {
  return a * a;
}
int read() {
  int w = 1, q = 0, ch = ' ';
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = q * 10 + ch - 48;
  return q * w;
}
inline void FileIO() {
  freopen(
      ""
      ".in",
      "r", stdin);
  freopen(
      ""
      ".out",
      "w", stdout);
}
const int maxn = 500010;
int n, m;
std::vector<int> G[maxn];
int L[maxn], Z[maxn], maxl[maxn], fa[maxn];
std::vector<int> C[maxn];
int cycnt = 0;
std::map<std::pair<int, int>, int> isb;
int low[maxn], dfn[maxn], tm = 0;
void dfs(int p, int f) {
  dfn[p] = low[p] = ++tm;
  for (auto t : G[p]) {
    if (t == f) continue;
    if (!dfn[t]) {
      dfs(t, p);
      updmin(low[p], low[t]);
      if (low[t] > dfn[p]) {
        isb[std::make_pair(t, p)] = isb[std::make_pair(p, t)] = 1;
      }
    } else {
      updmin(low[p], dfn[t]);
    }
  }
}
int bel[maxn];
void addcy(int p) {
  C[cycnt].push_back(p);
  bel[p] = cycnt;
  for (auto t : G[p]) {
    if (!bel[t] && !isb[std::make_pair(t, p)]) {
      addcy(t);
    }
  }
}
int vis[maxn];
void calcL() {
  std::vector<int> v;
  v.push_back(1);
  vis[1] = 1;
  fa[1] = 0;
  for (size_t i = 0; i < v.size(); i++) {
    int p = v[i];
    for (auto t : G[p]) {
      if (vis[t]) continue;
      vis[t] = 1;
      v.push_back(t);
      fa[t] = p;
    }
  }
  for (int i = n - 1; ~i; i--) {
    int p = v[i];
    for (auto t : G[p]) {
      if (fa[t] == p) {
        updmax(maxl[p], maxl[t] + 1);
        if (isb[std::make_pair(t, p)]) {
          updmax(L[p], maxl[t] + 1);
        }
      }
    }
  }
}
inline void solvecy(int u, int pre, int upp) {
  updmax(L[u], upp);
  std::vector<int> &cy = C[bel[u]];
  int k = (int)cy.size();
  for (int op = 0; op < 2; op++) {
    std::priority_queue<std::pair<int, int> > q;
    for (int i = 0; i < 2 * k; i++) {
      while (!q.empty() && q.top().second + i > k / 2) q.pop();
      if (!q.empty()) updmax(Z[cy[i % k]], q.top().first + i);
      q.push(std::make_pair(L[cy[i % k]] - i, -i));
    }
    std::reverse(cy.begin(), cy.end());
  }
  for (auto c : cy) {
    int fmax = 0, smax = 0;
    for (auto t : G[c]) {
      if (t != pre && isb[std::make_pair(t, c)]) {
        if (fmax < maxl[t] + 1) {
          smax = fmax;
          fmax = maxl[t] + 1;
        } else {
          updmax(smax, maxl[t] + 1);
        }
      }
    }
    for (auto t : G[c]) {
      if (t != pre && isb[std::make_pair(t, c)]) {
        int nxt = std::max(upp, Z[c]);
        updmax(nxt, fmax == maxl[t] + 1 ? smax : fmax);
        solvecy(t, c, nxt + 1);
      }
    }
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    if (!bel[i]) {
      cycnt++;
      addcy(i);
    }
  }
  calcL();
  solvecy(1, 0, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d\n", std::max(L[i], Z[i]));
  }
  return 0;
}
