#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);
        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;
      }
      res[u] = dis1[u];
      if (p != -1 && gid[p] != gid[u]) {
        auto it = subdis[p].rbegin();
        if (*it == 1 + dis1[u]) {
          ++it;
        }
        if (it != subdis[p].rend()) {
          subdis[u].insert(*it + 1);
        } else {
          subdis[u].insert(1);
        }
        res[u] = max(res[u], *subdis[u].rbegin());
      }
      if ((p == -1 || gid[p] != gid[u]) && groups[gid[u]].size() > 1) {
        auto it = subdis[u].rbegin();
        if (it != subdis[u].rend()) {
          dis1[u] = *it;
        } else {
          dis1[u] = 0;
        }
        minMaxDistance2(u, dis1, cycleDis);
        auto& cycle = groups[gid[u]];
        for (auto v : cycle) {
          subdis[v].insert(cycleDis[v]);
          res[v] = max(res[v], max(dis1[v], cycleDis[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;
}
