#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  vector<long long> calc(vector<pair<int, int>>& pv, int n) {
    vector<long long> res(n, 0);
    vector<vector<int>> dest(n);
    for (auto& p : pv) {
      int u = p.first, v = p.second;
      dest[u].push_back(v);
    }
    vector<int> ends(n * 2, 0);
    for (int i = 0; i < n; ++i) {
      if (dest[i].empty()) {
        continue;
      }
      int d = INT_MAX;
      for (auto j : dest[i]) {
        d = min(d, (j - i + n) % n);
      }
      int m = dest[i].size();
      ends[i] = i + (m - 1) * n + d;
      ends[i + n] = ends[i] + n;
    }
    multiset<int, greater<int>> mt;
    for (int j = 0; j < n; ++j) {
      mt.insert(ends[j]);
    }
    res[0] = (mt.empty() ? 0 : *mt.begin() - 0);
    for (int i = 1, j = 1; i < n; ++i, ++j) {
      mt.erase(mt.find(ends[j - 1]));
      mt.insert(ends[j + n - 1]);
      res[i] = (mt.empty() ? 0 : *mt.begin() - i);
    }
    return res;
  }
};
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution sol;
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pv;
  pv.reserve(m);
  for (int i = 0, u = 0, v = 0; i < m; ++i) {
    cin >> u >> v;
    pv.emplace_back(u - 1, v - 1);
  }
  auto res = sol.calc(pv, n);
  for (auto r : res) {
    cout << r << " ";
  }
  cout << "\n";
  return 0;
}
