parseline(str=readline()) = parse.(Int, split(str))
function main()
    N, K = parseline()
    Flag = zeros(Int, N)
    Mod = 998244353
    for k in 1:K
        l, r = parseline()
        Flag[l:r] .= 1
    end
    dp = zeros(Int, N)
    dp[1] = 1
    for n in 1:N
        dp[n] == 0 && continue
        for m in 1:N
            Flag[m]≡0 && continue
            next = n + m
            next > N && break
            dp[next] += dp[n]
        end
    end
    println(mod(dp[end], Mod))
end
main()