#include <bits/stdc++.h>
using namespace std;
vector<int> p[5005];
int n, m, minn[5005];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) minn[i] = -1;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    p[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < p[i].size(); j++) {
      int to = p[i][j];
      if (to > i) {
        if (minn[i] == -1)
          minn[i] = (to - i);
        else
          minn[i] = min(minn[i], to - i);
      } else {
        if (minn[i] == -1)
          minn[i] = (n - i + to);
        else
          minn[i] = min(minn[i], n - i + to);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    for (int j = 1; j <= n; j++) {
      long long now = 0;
      if (j >= i)
        now += j - i;
      else
        now += n - i + j;
      int S = p[j].size();
      if (S == 0)
        continue;
      else
        now += (S - 1) * n + minn[j];
      ans = max(now, ans);
    }
    printf("%d ", ans);
  }
  return 0;
}
