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>
const long long mod = 998244353;
const long long N = 301000;
long long n, m, ans;
long long l[N], r[N], a[N], b[N];
long long jie[N], inv[N];
long long cha[N], sum[41][N], s[N];
long long qpow(long long x, long long y) {
  long long base = x % mod, qpowans = 1;
  while (y) {
    if (y & 1) qpowans = qpowans * base % mod;
    base = base * base % mod;
    y >>= 1;
  }
  return qpowans;
}
void pre() {
  jie[0] = jie[1] = 1, inv[0] = inv[1] = 1;
  for (long long i = 2; i <= N - 1000; ++i) jie[i] = jie[i - 1] * i % mod;
  for (long long i = 2; i <= N - 1000; ++i)
    inv[i] = inv[i - 1] * qpow(i, mod - 2) % mod;
  return;
}
long long getC(long long x, long long y) {
  if (x < y || x < 0 || y < 0) return 0;
  return jie[x] * inv[y] % mod * inv[x - y] % mod;
}
inline long long lowbit(long long x) { return x & (-x); }
inline long long read() {
  long long r = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    r = (r << 3) + (r << 1) + (ch ^ 48);
    ch = getchar();
  }
  return r * w;
}
signed main() {
  pre();
  n = read();
  m = read();
  for (long long i = 1; i <= n; ++i) {
    l[i] = read();
    r[i] = read();
    ++cha[l[i]];
    --cha[r[i] + 1];
  }
  for (long long i = 1; i <= m; ++i) a[i] = read(), b[i] = read();
  for (long long i = 1, ssum = 0; i <= n; ++i) {
    ssum += cha[i];
    s[i] = ssum;
  }
  for (long long i = 0; i <= 40; ++i)
    for (long long j = 1; j <= n; ++j) {
      sum[i][j] = (sum[i][j - 1] + getC(s[j] - i, j - i)) % mod;
    }
  for (long long i = 0; i < (1 << m); ++i) {
    long long ll = 1, rr = n;
    std::set<long long> vis;
    for (long long j = 1; j <= m; ++j)
      if ((i >> (j - 1)) & 1) {
        ll = std::max(ll, l[a[j]]);
        rr = std::min(rr, r[a[j]]);
        vis.insert(a[j]);
        ll = std::max(ll, l[b[j]]);
        rr = std::min(rr, r[b[j]]);
        vis.insert(b[j]);
      }
    if (ll > rr) continue;
    long long nowi = i, cnt = 0, cntvis = vis.size(),
              nowsum = (sum[cntvis][rr] - sum[cntvis][ll - 1] + mod) % mod;
    while (nowi) nowi -= lowbit(nowi), ++cnt;
    if (!(cnt & 1))
      ans = (ans + nowsum) % mod;
    else
      ans = (ans - nowsum + mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}