68 74
7 8
24 23
55 56
3 50
61 62
12 1
32 33
36 35
9 8
44 50
53 5
29 28
16 2
36 37
3 22
44 45
27 28
66 65
34 4
31 32
64 65
13 12
10 9
67 66
5 47
55 54
6 51
20 21
67 4
17 29
41 40
48 49
19 20
18 17
35 4
25 24
33 34
38 37
5 48
43 30
63 62
60 61
66 6
26 27
64 63
14 13
67 68
68 54
42 41
52 53
39 38
50 49
59 58
46 45
39 40
57 58
1 11
52 51
15 2
57 56
2 67
23 3
26 25
6 53
30 31
10 11
7 14
1 30
22 21
42 43
47 46
16 15
59 60
18 19
 8 9
1 6
3 6
4 7
8 1
1 5
8 4
2 7
3 5
8 2
 7 7
7 6
7 2
6 1
5 4
5 1
1 4
3 7
 17 20
13 11
2 3
16 3
12 14
17 1
2 6
5 4
7 9
3 10
8 16
10 8
14 2
6 15
1 7
15 1
15 12
4 13
8 5
9 17
11 5
 6 6
4 3
4 2
5 4
6 5
4 6
1 6
 4 4
1 2
2 3
1 3
1 4
 10 11
9 3
8 7
1 2
1 8
10 8
7 10
4 1
6 4
3 6
5 9
2 5
 1 0
 9 9
9 8
7 6
8 7
5 6
3 2
1 5
1 3
1 4
4 2
 2 1
1 2
 16 20
1 16
15 14
5 11
12 1
16 2
5 14
2 4
6 1
11 7
11 1
8 12
9 6
7 5
10 15
1 8
14 10
4 13
3 9
13 16
6 3
 7 8
7 4
3 1
2 1
6 5
6 7
2 3
1 4
4 5
 9 9
1 9
6 7
8 7
1 8
5 7
3 2
4 9
8 3
6 1
 11 12
6 5
7 1
1 2
2 11
10 11
9 6
8 7
4 8
11 9
2 3
5 10
3 4
 5 4
1 2
3 4
1 4
5 1
 8 8
6 7
5 1
8 2
3 1
6 4
3 6
7 4
8 5
 10 10
2 5
7 8
1 7
1 9
5 3
6 9
5 9
6 4
1 10
8 9
 4 3
3 4
2 4
4 1
 13 15
9 1
12 3
6 11
8 2
2 5
13 10
3 4
8 4
11 9
9 2
10 8
1 6
7 12
5 13
4 7
 11 12
11 1
9 3
6 1
6 7
2 10
4 6
9 11
10 9
10 11
1 8
6 5
8 7
 8 8
1 6
7 3
1 8
7 8
5 4
4 1
6 5
6 2
 3 3
2 1
1 3
3 2
 17 21
8 2
9 6
6 7
3 14
12 16
4 11
11 15
14 13
13 4
5 8
6 1
2 5
16 7
7 12
3 17
14 8
17 10
7 14
1 9
15 14
10 3
 3 2
1 2
2 3
 3 3
3 2
1 3
1 2
 10 9
9 8
4 10
8 7
1 3
8 3
7 6
7 5
10 9
2 7
 11 12
10 1
8 7
4 11
5 2
7 9
6 10
11 6
2 8
1 4
9 3
9 4
3 5
 18 22
5 3
15 18
8 10
17 6
9 2
7 16
7 10
3 8
11 9
2 14
4 18
10 5
14 11
11 13
1 4
13 7
15 6
16 17
6 12
18 1
12 15
17 13
 5 5
5 1
2 3
4 2
5 2
1 4
 8 8
3 1
4 5
6 1
7 8
2 5
3 2
1 4
6 8

22
16
19
16
15
13
26
26
25
24
23
23
24
25
17
17
25
24
23
22
21
20
20
21
22
23
24
25
26
21
20
19
18
17
17
18
19
20
21
22
23
23
22
19
18
17
16
16
17
18
14
15
14
17
18
19
20
21
21
20
19
18
17
16
15
14
15
16
 3
