#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
void debn(vector<int> a) {
  for (auto v : a) cout << v << ' ';
  cout << endl;
}
void debnn(vector<vector<int>> a) {
  for (auto v : a) {
    for (auto w : v) cout << w << ' ';
    cout << endl;
  }
}
long long powmod(long long x, long long y, long long mod) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  map<int, int> kol;
  vector<int> dp;
  dp.resize(20100, 1e9);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    kol[a]++;
    dp[a] = min((b - a + n) % n, dp[a]);
  }
  for (int i = 0; i < 20100; i++)
    if (dp[i] == 1e9) dp[i] = 0;
  for (int i = 0; i < n; i++) {
    int answer = 0;
    for (int j = 0; j < n; j++)
      answer = max(answer, kol[j + 1] * n - n + ((j - i + n) % n) + dp[j + 1]);
    cout << answer << ' ';
  }
  return 0;
}
