#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long read_long() {
  long long ans = 0;
  char c;
  bool started = false;
  bool is_negative = false;
  while (true) {
    c = getchar();
    if ((c < '0' || c > '9') && c != '-' && !started) continue;
    if ((c < '0' || c > '9') && c != '-' && started) break;
    if (started) {
      ans = ans * 10;
    }
    started = true;
    if (c == '-')
      is_negative = true;
    else
      ans += c - '0';
  }
  if (is_negative) ans *= -1;
  return ans;
}
int n, m;
vector<int> g[5050];
int st;
long long ans[5050];
vector<pair<pair<int, int>, int> > e;
int dist(int a, int b) {
  if (b >= a) return b - a;
  return n - 1 - a + 1 + b;
}
bool cmp(int x, int y) { return dist(st, x) > dist(st, y); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    g[x].push_back(y);
  }
  for (int i = 0; i < n; i++) {
    st = i;
    sort(g[i].begin(), g[i].end(), cmp);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (int)g[i].size(); j++) {
      e.push_back(make_pair(make_pair(i, g[i][j]), j));
    }
  }
  for (int st = 0; st < n; st++) {
    for (__typeof(e.begin()) it = e.begin(); it != e.end(); it++) {
      int x = (*it).first.first;
      int y = (*it).first.second;
      int r = (*it).second;
      long long t = dist(x, y) + dist(st, x) + r * 1ll * n;
      ans[st] = max(ans[st], t);
    }
  }
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    printf("%lld", ans[i]);
  }
  printf("\n");
  return 0;
}
