def a(num, b):
        ans = 0
        for i in range(len(b)):
                if(num - b[i] == 0):
                        ans = ans + 1
                elif(num - b[i] > 0):
                        ans +=a(num - b[i], b)
        return ans

N ,K = map(int, input().split())
S = []

for i in range(K):
        for n in input().split():
                S.append(int(n))

S = sorted(set(S), reverse=True)
print(a(N - 1, S) % 998244353)