#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int n, m;
vector<int> g[N];
long long bpick[N];
long long dist(int i, int j) {
  if (i <= j)
    return j - i;
  else
    return n - (i - j);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
  }
  for (int i = 0; i < n; i++) {
    if (g[i].size()) bpick[i] = dist(i, g[i][0]);
    for (int j = 1; j < g[i].size(); j++)
      bpick[i] = min(bpick[i], dist(i, g[i][j]));
  }
  for (int i = 0; i < n; i++) {
    long long res = 0;
    for (int j = 0; j < n; j++)
      if (g[j].size()) {
        res =
            max(res, dist(i, j) + n * ((long long)g[j].size() - 1) + bpick[j]);
      }
    cout << res << " ";
  }
  cout << endl;
  return 0;
}
