#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int inf = 0x3f3f3f3f;
int n, ti[maxn], m;
vector<int> v[maxn];
int dis(int a, int b) {
  if (b >= a)
    return b - a;
  else
    return n - a + b;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if ((int)v[i].size() == 0) continue;
    int minn = inf;
    for (int j = 0; j < (int)v[i].size(); j++) {
      minn = min(minn, dis(i, v[i][j]));
    }
    ti[i] = ((int)v[i].size() - 1) * n + minn;
  }
  for (int i = 1; i <= n; i++) {
    int maxx = 0;
    for (int j = 1; j <= n; j++) {
      if (ti[j] == 0) continue;
      maxx = max(maxx, ti[j] + dis(i, j));
    }
    cout << maxx << " ";
  }
  cout << endl;
  return 0;
}
