#include <bits/stdc++.h>
using namespace std;
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0,
                         long long int r = 0xFFFFFFFFFFFFFFFL) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
template <typename Arg1, typename Arg2>
ostream& operator<<(ostream& out, const pair<Arg1, Arg2>& a) {
  return out << "(" << a.first << " , " << a.second << ")";
}
template <typename Arg1>
ostream& operator<<(ostream& out, const vector<Arg1>& a) {
  out << "[";
  for (const auto& i : a) out << i << " , ";
  return out << "]";
}
template <typename Arg1>
ostream& operator<<(ostream& out, const set<Arg1>& a) {
  out << "{";
  for (const auto& i : a) out << i << " , ";
  return out << "}";
}
template <typename Arg1, typename Arg2>
ostream& operator<<(ostream& out, const map<Arg1, Arg2>& a) {
  out << "<";
  for (const auto& i : a) out << i << " , ";
  return out << ">";
}
template <typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
                   ostream&>::type
operator<<(ostream& out, T (&a)[N]) {
  out << '[';
  for (size_t i = 0; i < N; ++i) out << a[i] << " , ";
  out << ']';
  return out;
}
int n, m, lst[5005];
vector<int> can[5005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j, u, v;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    can[u].push_back(v);
  }
  for (i = 0; i < 5005; i++) {
    if (can[i].size()) {
      lst[i] = i - 1;
      sort(can[i].begin(), can[i].end());
      for (auto j : can[i]) {
        if ((n + j - i) % n <= (n + lst[i] - i) % n) {
          lst[i] = j;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    int ans = 0;
    for (j = i; j <= n; j++) {
      if (can[j].size() == 0) continue;
      int ta = 0;
      ta = (n + j - i) % n;
      ta += ((can[j].size() - 1) * n);
      ta += ((n + lst[j] - j) % n);
      ans = max(ans, ta);
    }
    for (j = 1; j < i; j++) {
      if (can[j].size() == 0) continue;
      int ta = 0;
      ta = (n + j - i) % n;
      ta += ((can[j].size() - 1) * n);
      ta += ((n + lst[j] - j) % n);
      ans = max(ans, ta);
    }
    cout << ans << " ";
  }
  return 0;
}
