/*
	Auth: Loxilante
	Time: 2020/09/19
	Prog: ABC179D
	Lang: cpp
*/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif
#include <bits/extc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...) 97
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn = int> inline tn next(void) { tn k; cin>>k; return k; }
int n,k,dp[22222222], seg1[15], seg2[15];
const int MOD = 998244353;
int lowbit(int k)
{
    return k & -k;
}
void add(int x,int k)
{
    while(x<=n)
    {
        dp[x]+=k;
        dp[x]%=MOD;
        x+=lowbit(x);
    }
}
int su(int x)
{
    int ans=0;
    while(x!=0)
    {
        ans+=dp[x];
        ans%=MOD;
        x-=lowbit(x);
    }
    return ans;
}
int sum(int a, int b)
{
	return ((su(b) - su(a-1))+2*MOD)%MOD;
}
signed main(void)
{
	cin>>n>>k;
	rep(i, 0, k) cin>>seg1[i]>>seg2[i];

	add(1, 1);
	hrp(i, 1, n) rep(j, 0, k)
	{
		int t = i-seg1[j], tt = i-seg2[j];
		if (t <= 0) continue;
		if (tt <= 0) tt = 1;

		add(i, sum(tt, t));
		hrp(T, 1, n) cout<<dp[T]<<" \n"[T == n];
	}
	
	cout<<sum(n, n)<<endl;

	return 0;
}