#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
void read(vector<long long> &a) {
  for (long long &i : a) cin >> i;
}
void read(vector<int> &a) {
  for (int &i : a) cin >> i;
}
long long INF64 = 1e18;
long long mod = 1e9 + 7;
int INF = 1e9;
long long fastpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
void test_case(int tnum) {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n + 1);
  vector<int> mn(n + 1, INF);
  vector<vector<int>> adj(n + 1);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    cnt[u]++;
    ;
    mn[u] = min(mn[u], (v - u + n) % n);
    adj[u].push_back(v);
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    if (mn[i] == INF) continue;
    mx = max(mx, cnt[i]);
  }
  vector<int> mxsta;
  for (int i = 1; i < n + 1; i++) {
    if (cnt[i] == mx) {
      mxsta.push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    int best = -INF;
    pair<int, int> p;
    for (int j = 1; j <= n; j++) {
      if (cnt[j] == 0) {
        continue;
      }
      int mn = INF;
      int no = -1;
      for (int k : adj[j]) {
        int dist = (k - j + n) % n;
        dist += (j - i + n) % n;
        dist += (cnt[j] - 1) * n;
        if (dist < mn) no = k;
        mn = min(mn, dist);
      }
      if (mn > best) {
        p = {j, no};
      }
      best = max(best, mn);
    }
    cout << best << ' ';
  }
}
int main(void) {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int t = 1;
  for (int test = 1; test <= t; test++) {
    test_case(test);
  }
  return 0;
}
