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 = 7e5 + 10;
const int INF = 0x3f3f3f3f;
int n, m, scc, timer;
int low[N], num[N], com[N], p[N], spec[N], ans[N];
int a[N], val[N], d[N];
bool fre[N];
vector<int> adj[N], V[N], node[N], C[N];
stack<int> ST;
struct RMQ {
  static const int LG = 20;
  int n;
  int lg[N];
  int spT[N][LG];
  void Init(int _n, int a[], int d) {
    n = _n;
    for (int i = 0; i < n; ++i) spT[i][0] = a[i] + d * i;
    for (int j = 1; 1 << j <= n; ++j)
      for (int i = 0; i + (1 << j) - 1 < n; ++i)
        spT[i][j] = max(spT[i][j - 1], spT[i + (1 << (j - 1))][j - 1]);
    for (int i = 0; 1 << i <= n; ++i) lg[1 << i] = i;
    for (int i = 1; i <= n; ++i)
      if (!lg[i]) lg[i] = lg[i - 1];
  }
  int Query(int l, int r) {
    if (l > r) return 0;
    int k = lg[r - l + 1];
    return max(spT[l][k], spT[r - (1 << k) + 1][k]);
  }
} RMQ[2];
struct Edge {
  int u, v;
  Edge() {}
  Edge(int u, int v) : u(u), v(v) {}
} E[N];
void Tarjan(int u, int par = -1) {
  ST.push(u);
  low[u] = num[u] = ++timer;
  for (int k = 0; k < adj[u].size(); ++k) {
    int v = adj[u][k];
    if (v == par || fre[v] == true) continue;
    if (num[v])
      low[u] = min(low[u], num[v]);
    else {
      Tarjan(v, u);
      low[u] = min(low[u], low[v]);
    }
  }
  if (low[u] == num[u]) {
    int v;
    ++scc;
    do {
      v = ST.top();
      ST.pop();
      fre[v] = true;
      com[v] = scc;
      V[scc].push_back(v);
    } while (v != u);
  }
}
int Left(int p, int m, int n) {
  int cut = (p + m - 1) % n;
  if (cut < p) {
    int s = max(RMQ[0].Query(p + 1, n - 1) - p, RMQ[0].Query(0, cut) - p + n);
    return max(s, 0);
  } else {
    int s = RMQ[0].Query(p + 1, cut) - p;
    return max(s, 0);
  }
}
int Right(int p, int m, int n) {
  int cut = (p + m - 1) % n;
  cut = (cut + 1) % n;
  if (cut <= p) {
    int s = RMQ[1].Query(cut, p - 1) + p;
    return max(s, 0);
  } else {
    int s = max(RMQ[1].Query(cut, n - 1) + p + n, RMQ[1].Query(0, p - 1) + p);
    return max(s, 0);
  }
}
void getAns(int scc) {
  for (int k = 0; k < V[scc].size(); ++k) {
    int u = V[scc][k];
    a[k] = val[u];
  }
  int sz = V[scc].size();
  RMQ[0].Init(sz, a, +1);
  RMQ[1].Init(sz, a, -1);
  for (int k = 0; k < V[scc].size(); ++k) {
    int u = V[scc][k];
    int l = 1, r = sz, f = INF;
    while (l <= r) {
      int m = (l + r) >> 1;
      int L = Left(k, m, sz), R = Right(k, m, sz);
      if (L > R) {
        r = m - 1;
        f = min(f, L);
      } else if (L < R) {
        l = m + 1;
        f = min(f, R);
      } else {
        f = min(f, L);
        break;
      }
    }
    ans[u] = (f == INF ? 0 : f);
  }
}
void BFS() {
  for (int i = 1; i <= n; ++i) fre[i] = false;
  queue<int> Q;
  Q.push(V[1][0]);
  fre[V[1][0]] = true;
  vector<int> ver;
  while (Q.size()) {
    int u = Q.front();
    Q.pop();
    ver.push_back(u);
    for (int k = 0; k < adj[u].size(); ++k) {
      int v = adj[u][k];
      if (fre[v] == false) {
        fre[v] = true;
        Q.push(v);
        p[v] = u;
      }
    }
  }
  int maxDist = 0;
  for (int i = (int)ver.size() - 1; i >= 0; --i) {
    int u = ver[i];
    for (int k = 0; k < adj[u].size(); ++k) {
      int v = adj[u][k];
      if (p[v] == u) {
        d[u] = max(d[u], d[v] + 1);
        if (com[u] != com[v]) val[u] = max(val[u], d[v] + 1);
      }
    }
  }
  for (int i = 1; i <= n; ++i) fre[i] = false;
}
void moveRoot(int u, int upValue) {
  int scc = com[u];
  val[u] = max(val[u], upValue);
  if (V[scc].size() == 1) {
    int x = V[scc][0];
    ans[x] = upValue;
  } else {
    getAns(scc);
  }
  ans[u] = max(ans[u], upValue);
  for (int k = 0; k < V[scc].size(); ++k) {
    int u = V[scc][k];
    int firstMax = 0, secondMax = 0;
    for (int i = 0; i < node[u].size(); ++i) {
      int v = node[u][i];
      if (p[v] == u) {
        if (d[v] + 1 > secondMax) {
          secondMax = d[v] + 1;
          if (firstMax < secondMax) swap(firstMax, secondMax);
        }
      }
    }
    for (int i = 0; i < node[u].size(); ++i) {
      int v = node[u][i];
      if (p[v] == u) {
        int passValue;
        if (d[v] + 1 == firstMax) {
          passValue = max(ans[u], secondMax);
        } else {
          passValue = max(ans[u], firstMax);
        }
        moveRoot(v, passValue + 1);
      }
    }
  }
}
void Read(int &n) {
  n = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c));
  do {
    n = n * 10 + c - '0';
    c = getchar();
  } while (isdigit(c));
}
void Write(int n) {
  if (n == 0) {
    putchar('0');
    return;
  }
  char c[30];
  int k = 0;
  while (n) {
    c[++k] = n % 10 + '0';
    n /= 10;
  }
  for (int i = k; i >= 1; --i) putchar(c[i]);
}
int main() {
  Read(n);
  Read(m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    Read(u);
    Read(v);
    E[i] = Edge(u, v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  Tarjan(1);
  for (int i = 1; i <= m; ++i) {
    int u = E[i].u, v = E[i].v;
    if (com[u] == com[v])
      continue;
    else {
      node[u].push_back(v);
      node[v].push_back(u);
    }
  }
  BFS();
  moveRoot(V[1][0], 0);
  for (int i = 1; i <= n; ++i) {
    Write(max(val[i], ans[i]));
    putchar(' ');
  }
  return 0;
}