n,k = map(int,input().split())
s = set()
for i in range(k):
    l, r = map(int,input().split())
    lr = set(list(range(l,r+1)))
    s = s|lr

def iterate(start, goal, s):
    if start == goal:
        return 1
    elif start > goal:
        return 0
    else:
        res = 0
        for i in s:
            res += iterate(start+i, goal, s)
        return res

ans = iterate(1, n, s)
ans = ans%998244353
print(ans)