#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e6 + 10;
int a[maxi], b[maxi];
vector<int> v[maxi];
string s;
int n, m;
int rez[maxi];
int cnt[maxi];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) rez[i] = maxi;
  int mm = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    cnt[a[i]]++;
    mm = max(cnt[a[i]], mm);
    if (b[i] >= a[i])
      rez[a[i]] = min(rez[a[i]], b[i] - a[i]);
    else
      rez[a[i]] = min(rez[a[i]], n - a[i] + b[i]);
  }
  for (int i = 1; i <= n; i++) {
    int ans = (mm - 1) * n;
    int mar = 0;
    for (int j = 1; j <= n; j++)
      if (cnt[j] == mm) {
        int dis = 0;
        if (j >= i)
          dis = j - i;
        else
          dis = n - i + j;
        mar = max(mar, dis + rez[j]);
      } else if (cnt[j] == mm - 1 && mm > 1) {
        int dist = 0;
        if (i > j)
          dist = i - j;
        else
          dist = n - j + i;
        mar = max(mar, rez[j] - dist);
      }
    printf("%d ", ans + mar);
  }
}
