(n,k),*e=[[*map(int,i.split())]for i in open(0)]
mod=998244353
a=[0]*n
a[0]=1
b=[]
e.sort()
for i,j in e:
    b+=range(i,j+1)
m=len(b)
if len(b)>n//2:
    c=range(1,n+1)
    c=set(c)-set(b)
    c=list(c)
    c.sort()
    b=c
for i in range(n):
    if a[i]==0:break
    for j in b:
        if i+j<n:
            a[i+j]+=a[i]
            a[i+j]%=mod
        else:break
print(pow(2,n-3,mod)-a[-1] if m>n//2 else a[-1]) 