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 = 45, P = 998244353;
int n, m, ans, L[N], R[N], f[N], a[N], b[N], s[N], p[N], g[M][N];
vector<int> v;
inline int bp(int x, int y) {
  int r = 1;
  for (; y; y = y >> 1, x = 1ll * x * x % P)
    if (y & 1) r = 1ll * r * x % P;
  return r;
}
inline int C(int x, int y) {
  return 1ll * f[x] * bp(1ll * f[x - y] * f[y] % P, P - 2) % P;
}
inline void add(int& x, int y) {
  if ((x += y) >= P) x -= P;
}
inline void sub(int& x, int y) {
  if ((x -= y) < 0) x += P;
}
int main() {
  scanf("%d%d", &n, &m), f[0] = 1;
  for (int i = 1; i <= n; i++) f[i] = 1ll * f[i - 1] * i % P;
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &L[i], &R[i]);
    s[R[i]]++, s[L[i] - 1]--;
  }
  for (int i = n; i >= 1; i--) s[i - 1] += s[i];
  for (int i = 1; i <= n; i++)
    if (s[i] >= i)
      for (int j = 0; j <= min(2 * m, i); j++)
        if (s[i] >= j) g[j][i] = C(s[i] - j, i - j);
  for (int i = 0; i <= 2 * m; i++)
    for (int j = 1; j <= n; j++) add(g[i][j], g[i][j - 1]);
  for (int i = 0; i < m; i++) scanf("%d%d", &a[i], &b[i]);
  ans = g[0][n];
  for (int S = 1; S < (1 << m); S++) {
    int l = 1, r = n, ll, rr, cnt = 0;
    v.clear();
    for (int j = 0; j < m; j++)
      if ((S >> j) & 1) {
        if (!p[a[j]]) v.push_back(a[j]), p[a[j]] = 1, cnt++;
        if (!p[b[j]]) v.push_back(b[j]), p[b[j]] = 1, cnt++;
      }
    for (int j = 0; j < m; j++)
      if ((S >> j) & 1) p[a[j]] = 0, p[b[j]] = 0;
    for (int i = 0; i < v.size(); i++) {
      ll = L[v[i]], rr = R[v[i]];
      if (ll < l) swap(ll, l), swap(rr, r);
      if (r < ll) {
        l = n + 1;
        break;
      }
      l = ll, r = min(r, rr);
    }
    if (l == n + 1) continue;
    int c = g[cnt][r] - g[cnt][l - 1], t = __builtin_popcount(S);
    if (c < 0) c += P;
    if (t & 1)
      sub(ans, c);
    else
      add(ans, c);
  }
  printf("%d", ans);
}