#include <bits/stdc++.h>
using namespace std;
const bool print = false;
const int N = 5e5 + 7;
int n, m;
vector<int> gr[N];
int cyk[N], odl[N], par[N];
vector<int> mycyk[N];
bool odw[N];
int ans[N];
vector<int> child[N];
int dpd[N], dpu[N];
void dfs1(int v) {
  odw[v] = 1;
  for (int i : gr[v]) {
    if (i == par[v]) continue;
    if (odw[i]) {
      if (odl[i] < odl[v]) {
        int w = v;
        while (w != i) {
          cyk[w] = i;
          mycyk[i].push_back(w);
          w = par[w];
        }
        cyk[i] = i;
        mycyk[i].push_back(i);
        reverse((mycyk[i]).begin(), (mycyk[i]).end());
      }
      continue;
    }
    odl[i] = odl[v] + 1;
    par[i] = v;
    dfs1(i);
    if (cyk[i] != cyk[v] || !cyk[v]) child[v].push_back(i);
  }
}
void dfs2(int v) {
  for (int i = (1); i <= ((int)mycyk[v].size() - 1); i++) {
    dfs2(mycyk[v][i]);
    dpd[v] = max(dpd[v], dpd[mycyk[v][i]] + min(i, (int)mycyk[v].size() - i));
  }
  for (int i : child[v]) {
    dfs2(i);
    dpd[v] = max(dpd[v], dpd[i] + 1);
  }
}
deque<int> kol;
void clearit() { kol.clear(); }
void add(int v) {
  while (!kol.empty() && kol.back() < v) kol.pop_back();
  kol.push_back(v);
}
void remove(int v) {
  if (kol.front() == v) kol.pop_front();
}
int war[N];
void solve(int v) {
  int k = mycyk[v].size();
  clearit();
  for (int i = (0); i <= (k - 1); i++) {
    war[i] = max(dpd[mycyk[v][i]], dpu[mycyk[v][i]]);
    if (!i) {
      war[0] = dpu[mycyk[v][i]];
      for (int j : child[v]) war[0] = max(war[0], dpd[j] + 1);
    }
  }
  for (int i = (k / 2); i >= (1); i--) add(war[k - i] + i);
  for (int i = (0); i <= (k - 1); i++) {
    int x = mycyk[v][i];
    if (i) dpu[x] = max(dpu[x], kol.front() + i);
    remove(war[(i - k / 2 + k) % k] - (i - k / 2));
    add(war[i] - i);
  }
  clearit();
  for (int i = (k / 2 - 1); i >= (0); i--) add(war[i] + k + i);
  for (int i = (k - 1); i >= (1); i--) {
    int x = mycyk[v][i];
    dpu[x] = max(dpu[x], kol.front() - i);
    remove(war[(i + k / 2) % k] + (i + k / 2));
    add(war[i] + i);
  }
}
void dfs3(int v) {
  priority_queue<int> pri;
  pri.push(dpu[v]);
  if (cyk[v] == v) {
    solve(v);
    int j = 0;
    for (int i : mycyk[v])
      if (i != v) {
        dfs3(i);
        j++;
        pri.push(dpd[i] + min(j, (int)mycyk[v].size() - j));
      }
  }
  for (int i : child[v]) pri.push(dpd[i] + 1);
  int x = pri.top();
  pri.pop();
  int y = -1;
  if (!pri.empty()) y = pri.top();
  for (int i : child[v]) {
    if (dpd[i] + 1 != x)
      dpu[i] = x + 1;
    else
      dpu[i] = y + 1;
    dfs3(i);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
  odl[1] = 1;
  dfs1(1);
  dfs2(1);
  dfs3(1);
  for (int i = (1); i <= (n); i++) ans[i] = max(dpd[i], dpu[i]);
  for (int i = (1); i <= (n); i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
