import itertools

n,k = map(int,input().split())
l = []
for num in range(k):
	l += [list(map(int,input().split()))]
    
s = []
for num in range(k):
  ch = 0
  if l[num][0] == l[num][1]:
    s += [l[num][0]]
  else:
    s += [l[num][0],l[num][1]]
    
count = 0

for num in range(n):
  test = list(itertools.product(s, repeat=num+1))
  for i in range(len(test)):
    
    if n-1 == sum(test[i]):
      count += 1
      #print(test[i],sum(test[i]))
    #elif n < sum(test[i]):
      #break   
print(count%998244353)