#include <bits/stdc++.h>
using namespace std;
vector<int> tab[1000];
int main() {
  int n, c;
  cin >> n >> c;
  for (int i = 0; i < c; i++) {
    int a, b;
    cin >> a >> b;
    tab[a].push_back(b);
  }
  int time = 2000000000;
  for (int second = 1; second <= n; second++) {
    int t = 0;
    int ma = 0;
    for (int i = 1; i <= n; i++) {
      int d;
      if (i >= second)
        d = i - second;
      else
        d = n - second + i;
      d += (tab[i].size() - 1) * n;
      int mi = 1231231;
      for (int j = 0; j < tab[i].size(); j++) {
        int dro = 0;
        if (tab[i][j] > i)
          dro = tab[i][j] - i;
        else
          dro = n - i + tab[i][j];
        if (dro < mi) mi = dro;
      }
      d += mi;
      if (d > ma && tab[i].size() > 0) {
        ma = d;
      }
    }
    cout << ma << " ";
  }
}
