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;
int n, m, num[500005], low[500005], rig = 0, numCircle = 0;
int belong[500005], pos[500005], z[500005];
pair<int, int> l1[500005], l2[500005];
vector<pair<int, int> > g[500005];
vector<int> circle[500005];
stack<int> st;
queue<int> qu;
priority_queue<pair<int, int> > pr;
void setup() {
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back(make_pair(v, i));
    g[v].push_back(make_pair(u, i));
  }
}
void dfs(int u, int pE) {
  num[u] = low[u] = ++rig;
  st.push(u);
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i].first;
    int id = g[u][i].second;
    if (id == pE) continue;
    if (num[v])
      low[u] = min(low[u], num[v]);
    else {
      dfs(v, id);
      low[u] = min(low[u], low[v]);
    }
  }
  if (low[u] == num[u]) {
    numCircle++;
    while (true) {
      int v = st.top();
      st.pop();
      belong[v] = numCircle;
      pos[v] = circle[numCircle].size();
      circle[numCircle].push_back(v);
      if (v == u) break;
    }
  }
}
int circleDistance(int u, int v) {
  if (pos[u] > pos[v]) return circleDistance(v, u);
  return min(pos[v] - pos[u], pos[u] + int(circle[belong[u]].size()) - pos[v]);
}
void updateL(int u, int value, int v) {
  if (value > l1[u].first) {
    if (v != l1[u].second) l2[u] = l1[u];
    l1[u] = make_pair(value, v);
  } else if (value > l2[u].first && v != l1[u].second)
    l2[u] = make_pair(value, v);
}
void buildLAndZ(int s, int p) {
  for (int i = 0; i <= int(circle[belong[s]].size()) - 1; i++) {
    int u = circle[belong[s]][i];
    for (int j = 0; j <= int(g[u].size()) - 1; j++) {
      int v = g[u][j].first;
      if (belong[v] == belong[s] || (u == s && v == p)) continue;
      buildLAndZ(v, u);
      updateL(u, max(l1[v].first, z[v]) + 1, v);
    }
    if (u != s) z[s] = max(z[s], l1[u].first + circleDistance(s, u));
  }
}
void buildLAndZFirstCircle(int u) {
  for (int i = 0; i <= int(g[u].size()) - 1; i++) {
    int v = g[u][i].first;
    if (belong[v] == belong[u]) continue;
    buildLAndZ(v, u);
    updateL(u, max(l1[v].first, z[v]) + 1, v);
  }
}
void calcAns(int s, int p) {
  if (p) {
    if (s != l1[p].second)
      updateL(s, max(z[p], l1[p].first) + 1, p);
    else
      updateL(s, max(z[p], l2[p].first) + 1, p);
  }
  int idCircle = belong[s], size = circle[idCircle].size();
  int id = pos[s], dis = 0;
  pr.push(make_pair(l1[s].first, 0));
  while (true) {
    if (++dis == size * 2) break;
    id = (id + 1 == size ? 0 : id + 1);
    int u = circle[idCircle][id];
    if (u != s) {
      while (!pr.empty() && dis - pr.top().second > size / 2) pr.pop();
      z[u] = max(z[u], pr.top().first + dis);
    }
    pr.push(make_pair(l1[u].first - dis, dis));
  }
  while (!pr.empty()) pr.pop();
  id = pos[s], dis = 0;
  pr.push(make_pair(l1[s].first, 0));
  while (true) {
    if (++dis == size * 2) break;
    id = (id - 1 == -1 ? size - 1 : id - 1);
    int u = circle[idCircle][id];
    if (u != s) {
      while (!pr.empty() && dis - pr.top().second > size / 2) pr.pop();
      z[u] = max(z[u], pr.top().first + dis);
    }
    pr.push(make_pair(l1[u].first - dis, dis));
  }
  while (!pr.empty()) pr.pop();
  for (int i = 0; i <= size - 1; i++) {
    int u = circle[idCircle][i];
    for (int j = 0; j <= int(g[u].size()) - 1; j++) {
      int v = g[u][j].first;
      if (belong[v] == belong[s] || (u == s && v == p)) continue;
      calcAns(v, u);
    }
  }
}
void calcAnsFirstCircle() {
  int s = circle[1][0];
  for (int i = 1; i <= int(circle[1].size()) - 1; i++) {
    int u = circle[1][i];
    z[s] = max(z[s], l1[u].first + circleDistance(s, u));
  }
  calcAns(s, 0);
}
void xuly() {
  dfs(1, 0);
  for (int i = 0; i <= int(circle[1].size()) - 1; i++) {
    int u = circle[1][i];
    buildLAndZFirstCircle(u);
  }
  calcAnsFirstCircle();
  for (int u = 1; u <= n; u++) cout << max(l1[u].first, z[u]) << ' ';
}
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}