#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9, MN = 5010;
vector<int> c[MN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    c[x].push_back(y);
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int x = 0, y = 0, mn1 = oo, mn2 = oo;
      for (int k = 0; k < (int)c[j].size(); k++) {
        if ((c[j][k] - i + n) % n <= (j - i + n) % n) {
          x++;
          mn1 = min(mn1, (c[j][k] - i + n) % n);
        } else {
          y++;
          mn2 = min(mn2, (c[j][k] - i + n) % n);
        }
      }
      int res = 0;
      if (x > 0 && y == 0)
        res = x * n + mn1;
      else if (x > 0 && y > 0)
        res = x * n + (y - 1) * n + mn2;
      else if (x == 0 && y > 0)
        res = (y - 1) * n + mn2;
      ans[i] = max(ans[i], res);
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << '\n';
  return 0;
}
