#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
const int MAXS = 1005;
const int inf = 1e9 + 1e8;
const long long INF = 1e18 + 1e17;
const int MOD1 = 998244353;
const int MOD2 = 1e9 + 7;
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
bool is_prime(int x) {
  if (x == 1 || (!(x % 2) && x > 2)) return false;
  for (int i = 3; i * i <= x; i += 2) {
    if (!(x % i)) {
      return false;
    }
  }
  return true;
}
bool is_palindrome(string str) {
  for (int i = 0; i < str.length() / 2; i++) {
    if (str[i] != str[str.length() - 1 - i]) {
      return false;
    }
  }
  return true;
}
long long NCR(int n, int r) {
  if (n < r || r < 0 || n <= 0) return 0;
  if (r > n / 2) return NCR(n, n - r);
  long long res = 1;
  for (long long k = 1; k <= r; k++) {
    res *= n - k + 1;
    res /= k;
  }
  return res;
}
int N, M;
int num[MAXN], minn[MAXN];
vector<int> stations[MAXN];
int main() {
  cin >> N >> M;
  int maxx = 0;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    num[a]++;
    maxx = max(maxx, num[a]);
    stations[a].push_back(b);
  }
  for (int i = 0; i < N; i++) {
    int temp = inf;
    for (int j = 0; j < stations[i].size(); j++) {
      temp = min(temp, (N + stations[i][j] - i) % N);
    }
    minn[i] = (stations[i].size() ? temp : 0);
  }
  for (int i = 0; i < N; i++) {
    int ans = 0;
    for (int j = 0; j < N; j++) {
      ans = max(ans, ((j + N - i) % N + minn[j] + ((num[j] - 1) * N)));
    }
    cout << ans << endl;
  }
  return 0;
}
