#include <bits/stdc++.h>
using namespace std;
long long int INF = 2e18;
const long long fact_table = 1200008;
double Pi = 3.1415926535897932384626;
priority_queue<long long> pql;
priority_queue<pair<long long, long long> > pqp;
priority_queue<pair<long long, long long> > bag;
priority_queue<long long, vector<long long>, greater<long long> > pqls;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    pqps;
long long dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
long long dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
const long long mod = 998244353ll;
long long mypow(long long number1, long long number2, long long mod) {
  if (number2 == 0) {
    return 1ll;
  } else {
    long long number3 = mypow(number1, number2 / 2, mod);
    number3 *= number3;
    number3 %= mod;
    if (number2 % 2 == 1) {
      number3 *= number1;
      number3 %= mod;
    }
    return number3;
  }
}
void YES(bool condition) {
  if (condition) {
    cout << "YES"
         << "\n";
    ;
  } else {
    cout << "NO"
         << "\n";
    ;
  }
  return;
}
void Yes(bool condition) {
  if (condition) {
    cout << "Yes"
         << "\n";
    ;
  } else {
    cout << "No"
         << "\n";
    ;
  }
  return;
}
bool multicase = false;
long long n, m, num, a, b, c, d, e, q;
bool used[200005];
long long k;
long long x[300005];
vector<long long> G[500005];
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    G[a].push_back(b);
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < G[i].size(); j++) {
      if (G[i][j] > i) {
        G[i][j] = G[i][j] - i;
      } else {
        G[i][j] = n + G[i][j] - i;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    sort(G[i].begin(), G[i].end());
    if (G[i].size() >= 1) x[i] = G[i][0];
  }
  for (long long i = 1; i <= n; i++) {
    long long start = i;
    long long ans = 0;
    for (long long j = 1; j <= n; j++) {
      long long time;
      if (G[j].size() == 0) continue;
      if (i <= j) {
        time = j - i;
      } else {
        time = j - i + n;
      }
      time += n * (G[j].size() - 1) + x[j];
      ans = max(ans, time);
    }
    cout << ans << " ";
    ;
  }
  cout << "\n";
  ;
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long q, testcase = 1;
  if (multicase) {
    cin >> q;
  } else {
    q = 1;
  }
  while (q--) {
    solve();
    testcase++;
  }
  return 0;
}
