#include <bits/stdc++.h>
using namespace std;
const int NMX = 5007;
const int MMX = 20007;
long long a[NMX][NMX];
long long mi[NMX];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int k, l;
    scanf("%d %d", &k, &l);
    a[k % n][l % n] += 1;
  }
  for (int i = 0; i < n; i++) {
    bool first = false;
    for (int j = i; j < (n + i); j++) {
      if (first == false && a[i][j % n] >= 1) {
        mi[i] += abs(j - i);
        first = true;
        a[i][j % n] -= 1;
      }
      mi[i] += a[i][j % n] * n;
    }
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    for (int j = 1; j <= n; j++) {
      if (mi[j % n] >= 1)
        ans = max(ans, mi[j % n] + ((i > j) ? n - i + j : j - i));
    }
    cout << ans << ' ';
  }
  return 0;
}
