#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m;
vector<int> deli[maxn];
int CMP;
inline int dif(int x) {
  if (x >= CMP) return x - CMP;
  return x - CMP + n;
}
bool less2(int a, int b) { return dif(a) > dif(b); }
int sig[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    deli[a].push_back(b);
  }
  for (int i = 1; i <= n; i++)
    if (!deli[i].empty()) {
      CMP = i;
      sort(deli[i].begin(), deli[i].end(), less2);
      sig[i] = ((int)deli[i].size() - 1) * n + dif(deli[i].back());
    }
  for (int i = 1; i <= n; i++) {
    int res = 0;
    CMP = i;
    for (int j = 1; j <= n; j++)
      if (!deli[j].empty()) {
        res = max(res, sig[j] + dif(j));
      }
    printf("%d ", res);
  }
  return 0;
}
