#include <bits/stdc++.h>
using namespace std;
int n, m, num[500005], low[500005], rig = 0, numCircle = 0;
int belong[500005], pos[500005], z[500005];
pair<int, int> l1[500005], l2[500005];
vector<pair<int, int> > g[500005];
vector<int> circle[500005];
stack<int> st;
queue<int> qu;
priority_queue<pair<int, int> > pr;
void setup() {
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back(make_pair(v, i));
    g[v].push_back(make_pair(u, i));
  }
}
void dfs(int u, int pE) {
  num[u] = low[u] = ++rig;
  st.push(u);
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i].first;
    int id = g[u][i].second;
    if (id == pE) continue;
    if (num[v])
      low[u] = min(low[u], num[v]);
    else {
      dfs(v, id);
      low[u] = min(low[u], low[v]);
    }
  }
  if (low[u] == num[u]) {
    numCircle++;
    while (true) {
      int v = st.top();
      st.pop();
      belong[v] = numCircle;
      pos[v] = circle[numCircle].size();
      circle[numCircle].push_back(v);
      if (v == u) break;
    }
  }
}
int circleDistance(int u, int v) {
  if (pos[u] > pos[v]) return circleDistance(v, u);
  return min(pos[v] - pos[u], pos[u] + int(circle[belong[u]].size()) - pos[v]);
}
void updateL(int u, int value, int v) {
  if (value > l1[u].first) {
    if (v != l1[u].second) l2[u] = l1[u];
    l1[u] = make_pair(value, v);
  } else if (value > l2[u].first && v != l1[u].second)
    l2[u] = make_pair(value, v);
}
void buildLAndZ(int s, int p) {
  for (int i = 0; i <= int(circle[belong[s]].size()) - 1; i++) {
    int u = circle[belong[s]][i];
    for (int j = 0; j <= int(g[u].size()) - 1; j++) {
      int v = g[u][j].first;
      if (belong[v] == belong[s] || (u == s && v == p)) continue;
      buildLAndZ(v, u);
      updateL(u, max(l1[v].first, z[v]) + 1, v);
    }
    if (u != s) z[s] = max(z[s], l1[u].first + circleDistance(s, u));
  }
}
void buildLAndZFirstCircle(int u) {
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i].first;
    if (belong[v] == belong[u]) continue;
    buildLAndZ(v, u);
    updateL(u, max(l1[v].first, z[v]) + 1, v);
  }
}
void calcAns(int s, int p) {
  if (p) {
    if (s != l1[p].second)
      updateL(s, max(z[p], l1[p].first) + 1, p);
    else
      updateL(s, max(z[p], l2[p].first) + 1, p);
  }
  int idCircle = belong[s], size = circle[idCircle].size();
  int id = pos[s], dis = 0;
  pr.push(make_pair(l1[s].first, 0));
  while (true) {
    if (++dis == size * 2) break;
    id = (id + 1 == size ? 0 : id + 1);
    int u = circle[idCircle][id];
    if (u != s) {
      while (!pr.empty() && dis - pr.top().second > size / 2) pr.pop();
      z[u] = max(z[u], pr.top().first + dis);
    }
    pr.push(make_pair(l1[u].first - dis, dis));
  }
  while (!pr.empty()) pr.pop();
  id = pos[s], dis = 0;
  pr.push(make_pair(l1[s].first, 0));
  while (true) {
    if (++dis == size * 2) break;
    id = (id - 1 == -1 ? size - 1 : id - 1);
    int u = circle[idCircle][id];
    if (u != s) {
      while (!pr.empty() && dis - pr.top().second > size / 2) pr.pop();
      z[u] = max(z[u], pr.top().first + dis);
    }
    pr.push(make_pair(l1[u].first - dis, dis));
  }
  while (!pr.empty()) pr.pop();
  for (int i = 0; i <= size - 1; i++) {
    int u = circle[idCircle][i];
    for (int j = 0; j <= int(g[u].size()) - 1; j++) {
      int v = g[u][j].first;
      if (belong[v] == belong[s] || (u == s && v == p)) continue;
      calcAns(v, u);
    }
  }
}
void calcAnsFirstCircle() {
  int s = circle[1][0];
  for (int i = 1; i <= int(circle[1].size()) - 1; i++) {
    int u = circle[1][i];
    z[s] = max(z[s], l1[u].first + circleDistance(s, u));
  }
  calcAns(s, 0);
}
void xuly() {
  dfs(1, 0);
  for (int i = 0; i <= int(circle[1].size()) - 1; i++) {
    int u = circle[1][i];
    buildLAndZFirstCircle(u);
  }
  calcAnsFirstCircle();
  for (int u = 1; u <= n; u++) cout << max(l1[u].first, z[u]) << ' ';
}
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
