#include <bits/stdc++.h>
inline long long read() {
  char c = getchar();
  long long x = 0, s = 1;
  while (c < '0' || c > '9') {
    if (c == '-') s = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * s;
}
using namespace std;
const int N = 2e5 + 10;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const unsigned long long mod = 998244353;
const double II = acos(-1);
const double PP = (II * 1.0) / (180.00);
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> v[n + 5];
  for (int i = 1; i <= m; i++) {
    int x, y, ans = 0;
    cin >> x >> y;
    x > y ? ans = n - (x - y) : ans = y - x;
    v[x].push_back(ans);
  }
  for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (int i = 1; i <= n; i++) {
    int sum = -1, ans;
    for (int j = 1; j <= n; j++) {
      if (v[j].size() == 0) continue;
      j >= i ? ans = j - i : ans = n - (i - j);
      ans = ans + v[j][0] + (v[j].size() - 1) * n;
      sum = max(sum, ans);
    }
    cout << sum << endl;
  }
}
