Problem: Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.

Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the army should consist of some subset of them.

The i-th mercenary can be chosen if the resulting number of chosen mercenaries is not less than l_i (otherwise he deems the quest to be doomed) and not greater than r_i (he doesn't want to share the trophies with too many other mercenaries). Furthermore, m pairs of mercenaries hate each other and cannot be chosen for the same quest. 

How many non-empty subsets does Polycarp need to consider? In other words, calculate the number of non-empty subsets of mercenaries such that the size of this subset belongs to [l_i, r_i] for each chosen mercenary, and there are no two mercenaries in the subset that hate each other.

The answer may be large, so calculate it modulo 998244353.

Input

The first line contains two integers n and m (1 ≤ n ≤ 3 ⋅ 10^5, 0 ≤ m ≤ min(20, (n(n-1))/(2))) — the number of mercenaries and the number of pairs of mercenaries that hate each other.

Then n lines follow, the i-th of them contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n).

Then m lines follow, the i-th of them contains two integers a_i and b_i (1 ≤ a_i < b_i ≤ n) denoting that the mercenaries a_i and b_i hate each other. There are no two equal pairs in this list.

Output

Print one integer — the number of non-empty subsets meeting the constraints, taken modulo 998244353.

Examples

Input


3 0
1 1
2 3
1 3


Output


3


Input


3 1
1 1
2 3
1 3
2 3


Output


2

Solution (in JAVA):

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

public class Main extends PrintWriter {
    
    
    private void solve() {
        build_fac();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] l = new int[n];
        int[] r = new int[n];
        int[] add = new int[n+1];
        int[] sub = new int[n+2];
        for(int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
            add[l[i]]++;
            sub[r[i]+1]++;
        }
        int[] cnt = new int[n+1];
        for(int i = 1, cur = 0; i <= n; i++) {
            cur -= sub[i];
            cur += add[i];
            cnt[i] = cur;
        }
        long[][] sum = new long[2*m+1][n+1];
        for(int i = 0; i <= 2*m; i++) {
            for(int j = 1; j <= n; j++) {
                sum[i][j] = sum[i][j-1] + C(cnt[j]-i, j-i);
                if(sum[i][j] >= M) sum[i][j] -= M;
            }
        }
        
        int[][] pairs = new int[m][];
        for(int i = 0; i < m; i++) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            pairs[i] = new int[] {a,b};
        }
        long ans = 0L;
        for(int i = 0; i < (1<<m); i++) {
            int l_ = 1;
            int r_ = n;
            HashSet<Integer> set = new HashSet<>();
            int constraints = 0;
            for(int j = 0; j < m; j++) {
                if((i & (1 << j)) > 0) {
                    set.add(pairs[j][0]);
                    set.add(pairs[j][1]);
                    constraints++;
                }
            }
            for(int x : set) {
                l_ = Math.max(l_, l[x]);
                r_ = Math.min(r_, r[x]);
            }
            int set_sz = set.size();
            if(l_ > r_) continue;
            long diff = sum[set_sz][r_] - sum[set_sz][l_-1];
            if(diff < 0) diff += M;
            ans = ans + ((constraints&1)==0?1:-1)*diff;
            if(ans < 0) ans += M;
            if(ans >= M) ans -= M;
        }
        println(ans);
    }
    
    
    
    int MX = 300000;
    long[] fac = new long[MX+1];
    long[] fac_inv = new long[MX+1];
    long[] inv = new long[MX+1];
    
    long M = 998244353L;
 
    long C(int n, int k) {
        if(n < k || k < 0) return 0L;
        long  c = (fac_inv[k] * fac_inv[n - k]) % M;
        c = (c * fac[n]) % M;
        return c;
    }
    
    void build_fac() {
        inv[1] = 1L;
        for(int i = 2; i <= MX; i++) 
            inv[i] = M - (M/i) * inv[(int)(M%i)] % M;
        fac[0] = 1L;
        fac_inv[0] = 1L;
        for(int i = 1; i <= MX; i++) {
            fac[i] = (fac[i-1]*i)%M;
            fac_inv[i] = (fac_inv[i-1]*inv[i])%M;
        }
    }
    
    
    
//  Main() throws FileNotFoundException { super(new File("output.txt")); }
//  InputReader sc = new InputReader(new FileInputStream("test_input.txt"));
    
  Main() { super(System.out); }
  InputReader sc = new InputReader(System.in);
  static class InputReader {
      InputReader(InputStream in) { this.in = in; } InputStream in;
      
      private byte[] buf = new byte[16384];
      private int    curChar;
      private int    numChars;
      
 
      public int read() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = in.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextLine() {
          int c = read();
          while (isSpaceChar(c))
              c = read();
          StringBuilder res = new StringBuilder();
          do {
              res.appendCodePoint(c);
              c = read();
          } while (!isEndOfLine(c));
          return res.toString();
      }
 
      public String nextString() {
          int c = read();
          while (isSpaceChar(c))
              c = read();
          StringBuilder res = new StringBuilder();
          do {
              res.appendCodePoint(c);
              c = read();
          } while (!isSpaceChar(c));
          return res.toString();
      }
 
      public long nextLong() {
          int c = read();
          while (isSpaceChar(c))
              c = read();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = read();
          }
          long res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = read();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public int nextInt() {
          int c = read();
          while (isSpaceChar(c))
              c = read();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = read();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = read();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      private boolean isSpaceChar(int c) {
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      private boolean isEndOfLine(int c) {
          return c == '\n' || c == '\r' || c == -1;
      }
  }
 
    public static void main(String[] $) {
        new Thread(null, new Runnable() {
            public void run() {
                long start = System.nanoTime();
                try {Main solution = new Main(); solution.solve(); solution.close();} 
                catch (Exception e) {e.printStackTrace(); System.exit(1);}
                System.err.println((System.nanoTime()-start)/1E9);
            }
        }, "1", 1 << 27).start();
 
    }
    

}