#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
vector<int> fuck[maxn];
int start, n, m;
bool cmp(int a, int b) {
  int aa = a, bb = b;
  if (aa < start) aa += n;
  if (bb < start) bb += n;
  return aa > bb;
}
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &j, &k);
    fuck[j].push_back(k);
  }
  for (i = 1; i <= n; i++) {
    start = i;
    sort(fuck[i].begin(), fuck[i].end(), cmp);
  }
  for (int st = 1; st <= n; st++) {
    int max_dis = 0;
    for (i = 1; i <= n; i++)
      if (!fuck[i].empty()) {
        int tmp_dis = i - st;
        if (tmp_dis < 0) tmp_dis += n;
        int round = fuck[i].size();
        tmp_dis += (round - 1) * n;
        int ed = fuck[i][round - 1];
        int dis = ed - i;
        if (dis < 0) dis += n;
        tmp_dis = tmp_dis + dis;
        max_dis = max(max_dis, tmp_dis);
      }
    printf("%d ", max_dis);
  }
}
