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 A {
	public static void main (String[] args) { new A(); }

	int MOD = 998244353;
	int[] fact, invFact;
	
	public A() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int N = fs.nextInt();
		int M = fs.nextInt();
		
		set(N);
		
		int[][] ranges = new int[N][2];
		for(int i = 0; i < N; i++) {
			ranges[i] = fs.nextIntArray(2);
		}
		
		int[][] edges = new int[M][2];
		for(int i = 0; i < M; i++) {
			edges[i][0] = fs.nextInt()-1;
			edges[i][1] = fs.nextInt()-1;
		}
		
		int[] cnts = new int[N + 2];
		for(int i = 0; i < N; i++) {
			int L = ranges[i][0];
			int R = ranges[i][1];
			cnts[L]++;
			cnts[R+1]--;
		}
		
		int[] freq = new int[N + 2];
		for(int i = 1, sum = 0; i < freq.length; i++) {
			sum += cnts[i];
			freq[i] = sum;
		}
		
		int total = 0;
		for(int size = 1; size <= N; size++) {
			if(freq[size] >= size) {
				int ways = nChooseK(freq[size], size);
				total = add(total, ways);
			}
		}
		
		int[][] precomp = new int[N+1][2*M+1];
		for(int i = 1; i <= N; i++) {
			for(int sub = 1; sub <= Math.min(2*M, freq[i]); sub++) {
				if(freq[i] >= i && i >= sub)
					precomp[i][sub] = nChooseK(freq[i]-sub, i-sub);
			}
		}
		int[][] prefixSum = new int[2*M+1][N+1];
		for(int i = 0; i < prefixSum.length; i++) {
			prefixSum[i][0] = precomp[0][i];
			for(int j = 1; j <= N; j++) {
				prefixSum[i][j] = add(prefixSum[i][j-1], precomp[j][i]);
			}
		}

		int[] marked = new int[N+1];
		for(int mask = 1; mask < (1 << M); mask++) {
			int bigL = 0, minR = N, curCnt = 0;
			for(int i = 0; i < M; i++) {
				int on = (1<<i)&mask;
				if(on == 0) continue;
				
				int u = edges[i][0], v = edges[i][1];
				if(marked[u] != mask) {
					marked[u] = mask;
					curCnt++;
				}
				if(marked[v] != mask) {
					marked[v] = mask;
					curCnt++;
				}
				
				bigL = Math.max(bigL, ranges[u][0]);
				bigL = Math.max(bigL, ranges[v][0]);
				minR = Math.min(minR, ranges[u][1]);
				minR = Math.min(minR, ranges[v][1]);
			}
			if(minR < bigL) continue;
			boolean sub = Integer.bitCount(mask)%2 == 1;
			
			int val = query(prefixSum[curCnt], bigL, minR);
			if(sub) total = sub(total, val);
			else total = add(total, val);
		}
		out.println(total);
		
		out.close();
	}
	
	int query(int[] a, int L, int R) {
		int res = a[R];
		if(L > 0) res = sub(res, a[L-1]);
		return res;
	}
	
	int nChooseK(int n, int k) {
		int den = mult(invFact[k], invFact[n-k]);
		int num = fact[n];
		return mult(num, den);
	}

	void set(int n) {
		fact = new int[n + 10];
		fact[0] = 1;
		for(int i = 1; i < fact.length; i++) {
			fact[i] = mult(fact[i-1], i);
		}
		
		int[] invs = new int[n + 10];
		invs[0] = invs[1] = 1;
		for (int i = 2; i < invs.length; ++i) {
			int term1 = MOD - (MOD / i);
			invs[i] = mult(term1, invs[MOD % i]);
		}
		invFact = new int[n + 10];
		invFact[0] = invs[0];
		for(int i = 1; i < invFact.length; i++) {
			invFact[i] = mult(invFact[i-1], invs[i]);
		}
		
	}
	
	int add(int a, int b) {
		a += b;
		if(a >= MOD) a -= MOD;
		return a;
	}
	int sub(int a, int b) {
		a -= b;
		if(a < 0) a += MOD;
		return a;
	}
	int mult(long a, long b) {
		a *= b;
		if(a >= MOD) a %= MOD;
		return (int)a;
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}