#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const long long mod = 1e9 + 7;
const int alphabet = 26;
const int inf = INT_MAX;
const long long linf = 1e18 + 9;
namespace util {
inline long long cnm(char ch) { return (ch - '0'); }
inline long long cap(char ch) { return (ch - 'a'); }
inline void instr(string& s, long long& n) {
  cin >> s;
  n = s.length();
}
inline void instr(string& s) { cin >> s; }
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
bool min(T a, T b, T c) {
  return std::min(a, std::min(b, c));
}
}  // namespace util
using namespace util;
int b[maxn];
vector<int> station[maxn];
long long n;
int distance(int from, int to) {
  if (to >= from) {
    return (to - from);
  } else
    return (n - from + to);
}
void solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, k, m;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    station[ai].push_back(bi);
  }
  int ans;
  vector<int> v_ans(maxn);
  for (i = 1; i <= n; i++) {
    ans = 0;
    vector<int> v;
    for (auto dest : station[i]) {
      v.push_back(distance(i, dest));
    }
    if (v.size() != 0) {
      sort(v.begin(), v.end());
      ans += n * (v.size() - 1) + v[0];
    }
    v_ans[i] = ans;
  }
  vector<int> res(maxn);
  for (i = 1; i <= n; i++) {
    int mxx = 0;
    for (j = 1; j <= n; j++) {
      if (v_ans[j]) mxx = max(mxx, v_ans[j] + distance(i, j));
    }
    res[i] = mxx;
  }
  for (i = 1; i <= n; i++) cout << res[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
