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 = 3e5 + 5, mod = 998244353;
int power(int a, int b) {
  if (b == 0) return 1;
  int res = power(a, b / 2);
  if (b & 1) return 1ll * res * res % mod * a % mod;
  return 1ll * res * res % mod;
}
int fact[maxn], ifact[maxn];
int sum[42][maxn];
int binom(int k, int n) {
  if (k > n || k < 0) return 0;
  return 1ll * fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fact[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    fact[i] = 1ll * fact[i - 1] * i % mod;
  }
  ifact[maxn - 1] = power(fact[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; --i) {
    ifact[i] = 1ll * ifact[i + 1] * (i + 1) % mod;
  }
  int N, M;
  cin >> N >> M;
  vector<int> L(N), R(N), deg(N + 2), A(M), B(M);
  for (int i = 0; i < N; ++i) {
    cin >> L[i] >> R[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i];
    --A[i];
    --B[i];
  }
  for (int i = 0; i < N; ++i) {
    deg[L[i]]++;
    deg[R[i] + 1]--;
  }
  for (int i = 1; i <= N; ++i) {
    deg[i] += deg[i - 1];
  }
  for (int sz = 0; sz <= 2 * M; ++sz) {
    for (int i = 1; i <= N; ++i) {
      sum[sz][i] = (sum[sz][i - 1] + binom(i - sz, deg[i] - sz)) % mod;
    }
  }
  function<void(int &, int)> add = [&](int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
  };
  int ans = 0;
  for (int mask = 0; mask < (1 << M); ++mask) {
    vector<int> p;
    for (int i = 0; i < M; ++i) {
      if (mask >> i & 1) {
        p.emplace_back(A[i]);
        p.emplace_back(B[i]);
      }
    }
    sort(p.begin(), p.end());
    p.erase(unique(p.begin(), p.end()), p.end());
    int l = max(1, (int)p.size()), r = N;
    for (int i : p) {
      l = max(l, L[i]);
      r = min(r, R[i]);
    }
    if (l > r) continue;
    int cur = (sum[p.size()][r] - sum[p.size()][l - 1] + mod) % mod;
    if (__builtin_popcount(mask) & 1)
      add(ans, -cur);
    else
      add(ans, cur);
  }
  cout << ans;
}