#include <bits/stdc++.h>
using namespace std;
vector<int> v[5005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b < a) b += n;
    v[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (!v[j].empty())
        ans = max(ans, (int)(v[j].size() - 1) * n + (j - i + n) % n +
                           v[j].back() - j);
    }
    printf("%d ", ans);
  }
}
