#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
vector<pair<int, int> > des[110];
int dist(int i, int j) {
  if (i <= j) return j - i;
  return n - i + j;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  int i = a.second;
  int x = a.first, y = b.first;
  return dist(i, x) < dist(i, y);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    des[a].push_back(pair<int, int>(b, a));
  }
  for (int i = 1; i <= n; i++) sort(des[i].begin(), des[i].end(), cmp);
  for (int s = 1; s <= n; s++) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (des[i].empty()) continue;
      int d;
      if (s <= i)
        d = i - s;
      else
        d = n - s + i;
      d += n * (des[i].size() - 1);
      int j = des[i][0].first;
      if (i <= j)
        d += j - i;
      else
        d += n - i + j;
      ans = max(ans, d);
    }
    cout << ans << ' ';
  }
}
