Problem: 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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, m;
vector<pair<int, int> > *g;
vector<vector<int> > cir;
int cis[N], maxl[N], L[N], Z[N];
bool vis[N], ib[N << 1];
inline void init() {
  scanf("%d%d", &n, &m);
  g = new vector<pair<int, int> >[(n + 1)];
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(pair<int, int>(v, i));
    g[v].push_back(pair<int, int>(u, i));
  }
}
int ts = 0;
int dfn[N], low[N];
void tarjan(int p, int fa) {
  dfn[p] = low[p] = ++ts;
  for (int i = 0; i < g[p].size(); i++) {
    pair<int, int> e = g[p][i];
    if (e.first == fa) continue;
    if (!dfn[e.first]) {
      tarjan(e.first, p);
      low[p] = min(low[p], low[e.first]);
      if (low[e.first] == dfn[e.first]) ib[e.second] = true;
    } else
      low[p] = min(low[p], dfn[e.first]);
  }
}
void dfs(int p) {
  vis[p] = true;
  cir.back().push_back(p);
  cis[p] = (signed)cir.size() - 1;
  for (int i = 0; i < g[p].size(); i++) {
    pair<int, int> e = g[p][i];
    if (!vis[e.first] && !ib[e.second]) dfs(e.first);
  }
}
queue<int> que;
void bfs(int s) {
  int tp = 0;
  int *tr = new int[(n + 1)];
  int *par = new int[(n + 1)];
  que.push(s);
  memset(vis, false, sizeof(vis));
  tr[++tp] = s, par[s] = 0, vis[s] = true;
  while (!que.empty()) {
    int e = que.front();
    que.pop();
    for (int i = 0; i < g[e].size(); i++) {
      pair<int, int> eu = g[e][i];
      if (vis[eu.first]) continue;
      vis[eu.first] = true;
      tr[++tp] = eu.first, par[eu.first] = e;
      assert(eu.first != s);
      que.push(eu.first);
    }
  }
  for (int i = n; i > 1; i--) {
    int p = tr[i];
    for (int j = 0; j < g[p].size(); j++) {
      pair<int, int> e = g[p][j];
      if (e.first == par[p]) {
        maxl[e.first] = max(maxl[e.first], maxl[p] + 1);
        if (ib[e.second]) L[e.first] = max(L[e.first], maxl[p] + 1);
        break;
      }
    }
  }
  delete[] tr;
  delete[] par;
}
int ql, qr;
pair<int, int> ar[N << 1];
void deal(int p, int fa, int upval) {
  L[p] = max(L[p], upval);
  vector<int> &circ = cir[cis[p]];
  int k = (signed)circ.size(), lim = k >> 1;
  for (int it = 0; it < 2; it++) {
    ql = 1, qr = 0;
    for (int i = 0, e; i < 2 * k; i++) {
      e = circ[i % k];
      while (ql <= qr && i - ar[ql].second > lim) ql++;
      if (ql <= qr) Z[e] = max(Z[e], i + ar[ql].first);
      while (ql <= qr && ar[qr].first <= L[e] - i) qr--;
      ar[++qr] = pair<int, int>(L[e] - i, i);
    }
    reverse(circ.begin(), circ.end());
  }
  for (int i = 0; i < circ.size(); i++) {
    int u = circ[i];
    int fiv = 0, scv = 0;
    for (int j = 0; j < g[u].size(); j++) {
      pair<int, int> e = g[u][j];
      if (e.first != fa && ib[e.second]) {
        if (maxl[e.first] + 1 > fiv)
          scv = maxl[e.first] + 1, swap(scv, fiv);
        else if (maxl[e.first] + 1 > scv)
          scv = maxl[e.first] + 1;
      }
    }
    for (int j = 0; j < g[u].size(); j++) {
      pair<int, int> e = g[u][j];
      if (e.first != fa && ib[e.second]) {
        int pv = max(Z[u], upval), val = maxl[e.first] + 1;
        if (val == fiv)
          pv = max(pv, scv);
        else
          pv = max(pv, fiv);
        deal(e.first, u, pv + 1);
      }
    }
  }
}
inline void solve() {
  tarjan(1, 0);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      cir.push_back(vector<int>());
      dfs(i);
    }
  bfs(1);
  deal(1, 0, 0);
  for (int i = 1; i <= n; i++) printf("%d ", max(L[i], Z[i]));
}
int main() {
  init();
  solve();
  return 0;
}