#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
vector<int> vec[maxn];
int main() {
  int n, m, dist;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 1; i <= m; i++) {
      int s, e;
      scanf("%d%d", &s, &e);
      if (s <= e)
        dist = e - s;
      else
        dist = n - (s - e);
      vec[s].push_back(dist);
    }
    for (int i = 1; i <= n; i++) {
      sort(vec[i].begin(), vec[i].end());
    }
    for (int i = 1; i <= n; i++) {
      int res = -1;
      for (int j = 1; j <= n; j++) {
        if (vec[j].size() == 0) continue;
        if (i <= j)
          dist = j - i;
        else
          dist = n - (i - j);
        dist += (vec[j].size() - 1) * n;
        dist += vec[j][0];
        if (res < dist) res = dist;
      }
      if (i != 1) printf(" ");
      printf("%d", res);
    }
    printf("\n");
  }
  return 0;
}
