#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
void maxi(int &x, int y) { x = max(x, y); }
vector<pair<int, int> > mp[1000005];
int dfn[1000005], sta[1000005], low[1000005], color, ii, cnt, belong[1000005];
bool ins[1000005];
void tarjan(int x, int p) {
  dfn[x] = low[x] = ++ii;
  sta[++cnt] = x;
  ins[x] = 1;
  for (auto cc : mp[x])
    if (cc.first != p) {
      int child = cc.first;
      if (!dfn[child]) {
        tarjan(child, x);
        low[x] = min(low[x], low[child]);
      } else if (ins[child]) {
        low[x] = min(low[x], dfn[child]);
      }
    }
  if (dfn[x] == low[x]) {
    ++color;
    int t;
    do {
      t = sta[cnt];
      cnt--;
      ins[t] = 0;
      belong[t] = color;
    } while (dfn[t] != low[t]);
  }
}
bool isB[1000005], vis[1000005];
vector<int> cyls[1000005];
int U[1000005], V[1000005], pa[1000005];
int L[1000005], Z[1000005], maxLen[1000005];
void findASpanningTreeAndInitializeL(int x) {
  queue<int> q;
  vector<int> nodesByDepth;
  q.push(x);
  memset(vis, 0, sizeof vis);
  vis[x] = 1;
  pa[x] = -1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    nodesByDepth.push_back(u);
    for (auto pp : mp[u]) {
      int v = pp.first;
      if (vis[v]) continue;
      vis[v] = 1;
      q.push(v);
      pa[v] = u;
    }
  }
  for (int i = n - 1; ~i; i--) {
    int u = nodesByDepth[i];
    for (auto pp : mp[u]) {
      int v = pp.first;
      if (pa[v] == u) {
        maxLen[u] = max(maxLen[u], maxLen[v] + 1);
        if (isB[pp.second]) {
          L[u] = max(L[u], maxLen[v] + 1);
        }
      }
    }
  }
}
void solveCycles(int u, int p, int upValue) {
  L[u] = max(L[u], upValue);
  int cid = belong[u];
  int k = cyls[cid].size();
  for (int(itr) = 0; (itr) < (int)(2); (itr)++) {
    priority_queue<pair<int, int> > q;
    for (int(i) = 0; (i) < (int)(k + k); (i)++) {
      int stmp = k + k - i;
      while (!q.empty() && q.top().second - stmp > k / 2) {
        q.pop();
      }
      if (!q.empty()) {
        if (cyls[cid][i % k] == 1) {
        }
        maxi(Z[cyls[cid][i % k]], q.top().first - stmp);
      }
      q.push({L[cyls[cid][i % k]] + stmp, stmp});
    }
    reverse(cyls[cid].begin(), cyls[cid].end());
  }
  for (int u : cyls[cid]) {
    int firstMax = 0, secondMax = 0;
    for (auto e : mp[u])
      if (e.first != p && isB[e.second]) {
        int v = e.first;
        if (secondMax < 1 + maxLen[v]) {
          secondMax = 1 + maxLen[v];
          if (firstMax < secondMax) swap(firstMax, secondMax);
        }
      }
    for (auto e : mp[u])
      if (e.first != p && isB[e.second]) {
        int v = e.first;
        int passValue = max(upValue, Z[u]);
        if (firstMax == 1 + maxLen[v])
          passValue = max(passValue, secondMax);
        else
          passValue = max(passValue, firstMax);
        solveCycles(v, u, passValue + 1);
      }
  }
}
void addC(int x) {
  cyls[belong[x]].push_back(x);
  ins[x] = 1;
  for (auto pp : mp[x]) {
    int v = pp.first;
    if (belong[v] != belong[x]) continue;
    if (ins[v]) continue;
    addC(v);
    return;
  }
}
void fmain(int ID) {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    scanf("%d%d", U + i, V + i);
    mp[U[i]].push_back({V[i], i});
    mp[V[i]].push_back({U[i], i});
  }
  tarjan(1, 0);
  memset(ins, 0, sizeof ins);
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (!vis[belong[i]]) {
      vis[belong[i]] = 1;
      addC(i);
    }
  for (int(i) = 1; (i) <= (int)(m); (i)++)
    if (belong[U[i]] != belong[V[i]]) {
      isB[i] = 1;
    }
  findASpanningTreeAndInitializeL(1);
  solveCycles(1, -1, 0);
  for (int(i) = 1; (i) <= (int)(n); (i)++) printf("%d ", max(L[i], Z[i]));
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
