# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True

import sys
input = sys.stdin.readline
import math
import itertools

def INT(): return int(input())
def MAPINT(): return map(int, input().split())
def LMAPINT(): return list(map(int, input().split()))
def STR(): return input()
def MAPSTR(): return map(str, input().split())
def LMAPSTR(): return list(map(str, input().split()))

f_inf = float('inf')
mod = 10 * 9 + 7


def main():

    n, k = MAPINT()
    d = [0] * (k*2)
    for i in range(k):
        d[i*2], d[i*2+1] = LMAPINT()

    kukan = list(set(d))
    count = 0
    for j in range(1, n):
        tmp = sorted(list(itertools.product(kukan, repeat=j)))
        for t in tmp:
            if sum(t) == n-1:
                count += 1
            if sum(t) > n:
              break
    print(int(count%998244353))

if __name__ == "__main__":
    main()
