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;
class Solution {
 public:
  vector<int> minimizeDistance(vector<pair<int, int>>& edges, int n) {
    graph.clear();
    graph.resize(n);
    parents.clear();
    parents.resize(n, -1);
    root = 0;
    gid.clear();
    gid.resize(n, -1);
    gidx.clear();
    gidx.resize(n, -1);
    for (auto& e : edges) {
      int u = e.first, v = e.second;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    ord.clear();
    ord.reserve(n);
    vector<int> path;
    dfs(root, -1, path);
    vector<int> res;
    calc(res);
    return res;
  }

 private:
  vector<vector<int>> graph;
  vector<int> parents;
  int root;
  vector<int> gid;
  vector<int> gidx;
  vector<vector<int>> groups;
  vector<int> ord;
  vector<multiset<int>> subdis;
  void dfs(int u, int p, vector<int>& path) {
    parents[u] = p;
    path.push_back(u);
    gid[u] = -2;
    for (auto v : graph[u]) {
      if (v == p || gid[v] >= 0) {
        continue;
      }
      if (gid[v] == -2) {
        int i = path.size();
        int w = -1;
        groups.resize(groups.size() + 1);
        do {
          w = path[--i];
          gid[w] = groups.size() - 1;
          groups.back().push_back(w);
        } while (w != v);
        auto& cycle = groups.back();
        reverse(cycle.begin(), cycle.end());
        for (int i = 0; i < cycle.size(); ++i) {
          gidx[cycle[i]] = i;
        }
        continue;
      }
      dfs(v, u, path);
    }
    if (gid[u] == -2) {
      gid[u] = groups.size();
      groups.emplace_back(vector<int>{u});
    } else {
    }
    path.pop_back();
    ord.push_back(u);
  }
  void calc(vector<int>& res) {
    int n = graph.size();
    vector<int> dis1(n, 0);
    subdis.clear();
    subdis.resize(n);
    res.clear();
    res.resize(n, -1);
    vector<int> cycleDis(n, 0);
    for (auto u : ord) {
      int p = parents[u];
      for (auto v : graph[u]) {
        if (v == p) {
          continue;
        }
        if (gid[u] == gid[v]) {
          continue;
        }
        dis1[u] = max(dis1[u], dis1[v] + 1);
        subdis[u].insert(dis1[v] + 1);
      }
      if ((p == -1 || gid[p] != gid[u]) && groups[gid[u]].size() > 1) {
        cycleDis[u] = minMaxDistance(u, dis1);
        subdis[u].insert(cycleDis[u]);
        dis1[u] = max(dis1[u], cycleDis[u]);
      }
    }
    for (int i = n - 1; i >= 0; --i) {
      int u = ord[i];
      int p = parents[u];
      if (res[u] != -1) {
        continue;
      }
      int newDis = 0;
      if (p == -1) {
        res[u] = dis1[u];
        newDis = res[u];
      }
      if (p != -1 && gid[p] != gid[u]) {
        auto it = subdis[p].rbegin();
        if (*it == 1 + dis1[u]) {
          ++it;
        }
        if (it != subdis[p].rend()) {
          newDis = *it + 1;
          subdis[u].insert(*it + 1);
        } else {
          newDis = 1;
          subdis[u].insert(1);
        }
        res[u] = max(res[u], *subdis[u].rbegin());
        newDis = res[u];
      }
      if ((p == -1 || gid[p] != gid[u]) && groups[gid[u]].size() > 1) {
        auto it = subdis[u].rbegin();
        if (*it == cycleDis[u]) {
          ++it;
        }
        if (it != subdis[u].rend()) {
          dis1[u] = *it;
        } else {
          dis1[u] = 0;
        }
        minMaxDistance2(u, dis1, res);
        auto& cycle = groups[gid[u]];
        for (auto v : cycle) {
          if (v == u) {
            res[u] = max(res[u], newDis);
            continue;
          }
          subdis[v].insert(res[v]);
          res[v] = max(dis1[v], res[v]);
        }
      }
    }
  }
  int minMaxDistance(int u, vector<int>& dis) {
    auto& cycle = groups[gid[u]];
    int p = gidx[u];
    int n = cycle.size();
    int res = 0;
    for (int i = 0; i < n; ++i) {
      if (i == p) {
        continue;
      }
      res = max(res, min(abs(i - p), abs(n - (i - p))) + dis[cycle[i]]);
    }
    return res;
  }
  void minMaxDistance2(int u, vector<int>& dis, vector<int>& res) {
    auto& cycle = groups[gid[u]];
    int n = cycle.size();
    vector<int> dis2(n, 0);
    multiset<int, greater<int>> left;
    multiset<int, greater<int>> right;
    left.insert(INT_MIN / 2);
    right.insert(INT_MIN / 2);
    dis2[0] = 0;
    int m = max(1, (n - 1) / 2);
    for (int i = 1; i <= m; ++i) {
      dis2[i] = dis[cycle[i]] + i;
      right.insert(dis2[i]);
    }
    for (int i = m + 1; i < n; ++i) {
      dis2[i] = dis[cycle[i]] + n - i;
      left.insert(dis2[i]);
    }
    res[cycle[0]] = max(*left.cbegin(), *right.cbegin());
    int r = m + 1;
    for (int i = 1; i < n; ++i) {
      dis2[i - 1] = dis[cycle[i - 1]] - (i - 1);
      left.insert(dis2[i - 1]);
      if (r < n) {
        left.erase(left.find(dis2[r]));
        if (r > i) {
          dis2[r] = dis[cycle[r]] + r;
          right.insert(dis2[r]);
        } else {
          dis2[r] = dis[cycle[r]] + n + r;
          right.insert(dis2[r]);
        }
        r = (r + 1) % n;
      }
      right.erase(right.find(dis2[i]));
      res[cycle[i]] = max(*left.cbegin() + i, *right.cbegin() - i);
    }
  }
  int minMaxDistance3(int u, vector<int>& dis) {
    auto& cycle = groups[gid[u]];
    int p = gidx[u];
    int cnt = 1;
    int n = cycle.size();
    int l = p;
    int r = p;
    int lcnt = 0;
    int rcnt = 0;
    int lsum = 0;
    int rsum = 0;
    while (cnt < n) {
      if (lsum < rsum) {
        l = (l - 1 + n) % n;
        ++lcnt;
        ++cnt;
        lsum = max(lsum, lcnt + dis[cycle[l]]);
      } else if (lsum > rsum) {
        r = (r + 1) % n;
        ++rcnt;
        ++cnt;
        rsum = max(rsum, rcnt + dis[cycle[r]]);
      } else {
        if (cnt + 1 == n) {
          if (lcnt > rcnt) {
            r = (r + 1) % n;
            ++rcnt;
            ++cnt;
            rsum = max(rsum, rcnt + dis[cycle[r]]);
          } else {
            l = (l - 1 + n) % n;
            ++lcnt;
            ++cnt;
            lsum = max(lsum, lcnt + dis[cycle[l]]);
          }
        } else {
          r = (r + 1) % n;
          ++rcnt;
          ++cnt;
          rsum = max(rsum, rcnt + dis[cycle[r]]);
          l = (l - 1 + n) % n;
          ++lcnt;
          ++cnt;
          lsum = max(lsum, lcnt + dis[cycle[l]]);
        }
      }
    }
    return max(lsum, rsum);
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> edges;
  edges.reserve(m);
  for (int i = 0, u = 0, v = 0; i < m; ++i) {
    cin >> u >> v;
    edges.emplace_back(u - 1, v - 1);
  }
  Solution sol;
  auto res = sol.minimizeDistance(edges, n);
  for (auto r : res) {
    cout << r << " ";
  }
  cout << endl;
  return 0;
}