#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
const double error = 1e-10;
const double PI = acos(-1);
inline long long int MOD(long long int x, long long int m = mod) {
  long long int y = x % m;
  return (y >= 0) ? y : y + m;
}
const int inf = INT_MAX;
const long long int infl = LLONG_MAX;
const int nmax = 5e3 + 10;
int cnt[nmax];
long long int mindist[nmax];
long long int ans[nmax];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int mxcnt = 0;
  for (int i = 1; i <= n; i++) mindist[i] = n;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    cnt[a]++;
    mxcnt = max(mxcnt, cnt[a]);
    mindist[a] = min(mindist[a], MOD(b - a, n));
  }
  for (int i = 1; i <= n; i++) {
    long long int maxans = 0;
    for (int j = 0; j < n; j++) {
      int k = i + j;
      if (k > n) k -= n;
      if (cnt[k] != 0) {
        maxans = max(maxans, j + (cnt[k] - 1) * n + mindist[k]);
      }
    }
    ans[i] = maxans;
  }
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
}
