#include <bits/stdc++.h>
using namespace std;
inline bool checkBit(long long n, long long i) {
  return n & ((long long)1 << i);
}
inline long long setBit(long long n, long long i) {
  return n | ((long long)1 << i);
  ;
}
inline long long resetBit(long long n, long long i) {
  return n & (~((long long)1 << i));
}
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) { a = (a + 1000000007) % 1000000007; }
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInv(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInv(b));
}
inline long long fact(long long r) {
  long long ans = 1;
  while (r) ans = modMul(ans, r), r--;
  return ans;
}
inline long long invfact(long long r) {
  long long ans = 1;
  while (r) ans = modMul(ans, modInv(r)), r--;
  return ans;
}
inline double dgcd(double a, double b) {
  if (a < b) return dgcd(b, a);
  if (b < .0001) return a;
  return dgcd(b, fmod(a, b));
}
const long long N = 5e3 + 1;
long long n, m, a, b;
vector<long long> take[N];
long long dis(long long x1, long long x2) {
  if (x2 >= x1)
    return x2 - x1;
  else {
    return n - x1 + x2;
  }
}
long long find(long long s, long long j) {
  long long ans = (long long)2e18;
  for (long long i = 0; i < (long long)((take[j]).size()); i++) {
    if (dis(s, j) < dis(s, take[j][i]))
      ans =
          min(ans, (long long)((take[j]).size()) * n - n + dis(s, take[j][i]));
    else
      ans = min(ans, (long long)((take[j]).size()) * n + dis(s, take[j][i]));
  }
  return (ans == (long long)2e18 ? 0 : ans);
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    a--, b--;
    take[a].push_back(b);
  }
  for (long long i = 0; i < n; i++) {
    long long ans = 0;
    for (long long j = 0; j < n; j++) {
      ans = max(ans, find(i, j));
    }
    cout << ans << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
