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 maxn = 300005, P = 998244353, S = 21;
int n, m, L[maxn], R[maxn], a[maxn], b[maxn], g[1 << S][S + 1], c[maxn],
    d[maxn], e[maxn];
int fact[maxn], infact[maxn], f[maxn][S * 2], tot, fa[maxn], sz[maxn],
    Log[1 << S], now[maxn], ans;
bool vis[maxn], ins[maxn];
vector<int> col[maxn];
int inline power(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = (long long)res * a % P;
    a = (long long)a * a % P;
    b >>= 1;
  }
  return res;
}
int inline C(int a, int b) {
  if (a < b || a < 0 || b < 0) return 0;
  return (long long)fact[a] * infact[b] % P * infact[a - b] % P;
}
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  scanf("%d%d", &n, &m);
  fact[0] = infact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = (long long)fact[i - 1] * i % P;
  infact[n] = power(fact[n], P - 2);
  for (int i = n - 1; i; i--)
    infact[i] = (long long)infact[i + 1] * (i + 1) % P;
  for (int i = 0; i <= 20; i++) Log[1 << i] = i;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", L + i, R + i);
    f[i][0] = 1, fa[i] = i, sz[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", a + i, b + i);
    fa[find(a[i])] = find(b[i]);
    ins[a[i]] = ins[b[i]] = true;
  }
  for (int i = 1; i <= n; i++) {
    if (!ins[i]) c[L[i]]++, c[R[i] + 1]--;
  }
  for (int i = 1; i <= n; i++) col[find(i)].push_back(i), c[i] += c[i - 1];
  for (int t = 1; t <= n; t++) {
    if (find(t) != t || col[t].size() == 1) continue;
    int k = col[t].size();
    for (int i = 1; i < (1 << k); i++)
      for (int j = 0; j <= k; j++) g[i][j] = 0;
    for (int i = 1; i < (1 << k); i++) {
      bool ok = true;
      int cnt = 0;
      for (int j = 0; j < k; j++)
        if (i >> j & 1) vis[col[t][j]] = true, cnt++;
      for (int j = 1; j <= m; j++)
        if (vis[a[j]] && vis[b[j]]) {
          ok = false;
          break;
        }
      for (int j = 0; j < k; j++)
        if (i >> j & 1) vis[col[t][j]] = false;
      if (ok) g[i][cnt] = 1;
    }
    for (int v = 0; v < k; v++) {
      for (int i = 1; i + 1 < (1 << k); i++) {
        for (int j = 1; j <= k; j++) {
          if (!g[i][j] || i >> v & 1) continue;
          (g[i + (1 << v)][j] += g[i][j]) %= P;
        }
      }
    }
    for (int i = 1; i <= n; i++) d[i] = 0, e[i] = 0;
    for (int i = 0; i < k; i++) {
      d[L[col[t][i]]] += 1 << i, d[R[col[t][i]] + 1] -= 1 << i;
      e[L[col[t][i]]]++, e[R[col[t][i]] + 1]--;
    }
    for (int i = 1; i <= n; i++) {
      d[i] += d[i - 1], e[i] += e[i - 1];
      now[i] += e[i];
      for (int j = now[i]; j; j--) {
        for (int v = 1; v <= min(j, e[i]); v++) {
          if (!f[i][j - v] || !g[d[i]][v]) continue;
          f[i][j] = (f[i][j] + (long long)f[i][j - v] * g[d[i]][v]) % P;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= now[i]; j++) {
      ans = (ans + (long long)f[i][j] * C(c[i], i - j)) % P;
    }
  }
  printf("%d\n", ans);
}