#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 5005;
const ll inf = 1e18;
int n, m;
int calc(int a, int b) { return (a <= b) ? (b - a) : n - (a - b); }
vector<int> G[sz], T[sz];
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    for (int i = 0; i < sz; i++) G[i].clear();
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      G[a].push_back(calc(a, b));
    }
    for (int i = 1; i <= n; i++) {
      sort(G[i].begin(), G[i].end());
    }
    for (int i = 1; i <= n; i++) {
      ll h = 0;
      for (int j = 1; j <= n; j++) {
        if (G[j].size() == 0) continue;
        ll dis = calc(i, j) + (max((ll)G[j].size() - 1, 0ll) * n) +
                 (G[j].size() ? G[j].front() : 0);
        h = max(dis, h);
      }
      cout << h << " ";
    }
    cout << "\n";
    cerr << "-----\n";
  }
  return 0;
}
