#include <bits/stdc++.h>
using namespace std;
int n, m, xMin[20005], cnt[20005];
pair<int, int> a[20005];
void inline MIN(int &A, int B) { A = min(A, B); }
void inline MAX(int &A, int B) { A = max(A, B); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    a[i] = make_pair(u, v);
  }
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= n - 1; j++) xMin[j] = 1000000007, cnt[j] = 0;
    for (int j = 1; j <= m; j++) {
      int u = (a[j].first - i + n) % n;
      int v = (a[j].second - i + n) % n;
      if (u > v) v += n;
      MIN(xMin[u], v);
      cnt[u]++;
    }
    int ans = 0;
    int cycle = 0;
    for (int j = 0; j <= n - 1; j++) MAX(cycle, cnt[j] - 1);
    long long res = 1ll * (cycle - 1) * n;
    for (int j = 0; j <= n - 1; j++)
      if (cnt[j] - 1 == cycle && xMin[j] != 1000000007)
        ans = max(ans, xMin[j] + n);
      else if (cnt[j] == cycle && xMin[j] != 1000000007)
        ans = max(ans, xMin[j]);
    cout << res + ans << ' ';
  }
}
