#include <bits/stdc++.h>
using namespace std;
int main() {
  int sn, cn;
  cin >> sn >> cn;
  int s[5005];
  for (int i = 1; i <= sn; i++) {
    s[i] = -1;
  }
  vector<int> p[5005];
  for (int i = 1; i <= cn; i++) {
    int tb, te;
    cin >> tb >> te;
    p[tb].push_back(te);
  }
  for (int i = 1; i <= sn; i++) {
    for (int j = 0; j < p[i].size(); j++) {
      int temp = p[i][j];
      if (temp > i) {
        if (s[i] == -1)
          s[i] = temp - i;
        else
          s[i] = min(s[i], temp - i);
      } else {
        if (s[i] == -1)
          s[i] = sn + temp - i;
        else
          s[i] = min(s[i], sn + temp - i);
      }
    }
  }
  for (int i = 1; i <= sn; i++) {
    long long sum = 0;
    for (int j = 1; j <= sn; j++) {
      long long np = 0;
      if (j >= i)
        np += j - i;
      else
        np += sn + j - i;
      if (!p[j].size())
        continue;
      else
        np += (p[j].size() - 1) * sn + s[j];
      sum = max(np, sum);
    }
    cout << sum << " ";
  }
}
