#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> candies[n];
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    candies[x - 1].push_back(y - 1);
  }
  for (int i = 0; i < n; i++) sort(candies[i].begin(), candies[i].end());
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = 0;
    int sz = candies[i].size();
    if (sz == 0) {
      continue;
    }
    a[i] = (sz - 1) * n;
    int x = INT_MAX;
    for (int j = 0; j < sz; j++) {
      if (candies[i][j] > i)
        x = min(x, (candies[i][j] - i));
      else
        x = min(x, (n - (i - candies[i][j])));
    }
    a[i] += x;
  }
  for (int i = 0; i < n; i++) {
    int res = 0, cur = 0, tot = 0;
    int j = i;
    while (true) {
      if (a[j] > cur) {
        res += (a[j] - cur);
        cur = a[j];
      }
      tot += candies[j].size();
      j++, j %= n;
      if (j == i || tot == m) break;
      if (cur == 0)
        res++;
      else
        cur--;
    }
    cout << res << " ";
  }
  cout << endl;
}
