#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 1, s = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return w * s;
}
int n, m;
vector<int> vec[100010];
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= m; ++i) {
    int x = read(), y = read();
    vec[x].push_back(y);
  }
  for (register int i = 1; i <= n; ++i) sort(vec[i].begin(), vec[i].end());
  for (register int i = 1; i <= n; ++i) {
    int ans = 0;
    for (register int j = i; j <= i + n - 1; ++j) {
      int cur = (j - 1) % n + 1;
      int res = j - i;
      int sz = vec[cur].size();
      if (!sz) continue;
      res += (sz - 1) * n;
      int Min = 1e9;
      for (register int k = 0; k < sz; ++k) {
        Min = min(Min, (vec[cur][k] - cur + n) % n);
      }
      res += Min;
      ans = max(ans, res);
    }
    cout << ans << " ";
  }
  return 0;
}
