#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int mxN = 5005;
template <class T>
T gcd(T a, T b) {
  return ((b == 0) ? a : gcd(b, a % b));
}
int n, m;
int dist(int a, int b) {
  if (b >= a) return b - a;
  return n - (a - b);
}
int cur = 0;
vector<int> g[mxN];
bool cmp(int a, int b) { return dist(cur, a) < dist(cur, b); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < (int)(m); i++)
    cin >> a[i] >> b[i], g[a[i]].push_back(b[i]);
  for (int i = (int)(1); i < (int)(n + 1); i++) {
    cur = i;
    sort(g[i].begin(), g[i].end(), cmp);
  }
  for (int i = (int)(1); i < (int)(n + 1); i++) {
    int ans = 0;
    int ind = i;
    int res = 0;
    int num = 0;
    for (int j = 0; j < (int)(n); j++) {
      res = max(res, ans + (g[ind].size() ? ((int)(g[ind].size() - 1) * n) +
                                                dist(ind, g[ind][0])
                                          : 0));
      num += g[ind].size();
      if (num == m) break;
      ind++;
      if (ind == (n + 1)) ind = 1;
      ans++;
    }
    cout << res << " ";
  }
  cout << endl;
  return 0;
}
