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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 500000;
int n, m;
vector<int> adj[MAXN];
int par[MAXN];
int state[MAXN];
int comp[MAXN];
vector<int> cyc[MAXN];
void dfsinit(int at) {
  state[at] = 1;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par[at]) continue;
    if (state[to] == 0) {
      par[to] = at;
      dfsinit(to);
    } else if (state[to] == 1) {
      for (int x = at; x != to; x = par[x]) cyc[to].push_back(x);
      cyc[to].push_back(to);
      reverse(cyc[to].begin(), cyc[to].end());
      for (int j = (0); j < (((int)(cyc[to]).size())); ++j)
        assert(comp[cyc[to][j]] == -1);
      for (int j = (0); j < (((int)(cyc[to]).size())); ++j)
        comp[cyc[to][j]] = to;
    } else {
      assert(state[to] == 2 && comp[to] == comp[at]);
    }
  }
  state[at] = 2;
}
int dpdown[MAXN], downvia[MAXN], dpdown2[MAXN];
int dpup[MAXN];
int tmp[2 * MAXN];
void upddown(int at, int val, int via) {
  if (val > dpdown[at])
    dpdown2[at] = dpdown[at], dpdown[at] = val, downvia[at] = via;
  else if (val > dpdown2[at])
    dpdown2[at] = val;
}
void dfsdown(int at) {
  dpdown[at] = 0, downvia[at] = -1, dpdown2[at] = 0;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par[at] || (comp[at] != -1 && comp[at] == comp[to])) continue;
    dfsdown(to);
    upddown(at, dpdown[to] + 1, to);
  }
  if (comp[at] != -1 && at == comp[at]) {
    assert(comp[at] == at && ((int)(cyc[at]).size()) > 0 && cyc[at][0] == at);
    for (int i = (1); i < (((int)(cyc[at]).size())); ++i) {
      int to = cyc[at][i];
      dfsdown(to);
    }
    for (int i = (1); i < (((int)(cyc[at]).size())); ++i) {
      int to = cyc[at][i];
      tmp[i] = dpdown[to];
    }
    int cycdown = 0;
    for (int i = (1); i < (((int)(cyc[at]).size())); ++i)
      cycdown = max(cycdown, tmp[i] + min(i, ((int)(cyc[at]).size()) - i));
    upddown(at, cycdown, -2);
  }
}
struct MxQ {
  int lidx, ridx;
  char id;
  pair<int, int> q[2 * MAXN];
  int qtail, qhead;
  void clear() { lidx = ridx = qtail = qhead = 0; }
  void push(int val) {
    while (qtail < qhead && q[qhead - 1].second < val) --qhead;
    q[qhead++] = make_pair(ridx, val);
    ++ridx;
  }
  void pop() {
    ++lidx;
    while (qtail < qhead && q[qtail].first < lidx) ++qtail;
  }
  int get(int off) { return qtail < qhead ? q[qtail].second + off : INT_MIN; }
};
MxQ qa, qb;
void dfsup(int at) {
  dpup[at] = 0;
  if (par[at] != -1) {
    dpup[at] = max(dpup[at], 1 + dpup[par[at]]);
    dpup[at] = max(dpup[at], 1 + (downvia[par[at]] != at ? dpdown[par[at]]
                                                         : dpdown2[par[at]]));
  }
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par[at] || (comp[at] != -1 && comp[at] == comp[to])) continue;
    dfsup(to);
  }
  if (comp[at] != -1) {
    assert(comp[at] == at && ((int)(cyc[at]).size()) > 0 && cyc[at][0] == at);
    for (int i = (0); i < (((int)(cyc[at]).size())); ++i) {
      tmp[i] = 0;
      int u = cyc[at][i];
      for (int j = (0); j < (((int)(adj[u]).size())); ++j) {
        int to = adj[u][j];
        if (to == par[at])
          tmp[i] = max(tmp[i], dpup[at]);
        else if (comp[to] != at)
          tmp[i] = max(tmp[i], 1 + dpdown[to]);
      }
    }
    for (int i = (0); i < (((int)(cyc[at]).size())); ++i)
      tmp[i + ((int)(cyc[at]).size())] = tmp[i];
    qa.id = 'A';
    qb.id = 'B';
    qa.clear();
    qb.clear();
    int lsa = 0, hsa = 0, lsb = 0, hsb = 0;
    for (int i = (1); i < (((int)(cyc[at]).size())); ++i) {
      int u = cyc[at][i];
      while (i + ((int)(cyc[at]).size()) / 2 >= hsa)
        qa.push(tmp[hsa] + hsa), ++hsa;
      while (lsa <= i) qa.pop(), ++lsa;
      while (i + ((int)(cyc[at]).size()) - 1 >= hsb)
        qb.push(tmp[hsb] + ((int)(cyc[at]).size()) - hsb), ++hsb;
      while (lsb <= i + ((int)(cyc[at]).size()) / 2) qb.pop(), ++lsb;
      dpup[u] = max(qa.get(-i), qb.get(+i));
    }
    for (int i = (1); i < (((int)(cyc[at]).size())); ++i) {
      int u = cyc[at][i];
      for (int j = (0); j < (((int)(adj[u]).size())); ++j) {
        int to = adj[u][j];
        if (to != par[at] && comp[to] != at) dfsup(to);
      }
    }
  }
}
int ans[MAXN];
void run() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (m); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = (0); i < (n); ++i) par[i] = -1, comp[i] = -1, state[i] = 0;
  dfsinit(0);
  dfsdown(0);
  dfsup(0);
  for (int at = (0); at < (n); ++at) {
    ans[at] = 0;
    ans[at] = max(ans[at], dpup[at]);
    if (comp[at] != -1 && at == comp[at]) ans[at] = max(ans[at], dpdown[at]);
    for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
      int to = adj[at][i];
      if (to != par[at] && (comp[at] == -1 || comp[to] != comp[at]))
        ans[at] = max(ans[at], 1 + dpdown[to]);
    }
  }
  for (int i = (0); i < (n); ++i) {
    if (i != 0) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
}
int main() {
  run();
  return 0;
}