#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int maxn = 1e6 + 10;
template <class T>
T mymin(const T a, const T b) {
  return a < b ? a : b;
}
template <class T>
T mymax(const T a, const T b) {
  return a > b ? a : b;
}
int dfn[maxn], low[maxn], scc_cnt, dfs_clock, inst[maxn], bel[maxn];
struct edge {
  int u, v;
  edge(int a = 0, int b = 0) : u(a), v(b){};
};
vector<edge> es;
vector<int> G[maxn], sccs[maxn];
stack<int> S;
int N, M;
bool isbridge[maxn << 2];
void tarjan(int u, int in_edge) {
  dfn[u] = low[u] = ++dfs_clock;
  S.push(u);
  for (int nx : G[u]) {
    int v = es[nx].v;
    if (!dfn[v]) {
      tarjan(v, nx);
      low[u] = min(low[u], low[v]);
      if (low[v] > dfn[u]) isbridge[nx] = 1;
    } else if (nx != (in_edge ^ 1))
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    int v;
    scc_cnt++;
    do {
      v = S.top();
      S.pop();
      sccs[scc_cnt].emplace_back(v);
      bel[v] = scc_cnt;
    } while (!S.empty() && u != v);
  }
}
int L[maxn], fa[maxn], dep[maxn], Z[maxn];
bool vis[maxn];
void bfs() {
  queue<int> q;
  q.push(1);
  vector<int> nodes;
  vis[1] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    nodes.emplace_back(u);
    for (int nx : G[u]) {
      int v = es[nx].v;
      if (!vis[v]) {
        vis[v] = 1;
        q.push(v);
        fa[v] = u;
      }
    }
  }
  for (auto it = nodes.rbegin(); it != nodes.rend(); it++) {
    int u = *it;
    for (int nx : G[u]) {
      int v = es[nx].v;
      if (fa[v] == u) {
        dep[u] = max(dep[v] + 1, dep[u]);
        if (isbridge[nx]) {
          L[u] = max(L[u], 1 + dep[v]);
        }
      }
    }
  }
}
void solve(int u, int par, int upval) {
  L[u] = max(L[u], upval);
  auto &cycle = sccs[bel[u]];
  for (int it = 0; it < 2; it++) {
    priority_queue<pair<int, int> > q;
    for (int i = 0; i < 2 * cycle.size(); i++) {
      int d = 2 * cycle.size() - i;
      while (!q.empty() && q.top().second - d > cycle.size() / 2) q.pop();
      if (!q.empty())
        Z[cycle[i % cycle.size()]] =
            max(Z[cycle[i % cycle.size()]], q.top().first - d);
      q.push(make_pair(L[cycle[i % cycle.size()]] + d, d));
    }
    reverse(cycle.begin(), cycle.end());
  }
  for (auto u : cycle) {
    int mx1, mx2;
    mx1 = mx2 = 0;
    for (int nx : G[u]) {
      int v = es[nx].v;
      if (v == par || !isbridge[nx]) continue;
      if (mx2 < 1 + dep[v]) {
        mx2 = 1 + dep[v];
        if (mx1 < mx2) swap(mx1, mx2);
      }
    }
    for (int nx : G[u]) {
      int v = es[nx].v;
      if (v == par || !isbridge[nx]) continue;
      int pssval = max(upval, Z[u]);
      if (mx1 == 1 + dep[v])
        pssval = max(pssval, mx2);
      else
        pssval = max(pssval, mx1);
      solve(v, u, pssval + 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    int u, v;
    cin >> u >> v;
    es.emplace_back(edge(u, v));
    es.emplace_back(edge(v, u));
    G[u].emplace_back(es.size() - 2);
    G[v].emplace_back(es.size() - 1);
  }
  for (int i = 1; i <= N; i++)
    if (!dfn[i]) tarjan(i, 0);
  bfs();
  solve(1, 0, 0);
  for (int i = 1; i <= N; i++) cout << max(L[i], Z[i]) << " ";
  cout << endl;
  return 0;
}
