#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9 + 7;
const long long INFF = (long long)1e18;
const int mod = 998244353;
const int MXN = (int)5e3 + 7;
vector<int> st[MXN];
int buf;
bool cmp(int u, int v) {
  if ((buf < u) != (buf < v)) return u < v;
  return u > v;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    st[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    buf = i;
    sort(begin(st[i]), end(st[i]), cmp);
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = i, cnt = 0; cnt < n; cnt++) {
      if (!st[j].empty()) {
        int v = ((int)(st[j]).size() - 1) * n + cnt;
        if (st[j].back() >= j)
          v += st[j].back() - j;
        else
          v += st[j].back() + n - j;
        ans = max(ans, v);
      }
      j = (j == n) ? 1 : j + 1;
    }
    printf("%d ", ans);
  }
  return 0;
}
