#include<bits/stdc++.h>
using namespace std;
#define int long long 
int mod = 998244353;

main(){
	int n,k; cin>>n>>k;
	set<int> s;
	while(k--){
		int a,b; cin>>a>>b;
		s.insert(a);
		s.insert(b);
	}
	
	int count[n]{};
	count[0] = 1;
	
	for(int i=1; i<=n-1; i++){
		for(int x : s){
			if(i>=x) count[i] = (count[i]%mod + count[i-x]%mod)%mod;
		}
	}
	cout<<count[n-1]%mod;
}