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.util.*;

public class g {
	
	static long mod=998244353;
	static int sum[];
	static Vector vec;
	static int dsu[],siz[];
	static long fac[]=new long[300066];
	 
	
	public static void main(String args[])
	{
		fac[0]=1;
		for(int i=1;i<=300000;i++)fac[i]=fac[i-1]*i%mod;
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		
		int l[]=new int[n+10];
		int r[]=new int[n+10];
		int a[]=new int[30];
		int b[]=new int[30];
		boolean vis[]=new boolean[30];
		boolean viss[]=new boolean[n+10];
		boolean visss[]=new boolean[n+10];
		dsu=new int[n+10];
		siz=new int[n+10];
		sum=new int[n+10];
		vec=new Vector();
		
		
		for(int i=1;i<=n;i++)
		{
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
			sum[l[i]]++;
			sum[r[i]+1]--;

		}
		for(int i=1;i<=n;i++)
		{
			sum[i]=sum[i]+sum[i-1];
		}
		for(int i=0;i<m;i++)
		{
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		long ans=0;
		long f[]=new long[50];
		int allleft=0;
		f[0]=1;
		for(int i=1;i<=n;i++)
		{
			boolean mybool=true;
			
			//for(int j=0;j<vec.size();j++)invec[(int)vec.elementAt(j)]=false;
			vec.clear();
			
			for(int j=0;j<m;j++)
			{
				if(i>=l[a[j]]&&i<=r[a[j]]&&i>=l[b[j]]&&i<=r[b[j]])
				{
					vec.add(a[j]);
					vec.add(b[j]);
					viss[a[j]]=false;
					viss[b[j]]=false;
					dsu[a[j]]=a[j];
					dsu[b[j]]=b[j];
					if(!vis[j])
					{
						vis[j]=true;
						mybool=false;
					}
				}
				else
				{
					if(vis[j])
					{
						vis[j]=false;
						mybool=false;
					}
				}
			}
			if(!mybool)
			{
				allleft=0;
				for(int j=0;j<m;j++)
				{
					if(!vis[j])continue;
					int s=myfind(a[j]),t=myfind(b[j]);
					dsu[s]=t;
				}
				int cnt=0;
				
				Vector v=new Vector();
				//long f[]=new long[50];
				for(int k=0;k<=20;k++)f[k]=0;
				f[0]=1;
				for(int j=0;j<vec.size();j++)
				{
					int w=(int)vec.elementAt(j);
					if(viss[w])continue;
					v.clear();
					for(int k=0;k<vec.size();k++)
					{
						int ww=(int)vec.elementAt(k);
						if(myfind(w)!=myfind(ww)||viss[ww])continue;
						viss[ww]=true;   allleft++;
						v.add(ww);
						//System.out.printf("%d__**\n", ww);
					}
					long g[]=new long[50];
					for(int k=1;k<(1<<v.size());k++)
					{
						int cn=0;
						for(int p=0;p<v.size();p++)
						{
							if(((1<<p)&k)>0)
							{
								visss[(int)v.elementAt(p)]=true;
								cn++;
							}
						}
						boolean myboo=true;
						for(int p=0;p<m;p++)
						{
							if(visss[a[p]]&&visss[b[p]])myboo=false;
						}
						if(myboo)g[cn]++;
						
						for(int p=0;p<v.size();p++)
						{
							if(((1<<p)&k)>0)visss[(int)v.elementAt(p)]=false;
						}
					}
					for(int k=20;k>=0;k--)
					{
						for(int p=k;p>=0;p--)
						{
							f[k]=(f[k]+f[p]*g[k-p])%mod;
						}
					}
				}
				
				for(int j=0;j<vec.size();j++)
				{
					int w=(int)vec.elementAt(j);
					viss[w]=false;
				}
				
				
				
				
			}
			
			for(int k=0;k<=20;k++)
			{
				ans=(ans+C(sum[i]-allleft,i-k)*f[k])%mod;
			}
			//System.out.printf("%d ___\n", ans)	;
			
			
			
			
			
			
		}
		
		System.out.println(ans);
	}
	
	static int myfind(int x)
	{
		if(dsu[x]==x)return x;
		return dsu[x]=myfind(dsu[x]);
	}
	
	static long powmod(long a,long n)
	{
		long ret=1;
		while(n>0)
		{
			if((n&1)>0)ret=ret*a%mod;
			a=a*a%mod;
			n>>=1;
		}return ret;
	}
	
	static long C(int n,int m)
	{
		if(m<0)return 0;
		if(n<m)return 0;
		if(n==0)return 1;
		if(n<0)return 0;
		
		return fac[n]*powmod(fac[m],mod-2)%mod*powmod(fac[n-m],mod-2)%mod;
	}
}


/*
 * 
 * 
2 1
1 2
1 2
1 2
 * */