4
5
4
4
4
5
3
 3
4
4
4
4
2
3
 9
6
6
10
9
7
10
8
11
7
10
8
11
7
8
7
10
 3
3
3
2
2
2
 1
2
2
2
 3
3
5
3
4
4
5
4
5
5
 0
 5
7
6
6
4
4
5
6
7
 1
1
 4
6
6
7
5
5
5
5
6
7
4
5
6
6
7
5
 3
4
4
2
3
4
3
 3
5
4
5
5
4
4
3
4
 4
3
4
5
6
6
5
6
5
5
4
 2
3
3
2
3
 3
6
4
6
4
5
6
5
 3
4
4
4
3
3
4
3
2
4
 2
2
2
1
 6
4
6
5
5
7
6
4
5
5
6
7
5
 3
5
5
5
5
4
5
4
4
4
3
 3
5
5
4
5
4
4
3
 1
1
1
 5
5
4
5
5
4
3
4
5
5
5
4
4
3
4
4
5
 2
1
2
 1
1
1
 5
5
4
5
5
5
4
3
3
4
 5
6
4
4
5
6
4
5
3
6
5
 9
8
9
9
8
6
6
8
7
7
6
7
5
7
7
5
5
8
 3
2
3
2
2
 3
5
4
4
5
3
5
4

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long mod7 = 1000000007LL;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
inline long long add(long long _x, long long _y, long long _mod = mod7) {
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline long long sub(long long _x, long long _y, long long _mod = mod7) {
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline long long mul(long long _x, long long _y, long long _mod = mod7) {
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1LL;
  long long _ret = mypow(mul(_a, _a, _mod), _x >> 1, _mod);
  if (_x & 1) _ret = mul(_ret, _a, _mod);
  return _ret;
}
long long mymul(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 0LL;
  long long _ret = mymul(add(_a, _a, _mod), _x >> 1, _mod);
  if (_x & 1) _ret = add(_ret, _a, _mod);
  return _ret;
}
void sleep(double sec = 1021) {
  clock_t s = clock();
  while (clock() - s < CLOCKS_PER_SEC * sec)
    ;
}
int __ = 1, _cs;
const int N = 505050;
struct seg_t {
  int n;
  vector<int> st;
  void init(int sz) {
    int lg = 1;
    while (lg < sz) lg <<= 1;
    st.resize(lg + lg);
    for (size_t i = 0; i < st.size(); i++) st[i] = 0;
    n = sz - 1;
  }
  void modify(int no, int l, int r, int p, int v) {
    st[no] = max(st[no], v);
    if (l == r) return;
    if (p <= ((l + r) >> 1))
      modify((no << 1), l, ((l + r) >> 1), p, v);
    else
      modify((1 + (no << 1)), ((l + r) >> 1) + 1, r, p, v);
  }
  void modify(int p, int v) { modify(1, 0, n, p, v); }
  int query(int no, int l, int r, int ql, int qr) {
    if (r < ql or l > qr) return 0;
    if (ql <= l and r <= qr) return st[no];
    return max(query((no << 1), l, ((l + r) >> 1), ql, qr),
               query((1 + (no << 1)), ((l + r) >> 1) + 1, r, ql, qr));
  }
  int query(int ql, int qr) {
    if (ql > qr) return 0;
    int ret = query(1, 0, n, ql, qr);
    return ret;
  }
};
void build() {}
int n, m;
vector<int> v[N];
vector<vector<int>> cyc;
int at[N], stk[N];
bool gt[N], vst[N], instk[N];
void go(int now, int prt, int dep) {
  stk[dep] = now;
  vst[now] = true;
  instk[now] = true;
  for (int son : v[now]) {
    if (son == prt) continue;
    if (vst[son]) {
      if (not instk[son]) continue;
      vector<int> tcyc;
      for (int i = dep;; i--) {
        gt[stk[i]] = true;
        at[stk[i]] = cyc.size();
        tcyc.push_back(stk[i]);
        if (stk[i] == son) break;
      }
      cyc.push_back(tcyc);
      continue;
    }
    go(son, now, dep + 1);
  }
  instk[now] = false;
}
vector<pair<int, pair<int, int>>> g[N];
void init() {
  n = getint();
  m = getint();
  while (m--) {
    int ui = getint();
    int vi = getint();
    v[ui].push_back(vi);
    v[vi].push_back(ui);
  }
  go(1, 1, 0);
  for (int i = 1; i <= n; i++)
    if (not gt[i]) {
      vector<int> tmp = {i};
      at[i] = cyc.size();
      cyc.push_back(tmp);
    }
  for (int i = 1; i <= n; i++)
    for (int j : v[i]) {
      if (at[i] == at[j]) continue;
      g[at[i]].push_back({at[j], {i, j}});
    }
}
int dp[N], where[N];
void go_dp(int now, int prt, int onow, int oprt) {
  if (cyc[now].size() == 1u) {
    for (auto _son : g[now]) {
      int son = _son.first;
      if (son == prt) continue;
      go_dp(son, now, _son.second.second, _son.second.first);
      dp[now] = max(dp[now], dp[son] + 1);
    }
    return;
  }
  size_t ptr = 0;
  if (now != prt)
    while (cyc[now][ptr] != onow) ptr++;
  else
    onow = cyc[now][0];
  vector<int> cur_cyc;
  for (size_t i = 0; i < cyc[now].size(); i++)
    cur_cyc.push_back(cyc[now][(ptr + i) % cyc[now].size()]);
  for (size_t i = 0; i < cyc[now].size(); i++) where[cur_cyc[i]] = i;
  vector<int> mx_dp;
  mx_dp.resize(cur_cyc.size());
  for (auto _son : g[now]) {
    int son = _son.first;
    if (son == prt) continue;
    go_dp(son, now, _son.second.second, _son.second.first);
    mx_dp[where[_son.second.first]] =
        max(mx_dp[where[_son.second.first]], dp[son] + 1);
  }
  dp[now] = N;
  vector<int> ldp, rdp;
  ldp.resize(mx_dp.size());
  rdp.resize(mx_dp.size());
  for (size_t i = 0; i < mx_dp.size(); i++) {
    ldp[i] = mx_dp[i] + i;
    rdp[i] = mx_dp[i] + mx_dp.size() - i;
  }
  for (size_t i = 1; i < mx_dp.size(); i++) ldp[i] = max(ldp[i], ldp[i - 1]);
  for (int i = (int)mx_dp.size() - 2; i >= 0; i--)
    rdp[i] = max(rdp[i], rdp[i + 1]);
  for (size_t i = 0; i < mx_dp.size(); i++) {
    int tdp = ldp[i];
    if (i + 1 < mx_dp.size()) tdp = max(tdp, rdp[i + 1]);
    dp[now] = min(dp[now], tdp);
  }
}
int ans[N];
seg_t _ldp[N], _rdp[N];
void go_dp2(int now, int prt, int onow, int oprt, int pdp) {
  if (cyc[now].size() == 1u) {
    onow = cyc[now][0];
    vector<int> ldp, rdp;
    ldp.resize(g[now].size());
    rdp.resize(g[now].size());
    for (size_t i = 0; i < g[now].size(); i++) {
      int son = g[now][i].first;
      if (son == prt)
        ldp[i] = rdp[i] = 0;
      else {
        ldp[i] = dp[son] + 1;
        rdp[i] = dp[son] + 1;
      }
    }
    for (size_t i = 1; i < g[now].size(); i++) ldp[i] = max(ldp[i], ldp[i - 1]);
    for (int i = (int)g[now].size() - 2; i >= 0; i--)
      rdp[i] = max(rdp[i], rdp[i + 1]);
    ans[onow] = max(dp[now], pdp);
    for (size_t i = 0; i < g[now].size(); i++) {
      auto _son = g[now][i];
      int son = _son.first;
      if (son == prt) continue;
      int tdp = pdp;
      if (i) tdp = max(tdp, ldp[i - 1]);
      if (i + 1 < g[now].size()) tdp = max(tdp, rdp[i + 1]);
      go_dp2(son, now, _son.second.second, _son.second.first, tdp + 1);
    }
    return;
  }
  size_t ptr = 0;
  if (now != prt)
    while (cyc[now][ptr] != onow) ptr++;
  else
    onow = cyc[now][0];
  vector<int> cur_cyc;
  for (size_t i = 0; i < cyc[now].size(); i++)
    cur_cyc.push_back(cyc[now][(ptr + i) % cyc[now].size()]);
  for (size_t i = 0; i < cyc[now].size(); i++) where[cur_cyc[i]] = i;
  vector<int> mx_dp;
  vector<multiset<int>> mx_dp_st;
  mx_dp.resize(cur_cyc.size());
  mx_dp_st.resize(cur_cyc.size());
  for (size_t i = 0; i < mx_dp.size(); i++) mx_dp[i] = 0;
  for (auto _son : g[now]) {
    int son = _son.first;
    if (son == prt) continue;
    mx_dp[where[_son.second.first]] =
        max(mx_dp[where[_son.second.first]], dp[son] + 1);
    mx_dp_st[where[_son.second.first]].insert(dp[son] + 1);
  }
  ans[onow] = max(pdp, dp[now]);
  seg_t& ldp = _ldp[now];
  seg_t& rdp = _rdp[now];
  ldp.init(mx_dp.size() + mx_dp.size());
  rdp.init(mx_dp.size() + mx_dp.size());
  for (size_t i = 0; i < mx_dp.size(); i++) {
    ldp.modify(i, mx_dp[i] + i);
    ldp.modify(i + mx_dp.size(), mx_dp[i] + mx_dp.size() + i);
    rdp.modify(i, mx_dp[i] + mx_dp.size() + mx_dp.size() - i);
    rdp.modify(i + mx_dp.size(), mx_dp[i] + mx_dp.size() - i);
  }
  size_t bst = 0;
  int val = N;
  for (size_t i = 1; i < mx_dp.size(); i++) {
    int tval = ldp.query(1, i);
    if (i + 1 < mx_dp.size())
      tval = max(tval,
                 rdp.query(i + 1, (int)mx_dp.size() - 1) - (int)mx_dp.size());
    if (tval < val) {
      val = tval;
      bst = i;
    }
  }
  vector<int> dn;
  dn.resize(mx_dp.size());
  for (size_t i = 1; i < mx_dp.size(); i++) {
    if (bst < i) bst++;
    size_t til = i + mx_dp.size();
    int cans = ldp.query(i + 1, bst) - i;
    if (bst + 1 < til)
      cans =
          max(cans, rdp.query(bst + 1, til - 1) + (int)i - (int)mx_dp.size());
    while (bst + 1 < til) {
      int ccans = ldp.query(i + 1, bst + 1) - i;
      if (bst + 2 < til)
        ccans = max(ccans,
                    rdp.query(bst + 2, til - 1) + (int)i - (int)mx_dp.size());
      if (ccans < cans) {
        cans = ccans;
        bst++;
      } else
        break;
    }
    int who = cur_cyc[i];
    int bns = min((int)i, (int)mx_dp.size() - (int)i);
    ans[who] = max(max(cans, pdp + bns), mx_dp[i]);
    dn[where[who]] = max(cans, pdp + bns);
  }
  for (auto _son : g[now]) {
    int son = _son.first;
    if (son == prt) continue;
    int tmp = dn[where[_son.second.first]];
    mx_dp_st[where[_son.second.first]].erase(
        mx_dp_st[where[_son.second.first]].find(dp[son] + 1));
    if (mx_dp_st[where[_son.second.first]].size())
      tmp = max(tmp, *mx_dp_st[where[_son.second.first]].rbegin());
    mx_dp_st[where[_son.second.first]].insert(dp[son] + 1);
    go_dp2(son, now, _son.second.second, _son.second.first, tmp + 1);
  }
}
void solve() {
  go_dp(0, 0, -1, -1);
  go_dp2(0, 0, -1, -1, 0);
  for (int i = 1; i <= n; i++) printf("%d%c", ans[i], " \n"[i == n]);
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
