#include <bits/stdc++.h>
using namespace ::std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
int64_t ri64() {
  int64_t x;
  scanf("%lld", &x);
  return x;
}
void wi(int x) { printf("%d\n", x); }
void wvi(vector<int> &v) {
  for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  printf("\n");
}
void dbg(string &str, int x) {
  cout << str << ": ";
  wi(x);
}
void dbg(string &str, vector<int> &x) {
  cout << str << ": ";
  wvi(x);
}
int main() {
  int n = ri();
  int m = ri();
  vector<vector<int> > P(n);
  for (int i = 0; i < m; i++) {
    int x = ri();
    int y = ri();
    x--;
    y--;
    int t = y - x;
    if (t < 0) t += n;
    P[x].push_back(t);
  }
  for (int i = 0; i < n; i++) {
    if (!P[i].empty()) sort(P[i].begin(), P[i].end());
  }
  vector<int> Q(n, 0);
  for (int i = 0; i < n; i++) {
    if (!P[i].empty())
      Q[i] = P[i][0] + n * (P[i].size() - 1);
    else
      Q[i] = -100000000;
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      int k = (i + j) % n;
      ans = max(ans, j + Q[k]);
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
