#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
const int INF = 1000000007;
int ctr[MAXN], dst[MAXN], val[MAXN];
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= 2 * n; ++i) {
    ctr[i] = 0;
    dst[i] = INF;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    if (y < x) y += n;
    ctr[x]++;
    dst[x] = min(dst[x], y - x);
  }
  int curr = 0;
  for (int i = 1; i <= 2 * n; ++i) {
    if (ctr[i - 1]) curr = max(curr, dst[i - 1] + ctr[i - 1] * n - 1);
    val[i] = curr;
    curr--;
  }
  for (int i = 1; i <= n; ++i) {
    cout << max(val[i], val[i + n]) << " ";
  }
  return 0;
}
