You are given a special connected undirected graph where each vertex belongs to at most one simple cycle.

Your task is to remove as many edges as needed to convert this graph into a tree (connected graph with no cycles). 

For each node, independently, output the maximum distance between it and a leaf in the resulting tree, assuming you were to remove the edges in a way that minimizes this distance.

Input

The first line of input contains two integers n and m (1 ≤ n ≤ 5⋅ 10^5), the number of nodes and the number of edges, respectively.

Each of the following m lines contains two integers u and v (1 ≤ u,v ≤ n, u ≠ v), and represents an edge connecting the two nodes u and v. Each pair of nodes is connected by at most one edge.

It is guaranteed that the given graph is connected and each vertex belongs to at most one simple cycle.

Output

Print n space-separated integers, the i-th integer represents the maximum distance between node i and a leaf if the removed edges were chosen in a way that minimizes this distance.

Examples

Input

9 10
7 2
9 2
1 6
3 1
4 3
4 7
7 6
9 8
5 8
5 9


Output

5 3 5 4 5 4 3 5 4


Input

4 4
1 2
2 3
3 4
4 1


Output

2 2 2 2

Note

In the first sample, a possible way to minimize the maximum distance from vertex 1 is by removing the marked edges in the following image:

<image>

Note that to minimize the answer for different nodes, you can remove different edges.
#include <bits/stdc++.h>
using namespace std;
void err() { cout << endl; }
template <class T, class... Ts>
void err(T arg, Ts &...args) {
  cout << arg << ' ';
  err(args...);
}
void read() {}
template <class T, class... Ts>
void read(T &arg, Ts &...args) {
  T f = 1;
  char ch;
  arg = 0;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar()) {
    if (ch == '-') f = -1;
  }
  for (; ch >= '0' && ch <= '9'; ch = getchar()) arg = arg * 10 + ch - '0';
  arg *= f;
  read(args...);
}
template <class T>
void myHash(T a[], int n, T w[] = nullptr) {
  set<T> st;
  for (int i = 0; i < n; i++) {
    st.insert(a[i]);
  }
  int tot = 0;
  map<T, int> mp;
  for (T x : st) {
    mp[x] = ++tot;
  }
  for (int i = 0; i < n; i++) {
    a[i] = mp[a[i]];
  }
  if (w != nullptr) {
    for (pair<T, int> p : mp) {
      w[p.second] = p.first;
    }
  }
}
const int maxn = 5e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
vector<pair<int, int> > G[maxn];
int dfn[maxn], low[maxn], idx;
stack<int> stk;
bool inST[maxn];
int grp[maxn];
vector<int> scc[maxn];
bool isRT[maxn];
void tarjan(int u, int eid) {
  dfn[u] = low[u] = ++idx;
  stk.push(u);
  inST[u] = true;
  for (pair<int, int> e : G[u]) {
    if (e.second == eid) continue;
    int v = e.first;
    if (!dfn[v]) {
      tarjan(v, e.second);
      low[u] = min(low[u], low[v]);
    } else if (inST[v]) {
      low[u] = min(low[u], low[v]);
    }
  }
  if (dfn[u] == low[u]) {
    while (stk.top() != u) {
      int v = stk.top();
      stk.pop();
      inST[v] = false;
      grp[v] = u;
      scc[u].push_back(v);
    }
    stk.pop();
    inST[u] = false;
    grp[u] = u;
    isRT[u] = true;
  }
}
int f[2][maxn];
int fto[maxn], sc[maxn];
int pre[maxn], suf[maxn];
void dp(int u, int fa) {
  assert(grp[u] == u);
  assert(isRT[u]);
  for (pair<int, int> e : G[u]) {
    int v = e.first;
    if (v == fa || grp[v] == u) continue;
    dp(v, u);
    int nxt = max(f[0][v], f[1][v]) + 1;
    if (nxt > f[0][u]) {
      sc[u] = f[0][u];
      fto[u] = v;
      f[0][u] = nxt;
    } else if (nxt > sc[u]) {
      sc[u] = nxt;
    }
  }
  for (int v : scc[u]) {
    assert(v != u);
    for (pair<int, int> e : G[v]) {
      int to = e.first;
      if (grp[to] == u) continue;
      dp(to, v);
      int nxt = max(f[0][to], f[1][to]) + 1;
      if (nxt > f[0][v]) {
        sc[v] = f[0][v];
        fto[v] = to;
        f[0][v] = nxt;
      } else if (nxt > sc[v]) {
        sc[v] = nxt;
      }
    }
  }
  int len = scc[u].size();
  for (int i = 1; i <= len; i++) {
    int v = scc[u][i - 1];
    pre[i] = max(pre[i - 1], f[0][v] + i);
  }
  suf[len + 1] = 0;
  for (int i = len; i >= 1; i--) {
    int v = scc[u][i - 1];
    suf[i] = max(suf[i + 1], f[0][v] + len + 1 - i);
  }
  f[1][u] = inf;
  for (int i = 0; i <= len; i++) {
    f[1][u] = min(f[1][u], max(pre[i], suf[i + 1]));
  }
}
int g[maxn];
int a[maxn * 2], b[maxn * 2];
struct SegTree {
  int info[maxn << 3];
  int n;
  void init(int _n, int w[]) {
    n = _n;
    build(1, 1, n, w);
  }
  void pushup(int x) { info[x] = max(info[x * 2], info[x * 2 + 1]); }
  void build(int x, int l, int r, int w[]) {
    if (l == r) {
      info[x] = w[l];
    } else {
      int mid = l + r >> 1;
      build(x * 2, l, mid, w);
      build(x * 2 + 1, mid + 1, r, w);
      pushup(x);
    }
  }
  int query(int x, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return info[x];
    int mid = l + r >> 1;
    int ans = 0;
    if (ql <= mid) ans = max(ans, query(x * 2, l, mid, ql, qr));
    if (qr > mid) ans = max(ans, query(x * 2 + 1, mid + 1, r, ql, qr));
    return ans;
  }
  int ask(int l, int r) {
    if (l > r) return 0;
    return query(1, 1, n, l, r);
  }
} sgl, sgr;
void dpG(int rt) {
  int n = 1 + scc[rt].size();
  a[1] = max(g[rt], f[0][rt]);
  for (int i = 2; i <= n; i++) {
    int u = scc[rt][i - 2];
    a[i] = f[0][u];
  }
  for (int i = n + 1; i <= n * 2; i++) {
    a[i] = a[i - n];
  }
  for (int i = 1; i <= n * 2; i++) {
    b[i] = a[i] + n * 2 - i;
    a[i] += i;
  }
  sgl.init(n * 2, a);
  sgr.init(n * 2, b);
  int split = 3;
  for (int i = 2, j = n + 2; i <= n; i++, j++) {
    if (split == i) split++;
    while (split < j) {
      int cur[2] = {sgl.ask(i + 1, split - 1) - i,
                    sgr.ask(split, j - 1) - (n * 2 - j)};
      int nxt[2] = {sgl.ask(i + 1, split) - i,
                    sgr.ask(split + 1, j - 1) - (n * 2 - j)};
      if (cur[0] >= cur[1]) break;
      if (max(nxt[0], nxt[1]) > max(cur[0], cur[1])) break;
      split++;
    }
    int u = scc[rt][i - 2];
    g[u] =
        max(sgl.ask(i + 1, split - 1) - i, sgr.ask(split, j - 1) - (n * 2 - j));
  }
}
void dfs(int u, int fa) {
  g[u] = max(g[fa], max(fto[fa] == u ? sc[fa] : f[0][fa], f[1][fa])) + 1;
  if (u == 1) g[u] = 0;
  dpG(u);
  for (pair<int, int> e : G[u]) {
    int v = e.first;
    if (v == fa || grp[v] == u) continue;
    dfs(v, u);
  }
  for (int v : scc[u]) {
    for (pair<int, int> e : G[v]) {
      int to = e.first;
      if (grp[to] == u) continue;
      dfs(to, v);
    }
  }
}
void run() {
  int n, m;
  read(n, m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    read(u, v);
    G[u].emplace_back(v, i);
    G[v].emplace_back(u, i);
  }
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) tarjan(i, 0);
  }
  dp(1, 0);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d%c", max(g[i], max(f[0][i], f[1][i])), i == n ? '\n' : ' ');
  }
}
int main() {
  int T = 1;
  while (T--) {
    run();
  }
  return 0;
}
