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;
vector<int> g[500010];
vector<int> bfstree[500010];
vector<int> st, ed;
int p[500010];
char used[500010];
char oncycle[500010];
vector<vector<int>> cycles;
int cyclenum[500010];
int l[500010], z[500010];
int an[500010];
multiset<int> ms[500010];
int fi[500010];
vector<pair<int, int>> er;
vector<int> drop[500010];
void dfs1(int v, int par) {
  used[v] = 1;
  for (int to : g[v]) {
    if (!used[to]) {
      p[to] = v;
      dfs1(to, v);
    } else if (to != par && used[to] == 1) {
      ed.push_back(v);
      st.push_back(to);
    }
  }
  used[v] = 2;
}
void dfs2(int v, int par, int di) {
  if (cyclenum[v] >= 0 && fi[cyclenum[v]] == 0) {
    fi[cyclenum[v]] = v;
  }
  for (int to : bfstree[v]) {
    if (to != par) {
      dfs2(to, v, di + 1);
      ms[v].insert(l[to] + 1);
      if (cyclenum[to] != -1 && cyclenum[v] == cyclenum[to])
        er.push_back({v, to});
    }
  }
  if (!ms[v].empty()) l[v] = *ms[v].rbegin();
  an[v] = l[v];
}
void calc_z(vector<int> &a) {
  set<pair<int, int>> q;
  int k = a.size();
  for (int t = 0; t < 2; t++) {
    for (int i = 0; i < 2 * k; i++) {
      while (!q.empty()) {
        auto v = *q.rbegin();
        if (i - v.second > k / 2)
          q.erase(*q.rbegin());
        else
          break;
      }
      if (!q.empty()) {
        auto v = *q.rbegin();
        int value = v.first + v.second;
        value += i - v.second;
        z[a[i % k]] = max(z[a[i % k]], value);
      }
      q.insert({l[a[i % k]] - i, i});
    }
    q.clear();
    reverse(a.begin(), a.end());
  }
  for (auto u : a) an[u] = max(an[u], max(l[u], z[u]));
}
void dfs_go(int v) {
  used[v] = true;
  for (int to : g[v]) {
    if (!used[to]) {
      if (oncycle[to]) {
        if (oncycle[v] && cyclenum[v] == cyclenum[to])
          dfs_go(to);
        else {
          int old = l[to];
          bool ok = false;
          if (ms[v].find(old + 1) != ms[v].end())
            ms[v].erase(ms[v].find(old + 1)), ok = true;
          int val = z[v];
          if (!ms[v].empty()) val = max(val, *ms[v].rbegin());
          ms[to].insert(val + 1);
          for (auto dr : drop[to]) {
            if (ms[to].find(dr) != ms[to].end()) ms[to].erase(ms[to].find(dr));
          }
          l[to] = *ms[to].rbegin();
          calc_z(cycles[cyclenum[to]]);
          for (auto dr : drop[to]) {
            ms[to].insert(dr);
          }
          l[to] = old;
          dfs_go(to);
          ms[to].erase(ms[to].find(val + 1));
          if (ok) ms[v].insert(old + 1);
        }
      } else {
        bool ok = false;
        if (ms[v].find(l[to] + 1) != ms[v].end())
          ms[v].erase(ms[v].find(l[to] + 1)), ok = true;
        if (!ms[v].empty())
          z[to] = max(*ms[v].rbegin(), z[v]) + 1;
        else
          z[to] = z[v] + 1;
        an[to] = max(an[to], z[to]);
        if (ok) ms[v].insert(l[to] + 1);
        dfs_go(to);
      }
    }
  }
}
void stupid() {
  for (int i = 1; i <= n; i++) {
    int an = 0;
    int d[n + 1];
    memset(d, -1, sizeof(d));
    d[i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      an = max(an, d[v]);
      for (int to : g[v]) {
        if (d[to] == -1) {
          d[to] = d[v] + 1;
          q.push(to);
        }
      }
    }
    cout << an << ' ';
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    g[from].push_back(to);
    g[to].push_back(from);
  }
  dfs1(1, 1);
  for (int i = 0; i < (int)ed.size(); i++) {
    int u = ed[i];
    cycles.push_back(vector<int>());
    for (int v = u; v != st[i]; v = p[v]) cycles.back().push_back(v);
    cycles.back().push_back(st[i]);
  }
  if (cycles.empty()) {
    cycles.push_back(vector<int>(1, 1));
  }
  memset(cyclenum, -1, sizeof(cyclenum));
  for (int i = 0; i < (int)cycles.size(); i++) {
    for (auto u : cycles[i]) {
      oncycle[u] = true;
      cyclenum[u] = i;
    }
  }
  memset(used, 0, sizeof(used));
  queue<int> q;
  for (auto u : cycles[0]) {
    q.push(u);
    used[u] = true;
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int to : g[v]) {
      if (!used[to]) {
        q.push(to);
        bfstree[v].push_back(to);
        bfstree[to].push_back(v);
        used[to] = true;
      }
    }
  }
  memset(used, 0, sizeof(used));
  for (auto u : cycles[0]) {
    dfs2(u, u, 0);
  }
  reverse(er.begin(), er.end());
  for (auto p : er) {
    int v = p.first;
    int to = p.second;
    if (fi[cyclenum[v]] == v) {
      drop[v].push_back(l[to] + 1);
      continue;
    }
    ms[v].erase(ms[v].find(l[to] + 1));
    if (!ms[v].empty())
      l[v] = *ms[v].rbegin();
    else
      l[v] = 0;
    an[v] = l[v];
  }
  calc_z(cycles[0]);
  memset(used, 0, sizeof(used));
  dfs_go(cycles[0][0]);
  for (int i = 1; i <= n; i++) {
    cout << an[i] << ' ';
  }
  cout << endl;
}