#include <bits/stdc++.h>
const int INF = 1000 * 1000 * 1000;
using namespace std;
int n, m;
int imp[5005];
int nxt[5005];
vector<vector<int> > g(5005);
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
  }
  int sz = 0;
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    sz = max(sz, ((int)(g[i].size())));
  }
  for (int i = 0; i < n; i++) {
    imp[i] = ((int)(g[i].size())) == sz;
    if (lower_bound(g[i].begin(), g[i].end(), i) == g[i].end()) {
      if (((int)(g[i].size())))
        nxt[i] = g[i].front();
      else
        nxt[i] = -1;
    } else
      nxt[i] = *lower_bound(g[i].begin(), g[i].end(), i);
  }
  for (int i = 0; i < n; i++) {
    int ans2 = 0;
    for (int j = 0; j < n; j++) {
      if (imp[j]) {
        ans2 = max(ans2, (sz - 1) * n + (j - i + n) % n + (nxt[j] - j + n) % n);
      } else if (((int)(g[j].size())) == sz - 1 && ((int)(g[j].size()))) {
        ans2 = max(ans2, (sz - 2) * n + (j - i + n) % n + (nxt[j] - j + n) % n);
      }
    }
    cout << ans2 << " ";
  }
}
