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;
const int CN = 4e5 + 5;
const int P = 998244353;
int read() {
  int s = 0, ne = 1;
  char c = getchar();
  while (c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
  while (c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
  return s * ne;
}
int qp(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = 1ll * r * a % P;
    a = 1ll * a * a % P;
    b >>= 1;
  }
  return r;
}
class ANTI {
 public:
  int a, b;
} Q[50];
class SGT {
 public:
  int tag[CN << 2];
  SGT() { memset(tag, 0, sizeof(tag)); }
  void pd(int k) {
    tag[k << 1] += tag[k], tag[k << 1 | 1] += tag[k], tag[k] = 0;
  }
  void md(int l, int r, int k, int s, int t) {
    if (s <= l && r <= t) return (void)(tag[k]++);
    int m = (l + r) >> 1;
    if (tag[k]) pd(k);
    if (s <= m) md(l, m, k << 1, s, t);
    if (m < t) md(m + 1, r, k << 1 | 1, s, t);
  }
  int qu(int l, int r, int k, int p) {
    if (l == r) return tag[k];
    int m = (l + r) >> 1;
    if (tag[k]) pd(k);
    if (p <= m)
      return qu(l, m, k << 1, p);
    else
      return qu(m + 1, r, k << 1 | 1, p);
  }
} D;
int n, m, L[CN], R[CN], f[CN][50], cnt[CN];
int fac[CN], ifac[CN];
int C(int n, int m) {
  return n < m || n < 0 || m < 0
             ? 0
             : 1ll * fac[n] * (1ll * ifac[m] * ifac[n - m] % P) % P;
}
set<int> T;
int bits(int x) {
  int r = 0;
  while (x) r += x & 1, x >>= 1;
  return r;
}
int si(int l, int r) {
  int s = T.size();
  return l > r ? 0 : (f[r][s] - f[l - 1][s] + P) % P;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    L[i] = read(), R[i] = read(), D.md(1, n, 1, L[i], R[i]);
  for (int i = 0; i < m; i++) Q[i].a = read(), Q[i].b = read();
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % P;
  ifac[n] = qp(fac[n], P - 2);
  for (int i = n - 1; i; i--) ifac[i] = 1ll * (i + 1) * ifac[i + 1] % P;
  for (int i = 1; i <= n; i++) cnt[i] = D.qu(1, n, 1, i);
  for (int k = 0; k <= (m << 1); k++)
    for (int i = 1; i <= n; i++)
      f[i][k] = (f[i - 1][k] + C(cnt[i] - k, i - k)) % P;
  int ans = 0;
  for (int S = 0; S < (1 << m); S++) {
    int b = bits(S), k = b & 1 ? -1 : 1, l = 1, r = n;
    T.clear();
    for (int i = 0; i < m; i++)
      if (S & (1 << i))
        T.insert(Q[i].a), T.insert(Q[i].b),
            l = max(l, max(L[Q[i].a], L[Q[i].b])),
            r = min(r, min(R[Q[i].a], R[Q[i].b]));
    ans = (((ans + k * si(l, r)) % P) + P) % P;
  }
  printf("%d", ans);
}