#include <bits/stdc++.h>
using namespace std;
vector<int> a[5050];
bool cmp(const int aa, const int bb) { return aa > bb; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u].push_back((v - u + n) % n);
  }
  int ma = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = a[i].size();
    ma = max(ma, tmp);
    sort(a[i].begin(), a[i].end(), cmp);
  }
  int gao = max(0, ma - 2);
  for (int i = 1; i <= n; i++) {
    int sz = a[i].size();
    if (sz - gao <= 0) {
      a[i].clear();
    } else if (sz - gao == 1) {
      int tmp = a[i][sz - 1];
      a[i].clear();
      a[i].push_back(tmp);
    } else {
      int a1 = a[i][sz - 2], a2 = a[i][sz - 1];
      a[i].clear();
      a[i].push_back(a1);
      a[i].push_back(a2);
    }
  }
  long long ans = 1ll * (long long)gao * (long long)n;
  for (int i = 1; i <= n; i++) {
    int wa = 0;
    int pos = i;
    for (int j = 1; j <= n; j++) {
      if (a[pos].size() == 2) {
        wa = max(wa, j - 1 + n + a[pos][1]);
      } else if (a[pos].size() == 1) {
        wa = max(wa, a[pos][0] + j - 1);
      }
      pos = pos % n + 1;
    }
    printf("%I64d%c", ans + (long long)wa, i == n ? '\n' : ' ');
  }
}
