#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
using namespace std;
inline void MAX(int &a, int b) {
  if (a < b) a = b;
}
int n, m;
struct edge {
  int nxt, to;
  edge() {}
  edge(int jzp, int zzz) { nxt = jzp, to = zzz; }
} e[1001000 << 1];
int head[1001000], ecnt = 1;
inline void addedge(int from, int to) {
  e[++ecnt] = edge(head[from], to);
  head[from] = ecnt;
}
int dep[1001000], fa[1001000];
bool evis[1001000 << 1];
void dfs_tree(int cur, int faa) {
  fa[cur] = faa;
  dep[cur] = dep[faa] + 1;
  for (int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == faa) continue;
    if (dep[to]) {
      evis[i >> 1] = true;
      continue;
    }
    dfs_tree(to, cur);
  }
}
int col[1001000], ctot;
vector<int> vec[1001000];
int mxd[1001000];
int mx[1001000], smx[1001000];
inline void calc_cir(int cur) {
  static int h[1001000];
  static pair<int, int> que[1001000];
  int front = 0, rear = 0, htot = 0;
  for (unsigned int i = 0; i < vec[cur].size(); ++i) h[++htot] = vec[cur][i];
  for (int i = 1; i <= htot; ++i) {
    int p = h[i];
    mx[p] = smx[p] = mxd[p] = 0;
    for (int j = head[p]; j; j = e[j].nxt) {
      int to = e[j].to;
      if (col[to] == cur) continue;
      int v = max(mxd[to], mx[to]) + 1;
      if (v >= mx[p])
        smx[p] = mx[p], mx[p] = v;
      else if (v > smx[p])
        smx[p] = v;
    }
  }
  for (int i = htot - (htot >> 1) + 1; i <= htot; ++i) {
    pair<int, int> v = make_pair(mx[h[i]] + (htot - i), -(htot - i));
    while (front < rear && v > que[rear]) --rear;
    que[++rear] = v;
  }
  for (int i = 1; i <= htot; ++i) {
    int p = h[i];
    if (front < rear && i - que[front + 1].second > (htot >> 1)) ++front;
    if (front < rear) MAX(mxd[p], que[front + 1].first + i);
    pair<int, int> v = make_pair(mx[p] - i, i);
    while (front < rear && v > que[rear]) --rear;
    que[++rear] = v;
  }
  front = rear = 0;
  reverse(h + 1, h + 1 + htot);
  for (int i = htot - (htot >> 1) + 1; i <= htot; ++i) {
    pair<int, int> v = make_pair(mx[h[i]] + (htot - i), -(htot - i));
    while (front < rear && v > que[rear]) --rear;
    que[++rear] = v;
  }
  for (int i = 1; i <= htot; ++i) {
    int p = h[i];
    if (front < rear && i - que[front + 1].second > (htot >> 1)) ++front;
    if (front < rear) MAX(mxd[p], que[front + 1].first + i);
    pair<int, int> v = make_pair(mx[p] - i, i);
    while (front < rear && v > que[rear]) --rear;
    que[++rear] = v;
  }
}
void dfs_init(int cur, int faa) {
  for (unsigned int i = 0; i < vec[cur].size(); ++i) {
    int p = vec[cur][i];
    mx[p] = mxd[p] = -1;
    for (int j = head[p]; j; j = e[j].nxt) {
      int to = e[j].to;
      if (to == faa || col[to] == cur) continue;
      dfs_init(col[to], p);
    }
  }
  calc_cir(cur);
}
int ans[1001000];
void dfs_cg(int cur, int faa) {
  calc_cir(cur);
  for (unsigned int i = 0; i < vec[cur].size(); ++i) {
    int p = vec[cur][i];
    ans[p] = max(mx[p], mxd[p]);
  }
  for (unsigned int i = 0; i < vec[cur].size(); ++i) {
    int p = vec[cur][i];
    for (int j = head[p]; j; j = e[j].nxt) {
      int to = e[j].to;
      if (to == faa || col[to] == cur) continue;
      int bkup = mx[p];
      mx[p] = (max(mx[to], mxd[to]) + 1) == mx[p] ? smx[p] : mx[p];
      dfs_cg(col[to], p);
      mx[p] = bkup;
    }
  }
}
int main() {
  read(n), read(m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    read(u), read(v);
    addedge(u, v), addedge(v, u);
  }
  dfs_tree(1, 0);
  for (int i = 1; i <= m; ++i)
    if (evis[i]) {
      int x = e[i << 1].to, y = e[i << 1 | 1].to;
      ++ctot;
      static int stk[1001000];
      int stop = 0;
      while (x != y) {
        if (dep[x] > dep[y])
          vec[ctot].push_back(x), col[x] = ctot, x = fa[x];
        else
          stk[++stop] = y, col[y] = ctot, y = fa[y];
      }
      col[x] = ctot;
      stk[++stop] = x;
      while (stop) vec[ctot].push_back(stk[stop--]);
    }
  for (int i = 1; i <= n; ++i)
    if (!col[i]) col[i] = ++ctot, vec[ctot].push_back(i);
  dfs_init(1, 0);
  dfs_cg(1, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  puts("");
  return 0;
}
