Problem: There are N cells arranged in a row, numbered 1, 2, \ldots, N from left to right.

Tak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.

You are given an integer K that is less than or equal to 10, and K non-intersecting segments [L_1, R_1], [L_2, R_2], \ldots, [L_K, R_K]. Let S be the union of these K segments. Here, the segment [l, r] denotes the set consisting of all integers i that satisfy l \leq i \leq r.

* When you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.



To help Tak, find the number of ways to go to Cell N, modulo 998244353.

Constraints

* 2 \leq N \leq 2 \times 10^5
* 1 \leq K \leq \min(N, 10)
* 1 \leq L_i \leq R_i \leq N
* [L_i, R_i] and [L_j, R_j] do not intersect (i \neq j)
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N K
L_1 R_1
L_2 R_2
:
L_K R_K


Output

Print the number of ways for Tak to go from Cell 1 to Cell N, modulo 998244353.

Examples

Input

5 2
1 1
3 4


Output

4


Input

5 2
3 3
5 5


Output

0


Input

5 1
1 2


Output

5


Input

60 3
5 8
1 3
10 15


Output

221823067

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

public class Main {
	static FastReader f = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);
	

	public static void main(String[] args) {
		//int t = f.nextInt();
		//while(t-- > 0)
			solve();
		out.close();
	}

	static int MOD = 998244353;
	static void solve() {
		int n = f.nextInt();
		int k = f.nextInt();
		int[][] arr = new int[k][2];
		for(int i=0;i<k;i++) {
			arr[i][0] = f.nextInt();
			arr[i][1] = f.nextInt();
		}

		SegmentTree seg = new SegmentTree(n);
		seg.update(0,1);
		for(int i=1;i<n;i++) {
			long loc = 0;
			for(int j=0;j<k;j++) {
				loc = (loc + seg.get(Math.max(0,i-arr[j][1]), Math.max(i-arr[j][0]+1,0))) % MOD; 
			}
			seg.update(i, (int) loc);
		}

		out.println(seg.get(n-1,n));
	}

	static class SegmentTree {
        int n;
        int[] arr;
 
        SegmentTree(int l) {
            this.n = calc(l);
            arr = new int[n << 1];
        }
 
        private static int calc(int size) {
            int ans = 1;
            while (ans < size) {
                ans <<= 1;
            }
            return ans;
        }

        void update(int i, int x) {
            int ind = n - 1 + i;
            arr[ind] = x;
            while (ind > 0) {
                ind = (ind-1)/2;
                arr[ind] = (arr[2*ind+1]+ arr[2*ind+2]) % MOD;
            }
        }
 
        long get(int left, int right) {
            return search(left, right, 0, 0, n);
        }
 
        long search(int l, int r, int x, int lx, int rx) {
 
            if(rx <= l || r <= lx) {
                return 0;
            }
            if(l <= lx && rx <= r) {
                return arr[x];
            }
 
            return (search(l, r, 2*x+1, lx, (rx+lx)/2)+
                    search(l, r, 2*x+2, (rx+lx)/2, rx)) % MOD;
        }
 
    }
 
 

	static class FastReader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(IOException ioe) {
					ioe.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			String s = "";
			try {
				s = br.readLine();
			} catch(IOException ioe) {
				ioe.printStackTrace();
			}

			return s;
		}

		int  nextInt() {
			return Integer.parseInt(next());
		}
	}
}