#include <bits/stdc++.h>
using namespace std;
int cases = 1;
vector<int> d(5005, INT_MAX), a(5005);
int n;
int getdist(int x, int y) {
  int dist;
  if (y < x)
    dist = (n - x) + y;
  else
    dist = y - x;
  return dist;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int m, maxi = INT_MIN;
  cin >> n >> m;
  vector<int> player;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    a[x]++;
    int dist = getdist(x, y);
    if (dist < d[x]) {
      d[x] = dist;
    }
  }
  vector<int> ans(n + 5, -1);
  for (int i = 1; i <= n; i++) {
    int pos = i;
    int cnt = 0;
    int mx = 0;
    while (cnt < n) {
      if (a[pos]) {
        int dist = getdist(i, pos);
        mx = max(mx, ((a[pos] - 1) * n) + dist + d[pos]);
      }
      pos++;
      if (pos == n + 1) pos = 1;
      cnt++;
    }
    ans[i] = mx;
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
