#include <bits/stdc++.h>
using namespace std;
struct re {
  int x, y;
};
const int inf = 1e9 + 10;
const int N = 5000 + 10;
const double pi = 3.14;
int n, m, x, y, dodai[N];
vector<int> a[N];
int dist(int x, int y) {
  if (x <= y) return y - x;
  return (n - x + y);
}
void cal(int x) {
  int kq = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i].size()) kq = max(kq, dist(x, i) + dodai[i]);
  cout << kq << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> x >> y;
    a[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i)
    if (a[i].size()) {
      dodai[i] = inf;
      for (auto j : a[i]) dodai[i] = min(dodai[i], dist(i, j));
      dodai[i] += (a[i].size() - 1) * n;
    }
  for (int i = 1; i <= n; ++i) cal(i);
  return 0;
}
