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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Mercenaries solver = new Mercenaries();
        solver.solve(1, in, out);
        out.close();
    }

    static class Mercenaries {
        long[] fact = new long[(int) (3e5) + 5];
        long[] invFact = new long[(int) (3e5) + 5];
        long MOD = 998244353;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] cnt = new int[N + 2];
            int[] l = new int[N];
            int[] r = new int[N];
            int[][] pair = new int[M][2];
            for (int i = 0; i < N; i++) {
                l[i] = in.nextInt();
                r[i] = in.nextInt();
                cnt[l[i]]++;
                cnt[r[i] + 1]--;
            }
            for (int i = 0; i < M; i++) {
                pair[i][0] = in.nextInt() - 1;
                pair[i][1] = in.nextInt() - 1;
            }
            for (int i = 1; i <= N; i++) {
                cnt[i] += cnt[i - 1];
            }
            fact[0] = 1;
            invFact[0] = 1;
            for (int i = 1; i <= N + 1; i++) {
                fact[i] = fact[i - 1] * i;
                fact[i] %= MOD;
                invFact[i] = invFact[i - 1] * MathUtils.inverse(i, MOD);
                invFact[i] %= MOD;
            }
            long[][] pref = new long[41][N + 1];
            long tot = 0;
            for (int k = 0; k <= 40; k++) {
                for (int i = 1; i <= N; i++) {
                    pref[k][i] = nChooseK(cnt[i] - k, i - k) + pref[k][i - 1];
                    while (pref[k][i] >= MOD) {
                        pref[k][i] -= MOD;
                    }
                }
            }
            tot = pref[0][N];
            for (int i = 1; i < (1 << M); i++) {
                int maxL = -1;
                int minR = 10000000;
                HashSet<Integer> set = new HashSet<Integer>();
                for (int j = 0; j < M; j++) {
                    if ((i & (1 << j)) > 0) {
                        set.add(pair[j][0]);
                        set.add(pair[j][1]);
                        maxL = Math.max(maxL, l[pair[j][0]]);
                        maxL = Math.max(maxL, l[pair[j][1]]);
                        minR = Math.min(minR, r[pair[j][0]]);
                        minR = Math.min(minR, r[pair[j][1]]);
                    }
                }
                if (maxL <= minR) {
                    tot += (Integer.bitCount(i) % 2 == 1 ? -1 : 1) * (pref[set.size()][minR] - pref[set.size()][maxL - 1]);
                    while (tot < 0) {
                        tot += MOD;
                    }
                    while (tot >= MOD) {
                        tot -= MOD;
                    }
                }
            }
            out.println(tot);
        }

        long nChooseK(int N, int K) {
            if (K > N || K < 0 || N < 0) {
                return 0;
            } else {
                long res = fact[N] * invFact[K];
                res %= MOD;
                res *= invFact[N - K];
                return res % MOD;
            }
        }

    }

    static class MathUtils {
        public static long inverse(long a, long mod) {
            long[] inv = extended_gcd(a, mod);
            if (inv[0] != 1) {
                return 0;
            } else {
                return (inv[1] + 2 * mod) % mod;
            }
        }

        public static long[] extended_gcd(long a, long b) {
            //three numbers, first is gcd, second is x, third is y
            if (a == 0) {
                return new long[]{b, 0, 1};
            }
            long[] next = extended_gcd(b % a, a);
            long tempX = next[1];
            next[1] = next[2] - (b / a) * next[1];
            next[2] = tempX;
            return next;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}