import sys
sys.setrecursionlimit(10**6)
N, K = map(int, input().split())
s = set()
for i in range(K):
    l, r = map(int, input().split())
    s.add(l)
    s.add(r)
s = list(s)
ans = [0]
def deepsearch(i):
    if N == i:
        ans[0] += 1
        return 0
    elif N < i:
        return 0
    else:
        for j in s:
            deepsearch(i+j)


deepsearch(1)
print(ans[0]%998244353)