#include <bits/stdc++.h>
using namespace std;
class MaxQueue {
  queue<pair<int, int> > q;
  list<pair<int, int> > l;
  int cnt = 0;

 public:
  MaxQueue() : cnt(0) {}
  void push(int x) {
    pair<int, int> cur = pair<int, int>(x, cnt++);
    while (!l.empty() && l.back() <= cur) l.pop_back();
    q.push(cur);
    l.push_back(cur);
  }
  int front() { return q.front().first; }
  void pop() {
    if (q.front().second == l.front().second) l.pop_front();
    q.pop();
  }
  int max() { return l.front().first; }
  int size() { return q.size(); }
};
int n, m;
vector<int> g[500309], st;
int cycle[500309], num[500309], pos[500309], par[500309];
int cnt = 0;
vector<int> cycles[500309];
int down[500309], up[500309];
void buildcycles(int u, int p) {
  num[u] = 1;
  pos[u] = st.size();
  st.push_back(u);
  for (int v : g[u]) {
    if (v == p)
      continue;
    else if (num[v] == 1 && cycle[u] == -1) {
      cycles[cnt].clear();
      for (int i = pos[v]; i <= pos[u]; i++) {
        cycle[st[i]] = cnt;
        cycles[cnt].push_back(st[i]);
      }
      cnt++;
    } else if (num[v] == 0) {
      buildcycles(v, u);
      if (cycle[u] == -1 || cycle[v] != cycle[u]) par[v] = u;
    }
  }
  num[u] = 2;
  st.pop_back();
}
int find(vector<int>& v, int u) {
  for (int i = 0; (i) < (int(v.size())); (i)++) {
    if (v[i] == u) return i;
  }
  return -1;
}
int nodedown(int u);
int cycledown(int u) {
  if (down[u] != -1) return down[u];
  int c = cycle[u];
  if (c == -1) return nodedown(u);
  vector<int>& arr = cycles[c];
  int sz = arr.size();
  nodedown(u);
  int j = find(arr, u);
  assert(j != -1);
  for (int i = 0; (i) < (sz); (i)++) {
    int d = abs(i - j);
    if (i == j) continue;
    down[u] = max(down[u], min(d, sz - d) + nodedown(arr[i]));
  }
  return down[u];
}
int nodedown(int u) {
  if (down[u] != -1) return down[u];
  down[u] = 0;
  for (int v : g[u]) {
    if (v == par[u]) continue;
    if (cycle[u] != -1 && cycle[u] == cycle[v]) continue;
    down[u] = max(down[u], 1 + cycledown(v));
  }
  return down[u];
}
void solve(vector<int>& L, vector<int>& Z) {
  int sz = L.size();
  int k = sz / 2;
  for (int i = 0; (i) < (sz); (i)++) L.push_back(L[i]);
  vector<int> left = L, right = L;
  for (int i = 0; (i) < (2 * sz); (i)++) left[i] += i;
  for (int i = 0; (i) < (2 * sz); (i)++) right[i] += 2 * sz - i - 1;
  Z.assign(sz, 0);
  MaxQueue q;
  for (int i = 0; i < sz; i++) {
    q.push(right[i]);
  }
  while (q.size() > k) q.pop();
  for (int i = sz; i < 2 * sz; i++) {
    Z[i - sz] = max(Z[i - sz], q.max() - (2 * sz - i - 1));
    q.push(right[i]);
    q.pop();
  }
  q = MaxQueue();
  for (int i = 2 * sz - 1; i >= sz; i--) {
    q.push(left[i]);
  }
  while (q.size() > k) q.pop();
  for (int i = sz - 1; i >= 0; i--) {
    Z[i] = max(Z[i], q.max() - i);
    q.push(left[i]);
    q.pop();
  }
}
void nodeup(int u, int d);
void cycleup(int u, int d) {
  int c = cycle[u];
  if (c == -1) {
    nodeup(u, d);
    return;
  }
  cycledown(u);
  vector<int>& arr = cycles[c];
  int sz = arr.size();
  up[u] = d;
  int j = find(arr, u);
  assert(j != -1);
  vector<int> L(sz), Z;
  int daux = d;
  for (int v : g[u]) {
    if (v == par[u]) continue;
    if (cycle[u] != -1 && cycle[u] == cycle[v]) continue;
    daux = max(daux, 1 + nodedown(v));
  }
  for (int i = 0; (i) < (sz); (i)++) {
    if (i == j)
      L[i] = daux;
    else
      L[i] = nodedown(arr[i]);
  }
  solve(L, Z);
  for (int i = 0; (i) < (sz); (i)++) {
    if (i == j)
      nodeup(arr[i], max(Z[i], d));
    else
      nodeup(arr[i], Z[i]);
  }
}
void nodeup(int u, int d) {
  up[u] = d;
  nodedown(u);
  int sz = g[u].size();
  int x = d, y = -1;
  for (int v : g[u]) {
    if (v == par[u]) continue;
    if (cycle[u] != -1 && cycle[u] == cycle[v]) continue;
    if (x >= y && 1 + nodedown(v) > y)
      y = 1 + down[v];
    else if (x < y && 1 + nodedown(v) > x)
      x = 1 + down[v];
  }
  for (int v : g[u]) {
    if (v == par[u]) continue;
    if (cycle[u] != -1 && cycle[u] == cycle[v]) continue;
    if (1 + nodedown(v) == max(x, y))
      cycleup(v, min(x, y) + 1);
    else
      cycleup(v, max(x, y) + 1);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int j = 0; (j) < (m); (j)++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  memset(&cycle, -1, sizeof cycle);
  memset(&down, -1, sizeof down);
  memset(&up, -1, sizeof up);
  memset(&num, 0, sizeof num);
  buildcycles(1, -1);
  cycleup(1, 0);
  for (int u = 1; (u) <= (n); (u)++) {
    printf("%d ", max(up[u], down[u]));
  }
  printf("\n");
  return 0;
}
