#include <bits/stdc++.h>
using namespace std;
const int INFL = (int)1e9;
const long long int INFLL = (long long int)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
long long int rndf(double x) {
  return (long long int)(x + (x >= 0 ? 0.5 : -0.5));
}
long long int floorsqrt(long long int x) {
  long long int m = (long long int)sqrt((double)x);
  return m + (m * m <= x ? 0 : -1);
}
long long int ceilsqrt(long long int x) {
  long long int m = (long long int)sqrt((double)x);
  return m + (x <= m * m ? 0 : 1);
}
long long int rnddiv(long long int a, long long int b) {
  return (a / b + (a % b * 2 >= b ? 1 : 0));
}
long long int ceildiv(long long int a, long long int b) {
  return (a / b + (a % b == 0 ? 0 : 1));
}
long long int gcd(long long int m, long long int n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
long long int lcm(long long int m, long long int n) {
  return m * n / gcd(m, n);
}
int dist(int s, int t, int n) {
  if (s <= t)
    return t - s;
  else
    return t + n - s;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  for (int i = 0; i < (int)(m); i++) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    a[s].push_back(dist(s, t, n));
  }
  for (int i = 0; i < (int)(n); i++) {
    sort(a[i].begin(), a[i].end());
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < (int)(n); i++) {
    vector<vector<int>> b = a;
    int p = i;
    int time = 0;
    int timeout = 0;
    while (true) {
      if (b[p].size()) {
        int t = b[p].back();
        b[p].pop_back();
        ans[i] = max(ans[i], time + t);
        timeout = 0;
      } else
        timeout++;
      if (timeout > n + 3) break;
      p++;
      if (p == n) p = 0;
      time++;
    }
  }
  for (int extra_i = 0; extra_i < (int)(ans.size()); extra_i++) {
    cout << ans[extra_i] << " ";
  }
  cout << endl;
  ;
}
