#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
int n, m, dp[MAXN], level[MAXN];
int dist[MAXN], val[MAXN * 3];
int local[MAXN], answer[MAXN];
vector<pair<int, int>> adj[MAXN], nex[MAXN];
bool cut_edge[MAXN * 3];
bool mark[MAXN];
void dfs_cut_edge(int v, int par = 0) {
  dp[v] = level[v] = level[par] + 1;
  mark[v] = true;
  for (auto i : adj[v]) {
    if (!mark[i.first]) {
      dfs_cut_edge(i.first, v);
      dp[v] = min(dp[v], dp[i.first]);
      if (dp[i.first] > level[v]) cut_edge[i.second] = true;
    } else if (i.first != par)
      dp[v] = min(dp[v], level[i.first]);
  }
}
void bfs(int v) {
  queue<int> q;
  dist[v] = 1;
  q.push(v);
  while (q.size()) {
    int tp = q.front();
    q.pop();
    for (auto i : adj[tp]) {
      if (!dist[i.first]) {
        dist[i.first] = dist[tp] + 1;
        q.push(i.first);
      }
      if (dist[i.first] == (dist[tp] + 1)) nex[tp].push_back(i);
    }
  }
}
void dfs_(int v, int par = 0) {
  mark[v] = true;
  for (auto i : nex[v]) {
    if (!mark[i.first]) dfs_(i.first, v);
    dp[v] = max(dp[v], dp[i.first] + 1);
    if (cut_edge[i.second]) val[i.second] = dp[i.first] + 1;
  }
}
inline int get_dist(int l, int r, int len) {
  if (l > r) return len - l + r;
  return r - l;
}
inline int get_(pair<int, int> p, int id, int len) {
  return p.first + get_dist(p.second, id, len);
}
void dfs(int v, int par = 0) {
  mark[v] = true;
  vector<int> cycle;
  cycle.push_back(v);
  while (true) {
    bool re = false;
    for (auto i : adj[cycle.back()])
      if (!mark[i.first] && !cut_edge[i.second]) {
        cycle.push_back(i.first);
        mark[i.first] = true;
        re = true;
        break;
      }
    if (!re) break;
  }
  for (auto v : cycle)
    for (auto e : adj[v])
      if (cut_edge[e.second]) local[v] = max(local[v], val[e.second]);
  int len = cycle.size();
  deque<pair<int, int>> deq;
  for (int i = (len / 2); i; i--) {
    int v = cycle[len - i];
    pair<int, int> me(local[v], len - i);
    while (deq.size() && get_(me, 0, len) >= get_(deq.back(), 0, len))
      deq.pop_back();
    deq.push_back(me);
  }
  for (int i = 0; i < len; i++) {
    while (deq.size() && get_dist(deq.front().second, i, len) > (len / 2))
      deq.pop_front();
    if (deq.size()) dp[cycle[i]] = get_(deq.front(), i, len);
    if (i == (len - 1)) break;
    int v = cycle[i];
    pair<int, int> me(local[v], i);
    while (deq.size() && get_(me, i + 1, len) >= get_(deq.back(), i + 1, len))
      deq.pop_back();
    deq.push_back(me);
  }
  deq.clear();
  reverse(cycle.begin(), cycle.end());
  for (int i = ((len - 1) / 2); i; i--) {
    int v = cycle[len - i];
    pair<int, int> me(local[v], len - i);
    while (deq.size() && get_(me, 0, len) >= get_(deq.back(), 0, len))
      deq.pop_back();
    deq.push_back(me);
  }
  for (int i = 0; i < len; i++) {
    while (deq.size() && get_dist(deq.front().second, i, len) > ((len - 1) / 2))
      deq.pop_front();
    if (deq.size()) dp[cycle[i]] = max(dp[cycle[i]], get_(deq.front(), i, len));
    if (i == (len - 1)) break;
    int v = cycle[i];
    pair<int, int> me(local[v], i);
    while (deq.size() && get_(me, i + 1, len) >= get_(deq.back(), i + 1, len))
      deq.pop_back();
    deq.push_back(me);
  }
  for (auto i : cycle) answer[i] = max(dp[i], local[i]);
  for (auto i : cycle) {
    int id = 0, mx = 0, smx = 0;
    for (auto e : adj[i])
      if (cut_edge[e.second])
        if (val[e.second] > mx) {
          mx = val[e.second];
          id = e.first;
        }
    for (auto e : adj[i])
      if (cut_edge[e.second] && e.first != id) smx = max(smx, val[e.second]);
    for (auto e : adj[i])
      if (cut_edge[e.second] && !mark[e.first]) {
        if (e.first == id) {
          val[e.second] = max(dp[i], smx) + 1;
          dfs(e.first, i);
        } else {
          val[e.second] = max(dp[i], mx) + 1;
          dfs(e.first, i);
        }
      }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
  }
  dfs_cut_edge(1);
  bfs(1);
  memset(mark, 0, sizeof(mark));
  memset(dp, 0, sizeof(dp));
  dfs_(1);
  memset(mark, 0, sizeof(mark));
  memset(dp, 0, sizeof(dp));
  dfs(1);
  for (int i = 1; i <= n; i++) cout << answer[i] << ' ';
  return 0;
}
