#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> c[5005], c1[5005];
void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    c[u].push_back(v);
  }
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    maxi = max(maxi, int(c[i + 1].size()));
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (int(c[i].size()) < 1) {
      continue;
    }
    int m1, m2, idx = 0;
    m1 = m2 = n;
    for (int jj = 0; jj < c[i].size(); jj++) {
      int j = c[i][jj];
      int d = j - i;
      if (d < 0) d = n + d;
      if (d < m1) {
        idx = jj;
        m1 = d;
      }
    }
    c1[i].push_back(c[i][idx]);
  }
  for (int i = 1; i <= n; i++) {
    int a1 = 0;
    ans = 0;
    for (int j = 1; j <= n; j++) {
      int n1 = c1[j].size();
      if (n1 == 0) continue;
      int d1 = j - i;
      if (d1 < 0) d1 += n;
      int d = c1[j][0] - j;
      if (d < 0) d = n + d;
      ans = max(ans, n * (int(c[j].size()) - 1) + d1 + d);
    }
    cout << ans << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
