process.stdin.resume()
process.stdin.setEncoding('utf8')
var g_input = ''
process.stdin.on('data', function(chunk) {
    g_input += chunk
})
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/))
})
function main(input){
  const n = input[0].split(' ')[0]
  const k = input[0].split(' ')[1]
  const s = []
  let c = 0
  input.shift()
  for(let j of input){
    j = j.split(' ')
    const l = j[0] *1
    const r = j[1] *1
    for(let jj=l;jj<=r;jj++){
      s.push(jj)
    }
  }
  const f = (i,l)=>{
    for(let j of s){
      if(i+j==n){
        c++
        //console.log(`${i} ${j} ${l}`)
      }else if(i+j<n){
        f(i+j,l +' '+i)
      }
    }
  }

  f(1,1)
  console.log(c%998244353)
}