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:
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            int k=scan.nextInt();
            long[] dp=new long[n];
            long mod=998244353;
            ArrayList<Pair> ks=new ArrayList<>();
            for(int i=0;i<k;i++){
                ks.add(new Pair(scan.nextInt(),scan.nextInt()));
            }
            long[] ps=new long[n];
            ps[0]=1;
            dp[0]=1;
            for(int i=1;i<n;i++){
                long ans=0;
                for(Pair cur:ks){
                    int l=cur.x;
                    int r=cur.y;
                    int ri=i-l;
                    int li=Math.max(0,i-r);
                    if(ri>=li){
                        ans=(ans+ps[ri])%mod;
                    }
                    if(li>0){
                        ans=(ans-ps[li-1]+mod)%mod;
                    }
                }
                dp[i]=ans;
                ps[i]=(ps[i-1]+dp[i])%mod;
            }
            out.println(dp[n-1]);
        }
        out.flush();
        out.close();
    }
    static class Pair{
        int x;
        int y;
        Pair(int x,int y) {
            this.x = x;
            this.y = y;
        }
//        @Override
//        public boolean equals(Object o) {
//            if (this == o) return true;
//            if (!(o instanceof Pair)) return false;
//            Pair key = (Pair) o;
//            return x == key.x && y == key.y;
//        }
//
//        @Override
//        public int hashCode() {
//            int result = x;
//            result = 31 * result + y;
//            return result;
//        }
    }
    static class fenwickTree{
        int[] arr;
        fenwickTree(int[] ar){
            arr=new int[ar.length+1];
            for(int i=0;i<ar.length;i++){
                update(i,ar[i]);
            }
        }
        fenwickTree(int n){
            arr=new int[n+1];
        }
        void update(int i,int nv){
            int in=i+1;
            while(in<arr.length){
                arr[in]+=nv;
                in+=(in&(-in));
            }
        }
        int query(int i){
            int sum=0;
            int in=i+1;
            while(in>0){
                sum+=arr[in];
                in=(in&(in-1));
            }
            return sum;
        }
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}