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;
int64_t mod = 998244353;
int64_t fac[300005];
int64_t inv[300005];
int64_t qpow(int64_t x, int64_t n) {
  int64_t ret = 1;
  while (n) {
    if (n & 1) ret = ret * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}
int64_t ncr(int64_t n, int64_t r) {
  if (n < 0 || r < 0 || r > n) return 0;
  return (((fac[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
int64_t cache[300005][45];
int64_t cover[300005];
int64_t n, m, l[300005], r[300005], a[45], b[45];
int32_t main() {
  cin >> n >> m;
  for (int64_t i = 1; i <= n; i++) cin >> l[i] >> r[i];
  for (int64_t i = 1; i <= m; i++) cin >> a[i] >> b[i];
  fac[0] = 1;
  inv[0] = 1;
  for (int64_t i = 1; i < 300005; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = qpow(fac[i], mod - 2);
  }
  for (int64_t i = 1; i <= n; i++) {
    cover[l[i]]++;
    cover[r[i] + 1]--;
  }
  for (int64_t i = 1; i <= n; i++) {
    cover[i] += cover[i - 1];
    cover[i] %= mod;
    if (0) printf("cover[%ld] = %ld\n", i, cover[i]);
  }
  int64_t answer = 0;
  for (int64_t x = 1; x <= n; x++) {
    answer += ncr(cover[x], x);
    answer %= mod;
  }
  for (int64_t x = 1; x <= n; x++) {
    for (int64_t k = 0; k < 45; k++) {
      cache[x][k] = (cache[x - 1][k] + ncr(cover[x] - k, x - k)) % mod;
      if (0) printf("cache[%ld][%ld] = %ld\n", x, k, cache[x][k]);
    }
  }
  if (0) printf("temp answer = %ld\n", answer);
  int64_t limit = 1 << m;
  for (int64_t bits = 1; bits < limit; bits++) {
    if (0) cout << bitset<32>(bits) << endl;
    int64_t cnt = __builtin_popcount(bits);
    int64_t contribution = cnt % 2 == 1 ? -1 : 1;
    int64_t s = 1;
    int64_t e = n;
    set<int64_t> uniq;
    for (int64_t shift = 1; shift <= m; shift++) {
      if (bits & (1 << (shift - 1))) {
        s = max(s, l[a[shift]]);
        s = max(s, l[b[shift]]);
        e = min(e, r[a[shift]]);
        e = min(e, r[b[shift]]);
        uniq.insert(a[shift]);
        uniq.insert(b[shift]);
      }
    }
    if (s > e) continue;
    int64_t c = uniq.size();
    if (0) printf("s = %ld, e = %ld, c = %ld\n", s, e, c);
    answer += contribution * (cache[e][c] - cache[s - 1][c]);
    answer += mod;
    answer %= mod;
  }
  cout << answer << endl;
}