#include <bits/stdc++.h>
using namespace std;
vector<long long int> ve[300000], ve2[5005];
int main() {
  std::ios::sync_with_stdio(false);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int u, v;
    cin >> u >> v;
    ve[u].push_back(v);
  }
  vector<long long int> indx;
  for (long long int i = 1; i <= n; i++) {
    for (auto it : ve[i]) {
      if (it < i) {
        it += n;
        ve2[i].push_back(it);
      } else {
        ve2[i].push_back(it);
      }
    }
    sort(ve2[i].begin(), ve2[i].end());
  }
  vector<long long int> answer;
  for (long long int i = 1; i <= n; i++) {
    long long int ans = 0;
    for (long long int j = 1; j <= n; j++) {
      long long int x;
      if (j < i)
        x = (j + n - i);
      else
        x = abs(j - i);
      if (ve2[j].size() == 0) x = 0;
      for (auto it : ve2[j]) {
        x += abs(j - it);
        break;
      }
      if (ve2[j].size() >= 1) x += n * (ve2[j].size() - 1);
      ans = max(ans, x);
    }
    answer.push_back(ans);
  }
  cout << endl;
  for (auto it : answer) cout << it << " ";
  return 0;
}
