#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, m;
int s[205];
int t[205];
vector<int> a[105];
int ans[105];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
  }
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int num = a[j].size();
      if (num == 0) continue;
      int temp = 0;
      if (i > j) {
        temp += n - i + j;
      } else {
        temp += j - i;
      }
      int min_dis = INF;
      for (int k = 0; k < num; k++) {
        int v = a[j][k];
        int dis;
        if (v >= j) {
          dis = v - j;
        } else {
          dis = n - j + v;
        }
        min_dis = min(min_dis, dis);
      }
      temp += (num - 1) * n;
      temp += min_dis;
      ans[i] = max(ans[i], temp);
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
