#include <bits/stdc++.h>
using namespace std;
const int INFL = (int)1e9;
const long long int INFLL = (long long int)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
long long int rndf(double x) {
  return (long long int)(x + (x >= 0 ? 0.5 : -0.5));
}
long long int floorsqrt(long long int x) {
  long long int m = (long long int)sqrt((double)x);
  return m + (m * m <= x ? 0 : -1);
}
long long int ceilsqrt(long long int x) {
  long long int m = (long long int)sqrt((double)x);
  return m + (x <= m * m ? 0 : 1);
}
long long int rnddiv(long long int a, long long int b) {
  return (a / b + (a % b * 2 >= b ? 1 : 0));
}
long long int ceildiv(long long int a, long long int b) {
  return (a / b + (a % b == 0 ? 0 : 1));
}
long long int gcd(long long int m, long long int n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
long long int lcm(long long int m, long long int n) {
  return m * n / gcd(m, n);
}
class Max_Queue {
 private:
  stack<pair<long long int, long long int> > stk0, stk1;
  void rebuffer() {
    while (stk1.size()) {
      long long int x = stk1.top().first;
      long long int y = stk0.size() ? stk0.top().second : LLONG_MIN;
      stk0.push({x, max(x, y)});
      stk1.pop();
    }
  }

 public:
  void push(long long int x) {
    long long int y = stk1.size() ? stk1.top().second : LLONG_MIN;
    stk1.push({x, max(x, y)});
  }
  long long int front() {
    if (stk0.empty()) rebuffer();
    return stk0.top().first;
  }
  void pop() {
    if (stk0.empty()) rebuffer();
    stk0.pop();
  }
  size_t size() { return stk0.size() + stk1.size(); }
  void clear() {
    while (stk0.size()) stk0.pop();
    while (stk1.size()) stk1.pop();
  }
  long long int get_max() {
    long long int x = LLONG_MIN, y = LLONG_MIN;
    if (stk0.size()) x = stk0.top().second;
    if (stk1.size()) y = stk1.top().second;
    return max(x, y);
  }
};
long long int dist(long long int s, long long int t, long long int n) {
  if (s <= t)
    return t - s;
  else
    return t + n - s;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long int> a(n, LLONG_MAX);
  vector<long long int> cnt(n, 0);
  for (int i = 0; i < (int)(m); i++) {
    long long int s, t;
    cin >> s >> t;
    s--;
    t--;
    a[s] = min(a[s], dist(s, t, n));
    cnt[s]++;
  }
  vector<long long int> ans(n, 0);
  Max_Queue mq;
  for (int j = 0; j < (int)(n); j++) {
    long long int buf = -n;
    if (cnt[j] > 0) buf = dist(0, j, n) + (cnt[j] - 1) * n + a[j];
    mq.push(buf);
  }
  for (int i = 0; i < (int)(n); i++) {
    ans[i] = mq.get_max() - i;
    long long int x = mq.front();
    mq.pop();
    mq.push(x + n);
  }
  for (int extra_i = 0; extra_i < (int)(ans.size()); extra_i++) {
    cout << ans[extra_i] << " ";
  }
  cout << endl;
  ;
}
