#include <bits/stdc++.h>
using namespace std;
int n, m, lev[110], ans[110];
const int inf = 0x3f3f3f3f;
vector<int> sta[110];
int nextsta(int x) {
  if (x == n) return 1;
  return x + 1;
}
int fendpos(int x) {
  int res = nextsta(x);
  int ans = x;
  while (res != x) {
    if (lev[res]) ans = res;
    res = nextsta(res);
  }
  return ans;
}
int main() {
  memset(lev, inf, sizeof(lev));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    sta[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    int len = sta[i].size();
    if (!len) lev[i] = 0;
    for (int j = 0; j < len; j++) {
      if (sta[i][j] >= i) {
        lev[i] = min(lev[i], (len - 1) * n + sta[i][j] - i);
      } else {
        lev[i] = min(lev[i], (len - 1) * n + n - (i - sta[i][j]));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int went = 0;
    int leftgo = lev[i];
    int j = nextsta(i);
    int endpos = fendpos(i);
    while (j != nextsta(endpos)) {
      went++;
      if (leftgo) leftgo--;
      leftgo = max(leftgo, lev[j]);
      j = nextsta(j);
    }
    ans[i] = went + leftgo;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
