#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> candy;
int min_dis[5000];
int distance(int a, int b) {
  if (a <= b)
    return b - a;
  else
    return n + b - a;
}
int main() {
  int i, j, k;
  int temp;
  scanf("%d %d", &n, &m);
  candy.resize(n);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &j, &k);
    j--;
    k--;
    candy[j].push_back(distance(j, k));
  }
  for (i = 0; i < n; i++) sort(candy[i].begin(), candy[i].end());
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (candy[j].size()) {
        temp = distance(i, j) + (candy[j].size() - 1) * n + candy[j][0];
        if (temp > min_dis[i]) min_dis[i] = temp;
      }
    }
  }
  for (i = 0; i < n; i++) printf("%d ", min_dis[i]);
}
