function MainD(input){
    const mod = 998244353;
    const [[Ns, Ks], ...LR] = input.split('\n').map(val => val.split(' '));
    const [N, K] = [Number(Ns), Number(Ks)]
    const uni = new Set();
    LR.flat().map(a => uni.add(Number(a)));
    const S = Array.from(uni);
    const DFS = (curr) => {
        if(curr > N) return 0;
        if(curr === N) return 1;
        let count = 0;
        if(!flg) return;
        for(let i=0; i<S.length; i++){
            if(curr+S[i] < N){
                count += DFS(curr+S[i]);
            }
        }
        return count % mod;
    }
    console.log(DFS(1));
}
MainD(require("fs").readFileSync("/dev/stdin", "utf8").trim());
