#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9,
                  Gold = ((1 + sqrt(5)) / 2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
long long keyCount = sizeof(keymod) / sizeof(long long);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcountll(s);
}
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
string cppstr_infile = "FILE.IN";
string cppstr_outfile = "FILE.OUT";
long long n, m;
vector<vector<long long> > station;
void Input() {
  cin >> n >> m;
  station.resize(n);
  while (m--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    station[a].push_back(b);
  }
}
void Solve() {
  long long MaxSize = 0;
  for (long long i = 0; i < n; i++) {
    sort(station[i].begin(), station[i].end());
    MaxSize = max(MaxSize, (long long)station[i].size());
  }
  for (long long i = 0; i < n; i++) {
    long long ans = 0;
    for (long long x = 0; x < n; x++) {
      long long tmp = LINF;
      for (auto y : station[x]) {
        if (x <= y) {
          if (i <= x)
            tmp = min(tmp, x - i + y - x);
          else
            tmp = min(tmp, n - i + x + y - x);
        } else {
          if (i <= x)
            tmp = min(tmp, x - i + n - x + y);
          else
            tmp = min(tmp, n - i + x + n - x + y);
        }
      }
      if (tmp == LINF) continue;
      ans = max(ans, n * max(0LL, (long long)station[x].size() - 1) + tmp);
    }
    cout << ans << " ";
  }
  cout << '\n';
}
int main(int argc, char* argv[]) {
  ControlIO(argc, argv);
  Input();
  TimerStart();
  Solve();
  TimerStop();
  return 0;
}
void ControlIO(int argc, char* argv[]) {
  char* infile = new char[cppstr_infile.size() + 1];
  char* outfile = new char[cppstr_outfile.size() + 1];
  strcpy(infile, cppstr_infile.c_str());
  strcpy(outfile, cppstr_outfile.c_str());
}
void TimerStart() {}
void TimerStop() {}
void Exit() {
  TimerStop();
  exit(0);
}
