#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX_N = 200 + 10;
struct Node {
  int depa;
  int dest;
  int dist;
  Node(int depa = 0, int dest = 0, int dist = 0)
      : depa(depa), dest(dest), dist(dist) {}
  Node(const Node& temp) : depa(temp.depa), dest(temp.dest), dist(temp.dist) {}
  bool operator<(const Node& temp) const { return dist > temp.dist; }
};
int n, m;
priority_queue<Node> que[MAX_N];
int maxNum = 0;
int solve(int start) {
  int result = 0;
  for (int i = 0; i < n; ++i) {
    int now = (start + i - 1) % n + 1;
    if (que[now].size() == 0) continue;
    Node node = que[now].top();
    int dist;
    if (now >= start)
      dist = now - start;
    else
      dist = now - start + n;
    if (que[now].size() == maxNum) {
      dist += node.dist;
    } else if (que[now].size() == maxNum - 1) {
      dist = n - dist;
      if (dist >= node.dist)
        dist = 0;
      else
        dist = node.dist - dist;
    } else
      continue;
    if (result < dist) result = dist;
  }
  return result;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int depa;
    int dest;
    scanf("%d %d", &depa, &dest);
    int dist;
    if (dest > depa)
      dist = dest - depa;
    else
      dist = n - depa + dest;
    que[depa].push(Node(depa, dest, dist));
  }
  for (int i = 1; i <= n; ++i)
    if (maxNum < que[i].size()) maxNum = que[i].size();
  int answer = (maxNum - 1) * n;
  for (int i = 0; i < n; ++i)
    printf("%d%c", answer + solve(i + 1), i == n ? '\n' : ' ');
  return 0;
}
