#include <bits/stdc++.h>
using namespace std;
const int M = 20005;
int a[M], b[M];
vector<int> c[M];
void solve(int n, int second) {
  int ans = 0, i = second;
  do {
    int i1 = (i - second + n) % n;
    int cst = (c[i].empty() ? 0 : 1 << 30);
    for (int j : c[i])
      cst =
          min(cst, (j - second + n) % n + ((j - second + n) % n < i1 ? n : 0));
    ans = max(ans, cst + (int)(c[i].size() - 1) * n);
    i = (i + 1) % n;
  } while (i != second);
  printf("%d ", ans);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    c[--a[i]].push_back(--b[i]);
  }
  for (int i = 0; i < n; ++i) solve(n, i);
  return 0;
}
