#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[500005];
bool visitedcycles[500005];
bool visiteddfs[500005];
int low[500005];
int idv[500005];
int idcycle[500005];
int parent[500005];
bool bridges[1000005];
int maxlen[500005];
int L[500005];
int Z[500005];
int timedfs;
int numcycles;
vector<vector<int> > cycles;
int n, m;
void findbridges(int u, int p) {
  low[u] = timedfs;
  idv[u] = timedfs;
  timedfs++;
  for (vector<pair<int, int> >::iterator iter = g[u].begin();
       iter != g[u].end(); iter++) {
    int v = (*iter).first;
    if (idv[v] == 0) {
      findbridges(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] > idv[u]) {
        bridges[(*iter).second] = true;
      }
    } else if (v != p) {
      low[u] = min(low[u], idv[v]);
    }
  }
}
void findcycles(int u) {
  cycles.back().push_back(u);
  idcycle[u] = numcycles;
  visitedcycles[u] = true;
  vector<int> ordered;
  for (vector<pair<int, int> >::iterator iter = g[u].begin();
       iter != g[u].end(); iter++) {
    int v = (*iter).first;
    if (!visitedcycles[v] && !bridges[(*iter).second]) {
      findcycles(v);
    }
  }
}
void bfstree(int u) {
  queue<int> visitdfs;
  visitdfs.push(u);
  visiteddfs[u] = true;
  vector<int> ordered;
  while (!visitdfs.empty()) {
    int v = visitdfs.front();
    visitdfs.pop();
    ordered.push_back(v);
    for (vector<pair<int, int> >::iterator iter = g[v].begin();
         iter != g[v].end(); iter++) {
      if (!visiteddfs[(*iter).first]) {
        visitdfs.push((*iter).first);
        visiteddfs[(*iter).first] = true;
        parent[(*iter).first] = v;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int v = ordered[i];
    for (vector<pair<int, int> >::iterator iter = g[v].begin();
         iter != g[v].end(); iter++) {
      int w = (*iter).first;
      if (parent[w] == v) {
        maxlen[v] = max(maxlen[v], maxlen[w] + 1);
        if (bridges[(*iter).second]) {
          L[v] = max(L[v], maxlen[w] + 1);
        }
      }
    }
  }
}
void solveCycles(int u, int p, int upValue) {
  L[u] = max(L[u], upValue);
  int k = cycles[idcycle[u]].size();
  vector<int> currcycle = cycles[idcycle[u]];
  for (int j = 0; j < 2; j++) {
    priority_queue<pair<int, int> > updatez;
    for (int i = 0; i < 2 * k; i++) {
      while (!updatez.empty() && updatez.top().second > 2 * k - i + k / 2) {
        updatez.pop();
      }
      if (!updatez.empty()) {
        Z[currcycle[i % k]] =
            max(Z[currcycle[i % k]], updatez.top().first - 2 * k + i);
      }
      updatez.push({L[currcycle[i % k]] + 2 * k - i, 2 * k - i});
    }
    reverse(currcycle.begin(), currcycle.end());
  }
  reverse(currcycle.begin(), currcycle.end());
  for (int i = 0; i < k; i++) {
    int branchmax = 0, branchaltern = 0;
    for (vector<pair<int, int> >::iterator iter = g[currcycle[i]].begin();
         iter != g[currcycle[i]].end(); iter++) {
      if (bridges[(*iter).second] && maxlen[(*iter).first] + 1 > branchaltern &&
          (*iter).first != p) {
        branchaltern = maxlen[(*iter).first] + 1;
        if (branchaltern > branchmax) {
          swap(branchaltern, branchmax);
        }
      }
    }
    for (vector<pair<int, int> >::iterator iter = g[currcycle[i]].begin();
         iter != g[currcycle[i]].end(); iter++) {
      if (bridges[(*iter).second] && (*iter).first != p) {
        int newup = max(upValue, Z[currcycle[i]]);
        if (maxlen[(*iter).first] + 1 == branchmax) {
          newup = max(newup, branchaltern);
        } else {
          newup = max(newup, branchmax);
        }
        solveCycles((*iter).first, currcycle[i], newup + 1);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  int end1, end2;
  for (int i = 0; i < m; i++) {
    cin >> end1 >> end2;
    g[end1].push_back({end2, i});
    g[end2].push_back({end1, i});
  }
  findbridges(1, 0);
  for (int i = 1; i <= n; i++) {
    vector<int> newcycle;
    if (!visitedcycles[i]) {
      cycles.push_back(newcycle);
      findcycles(i);
      numcycles++;
    }
  }
  bfstree(1);
  solveCycles(1, -1, 0);
  for (int i = 1; i <= n; i++) {
    cout << max(L[i], Z[i]) << " ";
  }
  return 0;
}
