#include <bits/stdc++.h>
using namespace std;
const int N = 5e3;
const long long INF = 1LL << 60;
vector<int> v[N];
long long f[N];
int n;
long long toGet(int a, int b) {
  if (b > a) return b - a;
  return n - (a - b);
}
int comper = 0;
bool cmp(int a, int b) { return toGet(comper, a) > toGet(comper, b); }
struct Multiset {
  multiset<long long> s;
  long long shift = 0;
  void add(long long x) { s.insert(x + shift); }
  void erase(long long x) { s.erase(s.lower_bound(x + shift)); }
  long long getMax() { return *s.rbegin() - shift; }
};
int main() {
  ::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    v[a].push_back(b);
  }
  for (int i = 0; i < n; ++i) {
    comper = i;
    sort(v[i].begin(), v[i].end(), cmp);
  }
  Multiset temp;
  for (int i = 0; i < n; ++i) {
    if (!v[i].empty()) {
      f[i] = toGet(i, v[i].back()) + n * (v[i].size() - 1LL);
      temp.add(f[i] + i);
    }
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    res = temp.getMax();
    cout << res << " ";
    if (i + 1 == n) break;
    if (!v[i].empty()) {
      temp.erase(f[i]);
      temp.add(f[i] + n);
    }
    temp.shift += 1;
  }
  cout << endl;
  return 0;
}
