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 MOD = 998244353;
vector<int> fact, inv_fact, inv;
int add(int a, int b) {
  int x = a + b;
  if (x >= MOD) x -= MOD;
  if (x < 0) x += MOD;
  return x;
}
int sub(int a, int b) { return add(a, -b); }
int mult(int a, int b) { return 1LL * a * b % MOD; }
int pow_mod(int x, int m) {
  int r = 1;
  for (int mm = m; mm > 0; mm >>= 1, x = mult(x, x))
    if (m & 1) r = mult(r, x);
  return r;
}
int inv_mod(int x) { return pow_mod(x, MOD - 2); }
void prepare(int N) {
  inv.resize(N + 1);
  fact.resize(N + 1);
  inv_fact.resize(N + 1);
  fact[0] = inv[0] = inv_fact[0] = 1;
  fact[1] = inv[1] = inv_fact[1] = 1;
  for (int i = 2; i <= N; ++i) {
    fact[i] = mult(fact[i - 1], i);
    inv[i] = mult(inv[MOD % i], (MOD - MOD / i));
    inv_fact[i] = mult(inv_fact[i - 1], inv[i]);
  }
}
int binom(int a, int b) {
  if (b > a or a < 0 or b < 0) return 0;
  return mult(fact[a], mult(inv_fact[a - b], inv_fact[b]));
}
void run() {
  int N, M;
  cin >> N >> M;
  vector<int> L(N), R(N);
  for (int i = 0; i < N; ++i) cin >> L[i] >> R[i];
  vector<int> A(M), B(M);
  for (int i = 0; i < M; ++i) cin >> A[i] >> B[i];
  prepare(N);
  vector<int> counts(N + 2, 0);
  for (int i = 0; i < N; ++i) {
    counts[L[i]]++;
    counts[R[i] + 1]--;
  }
  for (int i = 1; i <= N + 1; ++i) {
    counts[i] += counts[i - 1];
  }
  vector<vector<int>> dp(N + 1, vector<int>(2 * M + 1));
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= 2 * M; ++j) {
      dp[i][j] = add(dp[i - 1][j], binom(counts[i] - j, i - j));
    }
  }
  int MM = 1 << M;
  int result = 0;
  for (int mask = 0; mask < MM; ++mask) {
    set<int> edges;
    int bits = 0;
    for (int j = 0; j < M; ++j) {
      if (mask & (1 << j)) {
        edges.insert(A[j] - 1);
        edges.insert(B[j] - 1);
        bits++;
      }
    }
    int left = 1, right = N;
    for (int n : edges) {
      left = max(left, L[n]);
      right = min(right, R[n]);
    }
    if (right < left) continue;
    int k = edges.size();
    int tmp = sub(dp[right][k], dp[left - 1][k]);
    if (bits & 1) tmp = -tmp;
    result = add(result, tmp);
  }
  cout << result << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  run();
}