#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
string stin() {
  string s;
  cin >> s;
  return s;
}
const long long mod = 998244353;
int main() {
  int n = in(), k = in();
  vector<pair<int, int> > p(k);
  for (int i = 0; i < k; i++) p[i] = make_pair(in(), in() + 1);
  vector<long long> ans(n * 2 + 10), plus(n * 2 + 10);
  plus[1] = -1;
  ans[0] = 1;
  for (auto e : p) {
    plus[e.first] += 1;
    plus[e.second] -= 1;
  }
  for (int i = 0; i < n - 1; i++) {
    ans[i + 1] = ((ans[i] + plus[i + 1]) % mod + mod) % mod;
    for (auto e : p) {
      plus[i + 1 + e.first] += ans[i + 1];
      plus[i + 1 + e.second] -= ans[i + 1];
    }
  }
  for (int i = 0; i < n; i++) cout << i << " " << ans[i] << "\n";
  cout << ans[n - 1] << "\n";
}
