#include <bits/stdc++.h>
using namespace std;
struct data {
  int mmin, times;
} da[5010];
int n, m;
int idx[5010], now;
bool cmp(int a, int b) {
  if (da[a].times == 0) return 0;
  if (da[b].times == 0) return 1;
  return (da[a].times - da[b].times) * n + (a + n - now) % n + da[a].mmin >
         (b + n - now) % n + da[b].mmin;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) da[i].mmin = 10000, da[i].times = 0, idx[i] = i;
  while (m--) {
    int a, b;
    cin >> a >> b;
    da[a].times++;
    da[a].mmin = min(da[a].mmin, (b + n - a) % n);
  }
  now = 1;
  int id = n, mmax = 0;
  sort(idx + 1, idx + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    mmax = max(mmax, da[idx[i]].times);
    if (da[idx[i]].times - mmax < -1 || da[idx[i]].times == 0) {
      id = i;
      break;
    }
  }
  id--;
  for (int i = 1; i <= n; i++) {
    now = i;
    sort(idx + 1, idx + 1 + id, cmp);
    cout << (da[idx[1]].times - 1) * n + (idx[1] + n - now) % n +
                da[idx[1]].mmin
         << " ";
  }
  return 0;
}
