#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
int n, m;
vector<int> v[5005];
int A[5005];
int maks;
vector<pair<int, int> > maksi, maksikur;
int first(int x, int y) { return (y - x) < 0 ? y - x + n : y - x; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    v[a].push_back(b);
    maks = max(maks, (int)v[a].size());
  }
  for (int i = 0; i < n; i++) {
    if (v[i].size() == maks) {
      int pendek = INF;
      for (int j = 0; j < v[i].size(); j++)
        pendek = min(pendek, first(i, v[i][j]));
      maksi.push_back(make_pair(i, pendek));
    } else if (maks >= 2 && v[i].size() == maks - 1) {
      int pendek = INF;
      for (int j = 0; j < v[i].size(); j++)
        pendek = min(pendek, first(i, v[i][j]));
      maksikur.push_back(make_pair(i, pendek));
    }
  }
  for (int i = 0; i < n; i++) {
    int last = 0, terakhir = 0;
    for (int j = 0; j < maksi.size(); j++) {
      pair<int, int> now = maksi[j];
      int pem = first(now.first, i);
      if (pem == 0) {
        if (last == 1) continue;
        terakhir = max(terakhir, now.second);
        continue;
      }
      if (now.second < pem) {
        if (last == 1) continue;
        terakhir = max(terakhir, first(i, now.first) + now.second);
      } else {
        if (last == 0) {
          last = 1;
          terakhir = now.second - pem;
        } else {
          terakhir = max(terakhir, now.second - pem);
        }
      }
    }
    for (int j = 0; j < maksikur.size(); j++) {
      pair<int, int> now = maksikur[j];
      int pem = first(now.first, i);
      if (pem == 0) {
        continue;
      }
      if (now.second < pem) {
        continue;
      } else {
        if (last == 0) {
          terakhir = max(terakhir, now.second - pem);
        }
      }
    }
    cout << (maks - 1 + last) * n + terakhir << ' ';
  }
}
