#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first - a.second) > (b.first - b.second);
}
long long int power(long long int x, long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
int c;
int n;
bool cmp(int a, int b) {
  int t1 = a - c;
  int t2 = b - c;
  if (t1 < 0) t1 = t1 + n;
  if (t2 < 0) t2 = t2 + n;
  return t1 > t2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m;
  cin >> n >> m;
  std::vector<int> v[101];
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    int sz = v[a].size();
  }
  for (int i = 1; i <= n; ++i) {
    c = i;
    sort(v[i].begin(), v[i].end(), cmp);
  }
  for (int i = 1; i <= n; ++i) {
    long long int tme = 0;
    for (int j = 1; j <= n; ++j) {
      if (v[j].size() == 0) continue;
      int p = v[j].size() - 1;
      long long int tmp = (v[j].size() - 1) * n;
      int t1 = (j - i);
      if (t1 < 0) t1 = n + t1;
      int t2 = v[j][p] - j;
      if (t2 <= 0) t2 = n + t2;
      tmp += t1 + t2;
      tme = max(tme, tmp);
    }
    cout << tme << " ";
  }
  cout << endl;
  return 0;
}
