#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int M = 20005;
int n, m, out[N], C[N];
void checkmin(int &a, int b) {
  if (b < a) a = b;
}
void checkmax(int &a, int b) {
  if (b > a) a = b;
}
int dis(int s, int e) { return (e - s + n) % n; }
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    C[i] = n + 1;
  }
  for (int i = 1; i <= m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    out[a]++;
    checkmin(C[a], dis(a, b));
  }
}
void solve() {
  for (int start = 1; start <= n; ++start) {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (!out[i]) continue;
      checkmax(ans, (out[i] - 1) * n + dis(start, i) + C[i]);
    }
    printf("%d%c", ans, (start == n ? '\n' : ' '));
  }
}
int main() {
  init();
  solve();
  return 0;
}
