#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, count = 0;
  cin >> n >> k;
  int ans[200005] = {0};
  ans[1] = 1;
  int tag[20][5];
  for (int i = 0; i <= 19; i++) {
    for (int j = 0; j <= 4; j++) {
      tag[i][j] = 0;
    }
  }
  for (int i = 1; i <= k; i++) {
    int a, b;
    cin >> a >> b;
    tag[k][1] = a;
    tag[k][2] = b;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] > 0) {
      for (int j = 1; j <= k; j++) {
        for (int t = tag[j][1]; t <= tag[j][2]; t++) {
          int yn = i + t;
          if (yn <= n) {
            ans[yn] += ans[i];
            ans[yn] %= 998244353;
          } else {
            goto tag1;
          }
        }
      tag1:
        int c = 0;
      }
    }
    for (int i = 1; i <= n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  cout << ans[n] << endl;
  return 0;
}
