#include <bits/stdc++.h>
using namespace std;
long long inf = 2147483647;
const long long ll = 9223372036854775807, ninf = 1000000000;
const double eps = 1e-6;
const long long nll = 1000000000000000000;
int q[5005] = {};
int p[5005] = {};
int main() {
  int a, b;
  while (cin >> a >> b) {
    for (int i = 0; i < 5005; i++) p[i] = inf;
    for (int i = 1; i <= b; i++) {
      int x, y;
      cin >> x >> y;
      q[x]++;
      int h = 0;
      if (y >= x) {
        h = y - x;
      } else {
        h = a - x + y;
      }
      p[x] = min(p[x], h);
    }
    for (int i = 1; i <= a; i++) {
      int ans = 0;
      for (int j = 1; j <= a; j++) {
        if (q[j] == 0) continue;
        int h = 0;
        if (j >= i) {
          h = j - i;
        } else {
          h = a + j - i;
        }
        ans = max(ans, h + p[j] + (q[j] - 1) * a);
      }
      cout << ans << " ";
    }
    cout << '\n';
    ;
  }
  return 0;
}
