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 long long mod = 998244353;
const int maxN = 3 * 1e5 + 1;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b /= 2;
    a = (a * a) % mod;
  }
  return ans;
}
long long inverse(long long x) { return power(x, mod - 2); }
vector<long long> fact(maxN), fact_inv(maxN);
void precalc_fact() {
  fact[1] = fact_inv[1] = 1;
  for (long long i = 2; i < maxN; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
    fact_inv[i] = inverse(fact[i]);
  }
}
long long binom(long long a, long long b) {
  if (b > a) return 0;
  if (b == a || b == 0) return 1;
  long long ans = fact[a];
  ans = (ans * fact_inv[b]) % mod;
  ans = (ans * fact_inv[a - b]) % mod;
  return ans;
}
int n, m;
vector<pair<int, int>> hate;
vector<bool> hates;
vector<bool> isIn;
vector<int> hate_cnt;
vector<long long> incl_excl_cnt;
void precalc_subsets() {
  for (int i = 0; i < (1 << m); ++i) {
    set<int> s;
    for (int j = 0; j < m; ++j) {
      if ((1 << j) & i) {
        s.insert(hate[j].first);
        s.insert(hate[j].second);
      }
    }
    hate_cnt[i] = (int)s.size();
  }
}
void incl_excl(int subset, int i, int sign = -1) {
  if (i == m) {
    incl_excl_cnt[hate_cnt[subset]] += sign;
  } else {
    incl_excl(subset, i + 1, sign);
    if (isIn[hate[i].first] && isIn[hate[i].second])
      incl_excl(subset | (1 << i), i + 1, sign * (-1));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  hate.resize(m);
  isIn.resize(n);
  hates.resize(n);
  hate_cnt.resize(1 << m);
  incl_excl_cnt.resize(2 * m + 1);
  vector<vector<int>> slide(n + 2);
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    slide[l].push_back(i);
    slide[r + 1].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    hate[i].first = a;
    hate[i].second = b;
    hates[a] = true;
    hates[b] = true;
  }
  precalc_fact();
  precalc_subsets();
  int mercs = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    bool recalc = false;
    for (int j : slide[i]) {
      isIn[j] = !isIn[j];
      if (isIn[j])
        mercs++;
      else
        mercs--;
      if (hates[j]) recalc = true;
    }
    if (recalc) {
      incl_excl_cnt.assign(2 * m + 1, 0);
      incl_excl(0, 0);
    }
    long long cnt = binom(mercs, i);
    for (int j = 1; j <= 2 * m && j <= i; ++j) {
      cnt = (cnt - incl_excl_cnt[j] * binom(mercs - j, i - j) + mod) % mod;
    }
    ans = (ans + cnt) % mod;
  }
  cout << ans << "\n";
}