N,K = map(int, input().split())
S = set()
for _ in range(K):
	a,b = map(int, input().split())
	S.add(a)
	S.add(b)
dp = [0]*(N+1)
dp[1] = 1
mod = 998244353
l = sorted(list(S))
for i in range(1,N+1):
	for j in l:
		if(i >= j):
			dp[i] += dp[i-j]
			dp[i] %= mod
print(dp[-1])

