//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 998244353
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	set<int> g;
	vi h;
	for(int i=0;i<k;i++){
		int x,y;
		cin>>x>>y;
		g.insert(x);
		g.insert(y);
	}
	for(auto it=g.begin();it!=g.end();it++)
		h.pb(*it);
	int dp[n+1]={0};
	dp[1]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<h.size();j++){
			if(i-h[j]>=0){
				(dp[i]+=dp[i-h[j]])%=mod;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

