#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> c(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (b < a) {
      b += n;
    }
    c[a].push_back(b);
  }
  int max_size = 0;
  for (int i = 0; i < n; ++i) {
    sort(c[i].begin(), c[i].end());
    max_size = max(max_size, (int)c[i].size());
  }
  for (int i = 0; i < n; ++i) {
    int mx = 0;
    for (int j = 0; j < n; ++j) {
      if ((int)c[j].size() < max_size - 1) {
        continue;
      }
      if ((int)c[j].size() == max_size) {
        int from = j;
        int to = c[j][0] - i;
        if (to < 0) {
          to += n;
        } else if (to >= n) {
          to %= n;
        }
        if (from < to) {
          mx = max(mx, n * (max_size - 1) + to);
        } else {
          mx = max(mx, n * max_size + to);
        }
      } else if (!c[j].empty()) {
        int from = j;
        int to = c[j][0] - i;
        if (to < 0) {
          to += n;
        } else if (to >= n) {
          to %= n;
        }
        if (from > to) {
          mx = max(mx, n * (max_size - 1) + to);
        }
      }
    }
    cout << mx << ' ';
    rotate(c.begin(), c.begin() + 1, c.end());
  }
  return 0;
}
