#include <bits/stdc++.h>
using namespace std;
mt19937 rnd;
const int MAXN = 5020, MAXM = 20020;
vector<int> a[MAXN];
int ans[MAXN] = {};
vector<int> solve(int n, int m, pair<int, int> p[]) {
  for (int i = 0; i < m; i++) {
    int d = 0;
    if (p[i].second > p[i].first)
      d = p[i].second - p[i].first;
    else
      d = n - p[i].first + p[i].second;
    a[p[i].first].push_back(d);
  }
  for (int i = 1; i <= n; i++) {
    sort(a[i].begin(), a[i].end());
  }
  for (int i = 1; i <= n; i++) {
    if (a[i].size() == 0) continue;
    ans[i] = (a[i].size() - 1) * n + a[i][0];
  }
  vector<int> shit;
  for (int k = 1; k <= n; k++) {
    int r = 0;
    for (int i = 0; i < n; i++) {
      int d = k + i;
      if (d > n) d -= n;
      if (ans[d] > 0) {
        r = max(r, i + ans[d]);
      }
    }
    shit.push_back(r);
  }
  return shit;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  pair<int, int> p[m];
  for (int i = 0; i < m; i++) cin >> p[i].first >> p[i].second;
  vector<int> k = solve(n, m, p);
  for (int i = 0; i < n; i++) cout << k[i] << ' ';
  return 0;
}
