#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10, inf = 2 * N;
vector<int> candies[N];
int d[N];
int dist(int i, int j, int n);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    candies[a].push_back(b);
  }
  for (int i = 1; i <= n; ++i) {
    d[i] = inf;
    for (auto &j : candies[i]) {
      d[i] = min(d[i], dist(i, j, n));
    }
  }
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (!candies[j].empty()) {
        ans = max(ans, n * (int(candies[j].size()) - 1) + dist(i, j, n) + d[j]);
      }
    }
    cout << ans << ' ';
  }
}
int dist(int i, int j, int n) {
  if (i <= j) {
    return j - i;
  } else {
    return n - i + j;
  }
}
