#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 5;
int n, m, x[maxn], y[maxn], ans[5000 + 5];
bool vis[5000 + 5];
struct node {
  int y, t;
  node(int y = 0, int t = 0) : y(y), t(t) {}
  bool operator<(const node& g) const { return t > g.t; }
};
vector<node> g[5000 + 5], h[5000 + 5];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    x[i]--;
    y[i]--;
    g[x[i]].push_back(node(y[i], (y[i] - x[i] + n) % n));
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    mx = max(mx, (int)g[i].size());
  }
  for (int i = 0; i < n; i++) {
    for (int j = max(0, mx - 2); j < g[i].size(); j++) h[i].push_back(g[i][j]);
  }
  for (int i = 0; i < n; i++) {
    int num = 0;
    int dis = -1e9;
    memset(vis, 0, sizeof(vis));
    int st = i;
    while (true) {
      if (num < h[st].size()) {
        int y = h[st][num].y;
        if (vis[y] && dis < (y - i + n) % n) dis = (y - i + n) % n;
        if (!vis[y] && dis < (y - i + n) % n - n) dis = (y - i + n) % n - n;
      }
      vis[st] = 1;
      st = (st + 1) % n;
      if (st == i) break;
    }
    if (mx == 1) {
      ans[i] += n + dis;
      continue;
    }
    if (dis <= 0)
      dis = -1e9;
    else
      dis = dis - n;
    ans[i] += n;
    st = i;
    memset(vis, 0, sizeof(vis));
    num++;
    while (true) {
      if (num < h[st].size()) {
        int y = h[st][num].y;
        if (vis[y] && dis < (y - i + n) % n) dis = (y - i + n) % n;
        if (!vis[y] && dis < (y - i + n) % n - n) dis = (y - i + n) % n - n;
      }
      vis[st] = 1;
      st = (st + 1) % n;
      if (st == i) break;
    }
    ans[i] += n + dis;
  }
  for (int i = 0; i < n; i++) printf("%d\n", ans[i] + max(0, mx - 2) * n);
  return 0;
}
