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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long ans = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (f == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ans = (ans * 10) + ch - '0', ch = getchar();
  return ans * f;
}
const long long maxn = 500000;
const long long mod = 998244353;
long long fac[maxn], infac[maxn];
long long sum[maxn][41];
long long ksm(long long a, long long b) {
  long long sum = 1;
  while (b) {
    if (b & 1) sum = sum * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return sum;
}
long long n, m, ans;
void pre() {
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  infac[n] = ksm(fac[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--)
    infac[i] = infac[i + 1] * (i + 1) % mod;
  return;
}
long long C(long long n, long long m) {
  if (n < 0 || m < 0 || m > n) return 0;
  return fac[n] * infac[m] % mod * infac[n - m] % mod;
}
long long a[41], b[41], l[maxn], r[maxn];
long long cf[maxn], cnt[maxn];
long long len[2000000];
set<long long> ss;
signed main() {
  n = read(), m = read();
  for (long long i = 1; i < (1 << m); i++) len[i] = len[i & (i - 1)] + 1;
  pre();
  for (long long i = 1; i <= n; i++) {
    l[i] = read(), r[i] = read();
    cf[l[i]]++, cf[r[i] + 1]--;
  }
  long long temp = 0;
  for (long long i = 1; i <= n; i++) {
    temp += cf[i];
    cnt[i] = temp;
  }
  for (long long i = 1; i <= m; i++) a[i] = read(), b[i] = read();
  for (long long i = 0; i <= 40; i++)
    for (long long j = 1; j <= n; j++)
      sum[j][i] = (sum[j - 1][i] + C(cnt[j] - i, j - i)) % mod;
  for (long long s = 0; s < (1 << m); s++) {
    ss.clear();
    long long ll = 1, rr = n;
    for (long long j = 1; j <= m; j++) {
      if ((1 << (j - 1)) & s) {
        ll = max(ll, l[a[j]]), rr = min(rr, r[a[j]]), ss.insert(a[j]);
        ll = max(ll, l[b[j]]), rr = min(rr, r[b[j]]), ss.insert(b[j]);
      }
    }
    if (ll > rr) continue;
    long long add = sum[rr][ss.size()] - sum[ll - 1][ss.size()];
    ans = (ans + ((len[s] & 1) ? -1 : 1) * add % mod + mod) % mod;
    ans = (ans + mod) % mod;
  }
  cout << ans;
  return 0;
}