#include <bits/stdc++.h>
using namespace std;
const int maxn = 2100;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-6;
const double pi = acos(-1);
int a[maxn], b[maxn];
int c[maxn];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a[i], &b[i]);
    c[a[i]]++;
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    mx = max(mx, c[i]);
  }
  for (int p = 1; p <= n; p++) {
    int t = 1;
    for (int i = 1; i <= n; i++) {
      if (c[i] == mx - 1) {
        int tt = -1;
        int tb;
        for (int j = 1; j <= m; j++) {
          if (a[j] == i) {
            if (b[j] > i)
              tb = b[j];
            else
              tb = n + b[j];
            if (tt == -1)
              tt = tb;
            else
              tt = min(tt, tb);
          }
        }
        t = max(t, tt);
      }
    }
    int ans2 = t - 1;
    if (mx >= 2) ans2 += (mx - 2) * n;
    t = 1;
    for (int i = 1; i <= n; i++) {
      if (c[i] == mx) {
        int tt = -1;
        int tb;
        for (int j = 1; j <= m; j++) {
          if (a[j] == i) {
            if (b[j] > i)
              tb = b[j];
            else
              tb = n + b[j];
            if (tt == -1)
              tt = tb;
            else
              tt = min(tt, tb);
          }
        }
        t = max(t, tt);
      }
    }
    int ans = (mx - 1) * n + t - 1;
    ans = max(ans2, ans);
    printf("%d ", ans);
    for (int j = 1; j <= m; j++) {
      if (a[j] == 1)
        a[j] = n;
      else
        a[j]--;
      if (b[j] == 1)
        b[j] = n;
      else
        b[j]--;
    }
    c[n + 1] = c[1];
    for (int i = 1; i <= n; i++) {
      c[i] = c[i + 1];
    }
  }
}
