#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using V = vector<int>;
int main(int argc, char const *argv[]) {
  int mod = 998244353;
  int n, k;
  cin >> n >> k;
  int l[15], r[15];
  for (int i = 0; i < k; i++) {
    cin >> l[i] >> r[i];
  }
  sort(l, l + k);
  sort(r, r + k);
  long long int dp[200010] = {};
  dp[1] = 1;
  if (l[0] == 1) dp[2] = 1;
  for (int i = 3; i <= n; i++) {
    dp[i] = dp[i - 1];
    for (int j = 0; j < k; j++) {
      if (i - l[j] - 1 >= 0) {
        dp[i] += dp[i - l[j]];
        if (i - r[j] - 1 >= 1) dp[i] -= dp[i - r[j] - 1];
        dp[i] += mod;
        dp[i] %= mod;
      }
    }
    cout << dp[i] << endl;
  }
  cout << dp[n] << endl;
  return 0;
}
