#include <bits/stdc++.h>
using namespace std;
const int mx = 5e3 + 5, inf = 1e9;
int n, m, num[mx], mn[mx];
int minn(int a, int b) { return ((b - a + n) % n); }
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) mn[i] = inf;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    num[a]++;
    mn[a] = min(mn[a], minn(a, b));
  }
  for (int i = 0; i < n; i++) {
    int maxx = 0;
    for (int j = 0; j < n; j++) {
      int sum = 0;
      if (num[j] == 0) mn[j] = 0;
      sum += minn(i, j);
      sum += (num[j] - 1) * n;
      sum += mn[j];
      maxx = max(sum, maxx);
    }
    cout << maxx << endl;
  }
  return 0;
}
