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 MAXN = 5e5 + 10;
int n, m, dp[MAXN], level[MAXN];
int dist[MAXN], val[MAXN * 3];
int local[MAXN], answer[MAXN];
vector<pair<int, int>> adj[MAXN], nex[MAXN];
bool cut_edge[MAXN * 3];
bool mark[MAXN];
void dfs_cut_edge(int v, int par = 0) {
  dp[v] = level[v] = level[par] + 1;
  mark[v] = true;
  for (auto i : adj[v]) {
    if (!mark[i.first]) {
      dfs_cut_edge(i.first, v);
      dp[v] = min(dp[v], dp[i.first]);
      if (dp[i.first] > level[v]) cut_edge[i.second] = true;
    } else if (i.first != par)
      dp[v] = min(dp[v], level[i.first]);
  }
}
void bfs(int v) {
  queue<int> q;
  dist[v] = 1;
  q.push(v);
  while (q.size()) {
    int tp = q.front();
    q.pop();
    for (auto i : adj[tp]) {
      if (!dist[i.first]) {
        dist[i.first] = dist[tp] + 1;
        q.push(i.first);
      }
      if (dist[i.first] == (dist[tp] + 1)) nex[tp].push_back(i);
    }
  }
}
void dfs_(int v, int par = 0) {
  mark[v] = true;
  for (auto i : nex[v]) {
    if (!mark[i.first]) dfs_(i.first, v);
    dp[v] = max(dp[v], dp[i.first] + 1);
    if (cut_edge[i.second]) val[i.second] = dp[i.first] + 1;
  }
}
inline int get_dist(int l, int r, int len) {
  if (l > r) return len - l + r;
  return r - l;
}
inline int get_(pair<int, int> p, int id, int len) {
  return p.first + get_dist(p.second, id, len);
}
void dfs(int v, int par = 0) {
  mark[v] = true;
  vector<int> cycle;
  cycle.push_back(v);
  while (true) {
    bool re = false;
    for (auto i : adj[cycle.back()])
      if (!mark[i.first] && !cut_edge[i.second]) {
        cycle.push_back(i.first);
        mark[i.first] = true;
        re = true;
        break;
      }
    if (!re) break;
  }
  for (auto v : cycle)
    for (auto e : adj[v])
      if (cut_edge[e.second]) local[v] = max(local[v], val[e.second]);
  int len = cycle.size();
  deque<pair<int, int>> deq;
  auto stackf = [&](int happy) {
    for (int i = happy; i; i--) {
      int v = cycle[len - i];
      pair<int, int> me(local[v], len - i);
      while (deq.size() && get_(me, 0, len) >= get_(deq.back(), 0, len))
        deq.pop_back();
      deq.push_back(me);
    }
    for (int i = 0; i < len; i++) {
      while (deq.size() && get_dist(deq.front().second, i, len) > happy)
        deq.pop_front();
      if (deq.size())
        dp[cycle[i]] = max(dp[cycle[i]], get_(deq.front(), i, len));
      if (i == (len - 1)) break;
      int v = cycle[i];
      pair<int, int> me(local[v], i);
      while (deq.size() && get_(me, i + 1, len) >= get_(deq.back(), i + 1, len))
        deq.pop_back();
      deq.push_back(me);
    }
  };
  stackf(len / 2);
  deq.clear();
  reverse(cycle.begin(), cycle.end());
  stackf((len - 1) / 2);
  for (auto i : cycle) answer[i] = max(dp[i], local[i]);
  for (auto i : cycle) {
    int id = 0, mx = 0, smx = 0;
    for (auto e : adj[i])
      if (cut_edge[e.second])
        if (val[e.second] > mx) {
          mx = val[e.second];
          id = e.first;
        }
    for (auto e : adj[i])
      if (cut_edge[e.second] && e.first != id) smx = max(smx, val[e.second]);
    for (auto e : adj[i])
      if (cut_edge[e.second] && !mark[e.first]) {
        if (e.first == id) {
          val[e.second] = max(dp[i], smx) + 1;
          dfs(e.first, i);
        } else {
          val[e.second] = max(dp[i], mx) + 1;
          dfs(e.first, i);
        }
      }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
  }
  dfs_cut_edge(1);
  bfs(1);
  memset(mark, 0, sizeof(mark));
  memset(dp, 0, sizeof(dp));
  dfs_(1);
  memset(mark, 0, sizeof(mark));
  memset(dp, 0, sizeof(dp));
  dfs(1);
  for (int i = 1; i <= n; i++) cout << answer[i] << ' ';
  return 0;
}