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.*;
import java.math.*;

public class G {
    final long MOD = 998244353;
    long[] fact;
    long[] invFact;

    public void go() throws IOException {
        int n = ipar();
        int m = ipar();
        fact = new long[n+1];
        invFact = new long[n+1];
        fact[0] = 1;
        invFact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i-1] * i % MOD;
            invFact[i] = invFact[i-1] * inverse(i) % MOD;
        }
        int[][] ranges = new int[n][];
        PriorityQueue<int[]> starts = new PriorityQueue<>((a, b) -> a[0] - b[0]);
        PriorityQueue<int[]> ends = new PriorityQueue<>((a, b) -> a[1] - b[1]);
        for (int i = 0; i < n; i++) {
            ranges[i] = iapar(2);
            starts.add(ranges[i]);
            ends.add(ranges[i]);
        }
        int[][] pairs = new int[m][];
        for (int i = 0; i < m; i++) {
            pairs[i] = iapar(2);
        }
        int[] count = new int[n+1];
        int curr = 0;
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            while (!starts.isEmpty() && starts.peek()[0] <= i) {
                starts.remove();
                curr++;
            }
            while (!ends.isEmpty() && ends.peek()[1] < i) {
                ends.remove();
                curr--;
            }
            count[i] = curr;
            ans += ncr(count[i], i);
            ans %= MOD;
        }
        // out.println(Arrays.toString(count));
        long[][] prefix = new long[n+1][m*2+1];
        for (int i = 0; i < n; i++) {
            for (int e = 0; e <= m*2; e++) {
                prefix[i+1][e] = (prefix[i][e] + ncr(count[i+1]-e, i+1-e)) % MOD;
            }
            // out.println(Arrays.toString(prefix[i+1]));
        }
        for (int mask = 1; mask < (1 << m); mask++) {
            int mult = Integer.bitCount(mask) % 2 == 0 ? 1 : -1;
            HashSet<Integer> set = new HashSet<>();
            int l = 0;
            int r = n+1;
            for (int i = 0; i < m; i++) {
                if ((mask & (1 << i)) != 0) {
                    set.add(pairs[i][0]);
                    set.add(pairs[i][1]);
                    l = Math.max(ranges[pairs[i][0]-1][0], l);
                    r = Math.min(ranges[pairs[i][0]-1][1], r);
                    l = Math.max(ranges[pairs[i][1]-1][0], l);
                    r = Math.min(ranges[pairs[i][1]-1][1], r);
                }
            }
            if (l <= r) {
                // out.printf("[%d,%d]%n", l, r);
                int bad = set.size();
                ans -= mult * prefix[l-1][bad];
                ans += mult * prefix[r][bad];
                ans += MOD*2;
                ans %= MOD;
            }
        }
        out.println(ans % MOD);
    }

    public long ncr(int a, int b) {
        if (a < 0 || b < 0 || a < b) {
            return 0;
        }
        return fact[a] * invFact[b] % MOD * invFact[a-b] % MOD;
    }

    public long inverse(long a) {
        return modPow(a, MOD-2);
    }

    public long modPow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 0) {
            return modPow(a*a%MOD, b/2);
        }
        return a * modPow(a*a%MOD, b/2) % MOD;
    }

    //////////////////////////////////////////////
    //             DEBUG PROPERTIES             //
    //////////////////////////////////////////////

    static final boolean RUN_TIMING = false;
    static final boolean AUTOFLUSH = false;
    static final boolean FILE_INPUT = false;
    static final boolean FILE_OUTPUT = false;

    ///////////////////////////////////////////
    //             TEMPLATE CODE             //
    ///////////////////////////////////////////

    static char[] inputBuffer = new char[1 << 20];
    static PushbackReader in = new PushbackReader(new BufferedReader(new InputStreamReader(System.in)), 1 << 20);
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), AUTOFLUSH);

    public int ipar() throws IOException {
        return Integer.parseInt(spar());
    }

    public int[] iapar(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar() throws IOException {
        return Long.parseLong(spar());
    }

    public long[] lapar(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar() throws IOException {
        return Double.parseDouble(spar());
    }

    public String spar() throws IOException {
        int len = 0;
        int c;
        do {
            c = in.read();
        } while (Character.isWhitespace(c) && c != -1);
        if (c == -1) {
            throw new NoSuchElementException("Reached EOF");
        }
        do {
            inputBuffer[len] = (char)c;
            len++;
            c = in.read();
        } while (!Character.isWhitespace(c) && c != -1);
        while (c != '\n' && Character.isWhitespace(c) && c != -1) {
            c = in.read();
        }
        if (c != -1 && c != '\n') {
            in.unread(c);
        }
        return new String(inputBuffer, 0, len);
    }

    public String linepar() throws IOException {
        int len = 0;
        int c;
        while ((c = in.read()) != '\n' && c != -1) {
            if (c == '\r') {
                continue;
            }
            inputBuffer[len] = (char)c;
            len++;
        }
        return new String(inputBuffer, 0, len);
    }

    public boolean haspar() throws IOException {
        String line = linepar();
        if (line.isEmpty()) {
            return false;
        }
        in.unread('\n');
        in.unread(line.toCharArray());
        return true;
    }

    public void shuffle(int[] arr) {
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            int j = (int)(Math.random() * (n-i));
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
    }

    public void shuffle(long[] arr) {
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            int j = (int)(Math.random() * (n-i));
            long temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
    }

    public void shuffle(Object[] arr) {
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            int j = (int)(Math.random() * (n-i));
            Object temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
    }

    public static void main(String[] args) throws IOException {
        if (FILE_INPUT) {
            in = new PushbackReader(new BufferedReader(new FileReader(new File("test.txt"))), 1 << 20);
        }
        if (FILE_OUTPUT) {
            out = new PrintWriter(new FileWriter(new File("output.txt")));
        }
        long time = 0;
        time -= System.nanoTime();
        new G().go();
        time += System.nanoTime();
        if (RUN_TIMING) {
            System.out.printf("%.3f ms%n", time / 1000000.0);
        }
        out.flush();
        in.close();
    }
}