#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int n, m, first, second;
vector<int> v[5005];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (; m; m--) {
    cin >> first >> second;
    v[first].push_back(second);
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      int mn = n + 5;
      if (v[j].empty()) continue;
      for (auto &k : v[j]) {
        if (k < j)
          mn = min(mn, n - j + k);
        else
          mn = min(mn, k - j);
      }
      ans = max(ans,
                mn + (j >= i ? j - i : n - i + j) + n * ((int)v[j].size() - 1));
    }
    cout << ans << " ";
  }
  return 0;
}
