#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T>>;
template <class T>
ostream &operator<<(ostream &os, const deque<T> &t) {
  os << "{";
  for (int(i) = 0; (i) < (t.size()); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int(i) = 0; (i) < (t.size()); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class T, size_t n>
ostream &operator<<(ostream &os, const array<T, n> &t) {
  os << "{";
  for (int(i) = 0; (i) < (n); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
template <class S, class T, class U>
ostream &operator<<(ostream &os, const tuple<S, T, U> &t) {
  return os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
}
template <class S, class T, class U, class V>
ostream &operator<<(ostream &os, const tuple<S, T, U, V> &t) {
  return os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ","
            << get<3>(t) << ")";
}
template <class S, class T, class U, class V, class W>
ostream &operator<<(ostream &os, const tuple<S, T, U, V, W> &t) {
  return os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ","
            << get<3>(t) << "," << get<4>(t) << ")";
}
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
const long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(0);
  int n, m;
  cin >> n >> m;
  vv<int> dst(n);
  for (int(i) = 0; (i) < (m); ++(i)) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    dst[a].push_back((b + n - a) % n);
  }
  int t = 3;
  for (int(i) = 0; (i) < (n); ++(i)) MX<int>(t, dst[i].size());
  for (int(i) = 0; (i) < (n); ++(i)) {
    sort((dst[i]).begin(), (dst[i]).end());
    dst[i].resize(max(0, (int)dst[i].size() - (t - 3)));
    reverse((dst[i]).begin(), (dst[i]).end());
    dst[i].resize(3, -MOD);
  }
  vector<long long> re(n);
  for (int(i) = 0; (i) < (n); ++(i)) {
    long long cur = (t - 3) * n;
    long long mx = 0;
    for (int(j) = 0; (j) < (3); ++(j))
      for (int(k) = 0; (k) < (n); ++(k)) {
        MX(mx, cur + dst[(k + i >= n ? k + i - n : k + i)][j]);
        ++cur;
      }
    re[i] = mx;
  }
  (re, 1);
  for (auto x : re) cout << x << " ";
  return 0;
}
