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 limit = 1000000;
void minimize(int &a, int b) { a = min(a, b); }
void maximize(int &a, int b) { a = max(a, b); }
int n, m;
vector<int> g[limit];
int depth[limit];
int predepth[limit];
vector<int> cycle[limit];
vector<int> G[limit];
int seen[limit];
int incycle[limit];
int maxdistdown[limit];
int maxdistdownroot[limit];
int maxdist[limit];
vector<int> distsdown[limit];
void gencycle(int uini, int u, int p, vector<int> &c) {
  c.push_back(u);
  incycle[u] = 1;
  vector<int> &ar = g[u];
  for (int i = 0; i < int(ar.size()); i++) {
    int v = ar[i];
    if (p != v and incycle[v] and v != uini) G[u].push_back(v);
  }
  for (int i = 0; i < int(ar.size()); i++) {
    int v = ar[i];
    if (p != v and not incycle[v]) gencycle(uini, v, u, c);
  }
}
void generate(int u, int p, int d) {
  depth[u] = d;
  predepth[u] = d;
  seen[u] = 1;
  vector<int> &ar = g[u];
  for (int i = 0; i < int(ar.size()); i++) {
    int v = ar[i];
    if (v != p) {
      if (not seen[v]) {
        generate(v, u, d + 1);
        minimize(predepth[u], predepth[v]);
      } else if (depth[v] < depth[u]) {
        predepth[u] = depth[v];
      }
    }
  }
  if (predepth[u] == depth[u]) gencycle(u, u, p, cycle[u]);
}
void computemaxdistdownroot(int u);
void computemaxdistdown(int u) {
  vector<int> &ar = G[u];
  for (int i = 0; i < int(ar.size()); i++) {
    int v = ar[i];
    computemaxdistdownroot(v);
    distsdown[u].push_back(1 + maxdistdownroot[v]);
    maximize(maxdistdown[u], 1 + maxdistdownroot[v]);
  }
}
void computemaxdistdownroot(int u) {
  vector<int> &c = cycle[u];
  int n = int(c.size());
  for (int i = 0; i < n; i++) {
    int v = c[i];
    computemaxdistdown(v);
    maximize(maxdistdownroot[u], maxdistdown[v] + min(i, n - i));
  }
}
void write(string s, priority_queue<pair<int, int> > q) {
  cout << s << ": ";
  while (not q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    cout << "(" << p.first << "," << p.second << ")";
  }
  cout << endl;
}
void computemaxdist(int u, int d) {
  distsdown[u].push_back(d);
  maximize(maxdistdown[u], d);
  vector<int> &c = cycle[u];
  priority_queue<pair<int, int> > ql, qr;
  int n = int(c.size());
  if (n > 1) {
    for (int i = 0; i < n; i++) {
      int v = c[i];
      ql.push(pair<int, int>(maxdistdown[v] + n - i, i));
    }
    int ir = n / 2;
    for (int i = 0; i <= ir; i++) {
      int v = c[i];
      qr.push(pair<int, int>(maxdistdown[v] + i, i));
    }
    for (int i = 0; i < n; i++) {
      int v = c[i];
      for (;;) {
        pair<int, int> p = ql.top();
        int dis = p.first;
        int ind = p.second;
        if (ind == i or
            (ind < i and maxdistdown[c[ind]] + i - ind != dis + i) or
            (i < ind and maxdistdown[c[ind]] + n - (ind - i) != dis + i) or
            (i + n - ind) % n > (ind + n - i) % n)
          ql.pop();
        else
          break;
      }
      for (;;) {
        pair<int, int> p = qr.top();
        int dis = p.first;
        int ind = p.second;
        if (ind == i or
            (ind < i and maxdistdown[c[ind]] + n - (i - ind) != dis - i) or
            (i < ind and maxdistdown[c[ind]] + ind - i != dis - i) or
            (i + n - ind) % n < (ind + n - i) % n)
          qr.pop();
        else
          break;
      }
      int dleft = ql.top().first + i;
      int dright = qr.top().first - i;
      int daside = max(dleft, dright);
      distsdown[v].push_back(daside);
      ql.push(pair<int, int>(maxdistdown[v] - i, i));
      ir = (ir + 1) % n;
      if (i < ir)
        qr.push(pair<int, int>(maxdistdown[c[ir]] + ir, ir));
      else
        qr.push(pair<int, int>(maxdistdown[c[ir]] + n + ir, ir));
    }
  }
  for (int i = 0; i < n; i++) {
    int v = c[i];
    vector<int> &dd = distsdown[v];
    sort(dd.begin(), dd.end());
    maxdist[v] = dd.back();
    vector<int> &ar = G[v];
    for (int j = 0; j < int(ar.size()); j++) {
      int w = ar[j];
      int dw = dd.back();
      if (maxdistdownroot[w] + 1 == dw) dw = dd[int(dd.size()) - 2];
      computemaxdist(w, dw + 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  generate(1, 0, 0);
  computemaxdistdownroot(1);
  computemaxdist(1, 0);
  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << " ";
    cout << maxdist[i];
  }
  cout << endl;
}