#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, a, b;
  vector<int> v[101];
  vector<int> sum(101), ans(101);
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
  }
  int val = INT_MAX;
  for (i = 1; i <= n; i++) {
    val = INT_MAX;
    int x = v[i].size();
    if (x != 0) {
      for (j = 0; j < x; j++) {
        if (i > v[i][j]) {
          val = min(val, v[i][j] + n - i);
        } else {
          val = min(val, v[i][j] - i);
        }
        sum[i] = (x - 1) * n + val;
      }
    } else
      sum[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    val = 0;
    long long time = 0;
    for (j = i; j <= n; j++) {
      if (val < time + sum[j] && v[j].size() > 0) {
        val = (sum[j] + time);
      }
      time++;
    }
    for (j = 1; j < i; j++) {
      if (val - time < sum[j] && v[j].size() > 0) {
        val = (sum[j] + time);
      }
      time++;
    }
    ans[i] = val;
  }
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
