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 N = 300005, M = 25;
const long long p = 998244353ll;
inline long long expo(long long a, int b = 998244351) {
  long long c = 1ll;
  while (b) {
    if (b & 1) c = c * a % p;
    b >>= 1;
    a = a * a % p;
  }
  return c;
}
long long FAC[N], IFA[N];
inline long long comb(int a, int b) {
  return (b < 0 || b > a) ? 0ll : (FAC[a] * (IFA[b] * IFA[a - b] % p) % p);
}
vector<int> L[N], R[N];
int I[N], C[M << 1];
long long E[M], ss;
inline void dfs(int m, long long a, int w = 1) {
  if (m) {
    dfs(m - 1, a, w);
    if ((ss & E[m]) == E[m]) dfs(m - 1, a & (~E[m]), -w);
  } else {
    C[__builtin_popcountll(a)] += w;
  }
}
int main() {
  int n, m, i, a, b, c = 0, f = 0, c0 = 0, c1 = 0;
  long long ans = 0ll, s1 = 0ll;
  vector<int>::iterator d;
  scanf("%d%d", &n, &m);
  FAC[0] = 1ll;
  for (i = (1); i <= (n); ++i) FAC[i] = FAC[i - 1] * i % p;
  IFA[n] = expo(FAC[n]);
  for (i = (n); i >= (1); --i) IFA[i - 1] = IFA[i] * i % p;
  for (i = (1); i <= (n); ++i) {
    scanf("%d%d", &a, &b);
    L[a].push_back(i);
    R[b].push_back(i);
  }
  for (i = (1); i <= (m); ++i) {
    scanf("%d%d", &a, &b);
    if (!I[a]) I[a] = ++c;
    if (!I[b]) I[b] = ++c;
    E[i] = (1ll << I[a]) | (1ll << I[b]);
  }
  C[0] = 1;
  for (i = (1); i <= (n); ++i) {
    for (d = L[i].begin(); d != L[i].end(); ++d) {
      a = *d;
      if (I[a]) {
        ++c1;
        f = 1;
        s1 |= 1ll << I[a];
      }
      ++c0;
    }
    if (f) {
      for (a = (0); a <= (c1); ++a) C[a] = 0;
      ss = s1;
      dfs(m, s1);
      f = 0;
    }
    for (a = (0); a <= (c1); ++a)
      ans = (ans + (C[c1 - a] + p) * comb(c0 - a, i - a)) % p;
    for (d = R[i].begin(); d != R[i].end(); ++d) {
      a = *d;
      if (I[a]) {
        --c1;
        f = 1;
        s1 ^= 1ll << I[a];
      }
      --c0;
    }
  }
  printf("%lld", ans);
  return 0;
}