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 = (int)5e5 + 10;
const int M = (int)2e6 + 10;
int n, m;
int cnt, lst[N], nxt[M], to[M];
void add(int u, int v) {
  nxt[++cnt] = lst[u];
  lst[u] = cnt;
  to[cnt] = v;
  nxt[++cnt] = lst[v];
  lst[v] = cnt;
  to[cnt] = u;
}
bool vis[N];
int bl[N], fa[N];
vector<int> cir[N];
int f[N], f0[N], f1[N], g[N];
int mx[N][2];
void dfs(int u, int pre) {
  vis[u] = 1;
  fa[u] = pre;
  for (int j = lst[u]; j; j = nxt[j]) {
    int v = to[j];
    if (v == pre) continue;
    if (vis[v]) {
      if (bl[u]) continue;
      ++m;
      for (int p = u; p != v; p = fa[p]) {
        cir[m].push_back(p);
        bl[p] = m;
      }
      cir[m].push_back(v);
      bl[v] = m;
      continue;
    }
    dfs(v, u);
  }
  if (!bl[u]) {
    bl[u] = ++m;
    cir[m].push_back(u);
  }
}
void dpf(int u) {
  vis[u] = 1;
  for (int j = lst[u]; j; j = nxt[j]) {
    int v = to[j];
    if (vis[v]) continue;
    dpf(v);
    if (bl[v] != bl[u]) {
      f0[u] = max(f0[u], f[v] + 1);
      if (!mx[u][0] || f[mx[u][0]] <= f[v])
        mx[u][1] = mx[u][0], mx[u][0] = v;
      else if (!mx[u][1] || f[mx[u][1]] <= f[v])
        mx[u][1] = v;
    }
  }
  int p = bl[u], m = cir[p].size();
  if (u == cir[p][m - 1]) {
    for (int i = 0; i < m; i++) {
      int v = cir[p][i];
      f1[u] = max(f1[u], f[v] + min(i + 1, m - 1 - i));
    }
  }
  f[u] = max(f0[u], f1[u]);
}
int q[N][2], head, tail;
void dpg(int u) {
  vis[u] = 1;
  int pre = fa[u];
  if (pre && bl[pre] != bl[u]) {
    g[u] = max(g[u], g[pre] + 1);
    g[u] = max(g[u], f1[pre] + 1);
    if (u == mx[pre][0]) {
      if (mx[pre][1]) g[u] = max(g[u], f[mx[pre][1]] + 2);
    } else
      g[u] = max(g[u], f0[pre] + 1);
  }
  f0[u] = max(f0[u], g[u]);
  int p = bl[u], m = cir[p].size();
  if (u == cir[p][m - 1]) {
    head = tail = 1;
    q[head][0] = f0[cir[p][0]], q[head][1] = 0;
    for (int i = 1; i <= m / 2; i++) {
      while (head <= tail && q[tail][0] <= f0[cir[p][i]] + i) tail--;
      ++tail;
      q[tail][0] = f0[cir[p][i]] + i, q[tail][1] = i;
    }
    for (int i = 0; i < m - 1; i++) {
      if (q[head][1] == i) head++;
      g[cir[p][i]] = max(g[cir[p][i]], q[head][0] - i);
      int next = m / 2 + i + 1;
      while (head <= tail && q[tail][0] <= f0[cir[p][next % m]] + next) tail--;
      ++tail;
      q[tail][0] = f0[cir[p][next % m]] + next, q[tail][1] = next;
    }
    head = tail = 1;
    q[head][0] = f0[cir[p][m / 2]], q[head][1] = m / 2;
    for (int i = m / 2 + 1; i < m; i++) {
      while (head <= tail && q[tail][0] <= f0[cir[p][i]] + m - i) tail--;
      ++tail;
      q[tail][0] = f0[cir[p][i]] + m - i, q[tail][1] = i;
    }
    for (int i = 0; i < m - 1; i++) {
      if (q[head][1] == m / 2 + i) head++;
      g[cir[p][i]] = max(g[cir[p][i]], q[head][0] + i);
      int next = m + i;
      while (head <= tail && q[tail][0] <= f0[cir[p][next % m]] + m - next)
        tail--;
      ++tail;
      q[tail][0] = f0[cir[p][next % m]] + m - next, q[tail][1] = next;
    }
  }
  for (int j = lst[u]; j; j = nxt[j]) {
    int v = to[j];
    if (vis[v]) continue;
    dpg(v);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d %d", &u, &v);
    add(u, v);
  }
  m = 0;
  dfs(1, 0);
  memset(vis, 0, sizeof(vis));
  dpf(1);
  memset(vis, 0, sizeof(vis));
  dpg(1);
  for (int i = 1; i <= n; i++) printf("%d ", max(f[i], g[i]));
  return 0;
}