#include <bits/stdc++.h>
using namespace std;
const int maxn = 5010;
vector<int> v[maxn];
int vis[maxn];
int dis[maxn];
int n, m;
int num;
bool cmp(int a, int b) { return (a + n - num) % n < (b + n - num) % n; }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    num = i;
    sort(v[i].begin(), v[i].end(), cmp);
  }
  for (int i = 1; i <= n; i++) {
    if (v[i].size())
      dis[i] = (n * ((int)v[i].size() - 1)) + (*v[i].begin() + n - i) % n;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (v[j].size()) ans = max(ans, (j + n - i) % n + dis[j]);
    }
    printf("%d ", ans);
  }
  return 0;
}
