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 inf = 2 * (1e9) + 10;
const long long MOD = 1000000009;
const int NMAX = 1000005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
vector<int> G[NMAX];
int cycln = 0;
vector<int> Gcycl[NMAX];
int dpin[NMAX];
int dpout[NMAX];
int dpout2[NMAX];
bool viz[NMAX];
int cviz[NMAX];
int cind[NMAX];
bool incv[NMAX];
struct MaxDeque {
  vector<pair<int, int>> q;
  int ql, qr, indl, indr;
  MaxDeque() {
    ql = indl = indr = 0;
    qr = -1;
  }
  void push(int val) {
    while (ql <= qr && q[qr].second < val) qr--;
    ++qr;
    pair<int, int> newp = {++indr, val};
    if (qr >= q.size())
      q.push_back(newp);
    else
      q[qr] = newp;
  }
  void pop() {
    indl++;
    while (ql <= qr && q[ql].first <= indl) ql++;
  }
  int tail() { return q[ql].second; }
};
stack<int> hst;
void dfs1(int v, int p) {
  hst.push(v);
  for (auto el : G[v]) {
    if (el == p) {
      continue;
    }
    if (viz[el] && !cind[el]) {
      cycln++;
      while (!hst.empty() && hst.top() != el) {
        Gcycl[cycln].push_back(hst.top());
        hst.pop();
      }
      reverse(Gcycl[cycln].begin(), Gcycl[cycln].end());
      for (auto el : Gcycl[cycln]) hst.push(el);
      Gcycl[cycln].push_back(el);
      incv[el] = 1;
      reverse(Gcycl[cycln].begin(), Gcycl[cycln].end());
      Gcycl[cycln].push_back(el);
      for (auto cc : Gcycl[cycln]) {
        cind[cc] = cycln;
      }
    }
    if (!viz[el]) {
      viz[el] = 1;
      dfs1(el, v);
    }
  }
  hst.pop();
}
void dfs2(int v, int p1, int p2, int p3) {
  if (cind[v] && !cviz[cind[v]]) {
    cviz[cind[v]] = 1;
    int ci = cind[v];
    multiset<int> hsh;
    int cn = Gcycl[ci].size() - 1;
    dfs2(Gcycl[ci][0], Gcycl[ci][1], Gcycl[ci][cn - 1], p1);
    for (int i = 1; i < cn; ++i) {
      int el = Gcycl[ci][i];
      dfs2(Gcycl[ci][i], Gcycl[ci][i - 1], Gcycl[ci][i + 1], 0);
      hsh.insert(i + dpin[el]);
    }
    int mn = *(hsh.rbegin());
    for (int i = cn - 1; i >= 1; --i) {
      int el = Gcycl[ci][i];
      hsh.erase(hsh.find(i + dpin[el]));
      hsh.insert(cn - i + dpin[el]);
      mn = min(mn, *(hsh.rbegin()));
    }
    dpin[v] = max(mn, dpin[v]);
  } else {
    for (auto el : G[v]) {
      if (el == p1 || el == p2 || el == p3) {
        continue;
      }
      dfs2(el, v, 0, 0);
      if (incv[v])
        dpout2[v] = max(dpout2[v], max(dpin[el], dpout2[el]) + 1);
      else
        dpin[v] = max(dpin[v], max(dpin[el], dpout2[el]) + 1);
    }
  }
}
int lst[NMAX];
void dfs3(int v, int p1, int p2, int p3) {
  if (cind[v] && !cviz[cind[v]]) {
    cviz[cind[v]] = 1;
    MaxDeque Qa, Qb;
    int ci = cind[v];
    int cn = Gcycl[ci].size() - 1;
    for (int i = 0; i < cn; ++i) {
      int el = Gcycl[ci][i];
      int val;
      if (el == v)
        val = max(dpout[el], dpout2[el]);
      else
        val = dpin[el];
      lst[i] = val;
      lst[i + cn] = val;
    }
    int hlf = cn / 2;
    int ra = 0, rb = 0, la = 0, lb = 0;
    for (int i = 1; i < cn; ++i) {
      int el = Gcycl[ci][i];
      while (ra <= i + hlf) Qa.push(ra + lst[ra]), ra++;
      while (la <= i) Qa.pop(), la++;
      while (rb <= i + cn - 1) Qb.push((cn - rb) + lst[rb]), rb++;
      while (lb <= i + hlf) Qb.pop(), lb++;
      int qat = Qa.tail();
      int qbt = Qb.tail();
      int qatc = Qa.tail() - i;
      int qbtc = Qb.tail() + i;
      dpout[Gcycl[ci][i]] = max(Qa.tail() - i, Qb.tail() + i);
    }
    for (int i = 1; i < cn; ++i) {
      dfs3(Gcycl[ci][i], Gcycl[ci][i - 1], Gcycl[ci][i + 1], 0);
    }
    dpout[Gcycl[ci][0]] = max(dpout[Gcycl[ci][0]], dpin[Gcycl[ci][0]]);
    dfs3(Gcycl[ci][0], Gcycl[ci][1], Gcycl[ci][cn - 1], p1);
  } else {
    multiset<int> hsh;
    for (auto el : G[v]) {
      if (el == p1 || el == p2 || el == p3) continue;
      hsh.insert(max(dpin[el], dpout2[el]));
    }
    for (auto el : G[v]) {
      if (el == p1 || el == p2 || el == p3) continue;
      hsh.erase(hsh.find(max(dpin[el], dpout2[el])));
      dpout[el] = dpout[v] + 1;
      if (!hsh.empty()) dpout[el] = max(dpout[el], *(hsh.rbegin()) + 2);
      dfs3(el, v, 0, 0);
      hsh.insert(max(dpin[el], dpout2[el]));
    }
  }
}
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  viz[1] = 1;
  dfs1(1, 0);
  memset(cviz, 0, sizeof(cviz));
  dfs2(1, 0, 0, 0);
  memset(cviz, 0, sizeof(cviz));
  dfs3(1, 0, 0, 0);
  for (int i = 1; i <= n; ++i) {
    cout << max(dpout[i], max(dpin[i], dpout2[i])) << " ";
  }
  cout << "\n";
  return 0;
}