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 p = 998244353;
inline int fpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = 1ll * ans * x % p;
    x = 1ll * x * x % p, y >>= 1;
  }
  return ans;
}
int sum[300086], inv[300086];
inline int C(int n, int m) {
  if (n < 0 || m < 0 || n < m) return 0;
  return 1ll * sum[n] * inv[m] % p * inv[n - m] % p;
}
int n, m;
int a[300086], b[300086], c[300086];
int f[45][300086];
int u[25], v[25];
int ans;
bool vis[300086];
int main() {
  sum[0] = 1;
  for (int i = 1; i < 300086; i++) sum[i] = 1ll * sum[i - 1] * i % p;
  inv[300086 - 1] = fpow(sum[300086 - 1], p - 2);
  for (int i = 300086 - 2; ~i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % p;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    c[a[i]]++, c[b[i] + 1]--;
  }
  for (int i = 1; i <= n; i++) c[i] += c[i - 1];
  for (int j = 0; j <= 2 * m; j++) {
    for (int i = 1; i <= n; i++) {
      f[j][i] = (f[j][i - 1] + C(c[i] - j, i - j)) % p;
    }
  }
  for (int i = 1; i <= m; i++) scanf("%d%d", &u[i], &v[i]);
  for (int i = (1 << m) - 1; ~i; i--) {
    int l = 1, r = n, cnt = 0;
    for (int j = 1, k = 1; j <= m; j++, k <<= 1) {
      if (!(i & k)) continue;
      if (!vis[u[j]]) {
        vis[u[j]] = true, cnt++;
        l = max(l, a[u[j]]), r = min(r, b[u[j]]);
      }
      if (!vis[v[j]]) {
        vis[v[j]] = true, cnt++;
        l = max(l, a[v[j]]), r = min(r, b[v[j]]);
      }
    }
    if (l <= r) {
      int sum = (f[cnt][r] + p - f[cnt][l - 1]) % p;
      if (__builtin_popcount(i) & 1)
        ans = (ans + p - sum) % p;
      else
        ans = (ans + sum) % p;
    }
    for (int j = 1, k = 1; j <= m; j++, k <<= 1) {
      if (!(i & k)) continue;
      vis[u[j]] = vis[v[j]] = false;
    }
  }
  printf("%d", ans);
}