#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
bool RELAXED = false;
template <int, typename T>
struct MINMAX {
  T val;
  MINMAX(T val) : val(val) {}
};
template <typename T>
MINMAX<1, T> MAX(T val) {
  return MINMAX<1, T>(val);
};
template <typename T>
MINMAX<2, T> MIN(T val) {
  return MINMAX<2, T>(val);
};
template <typename T, typename U>
inline T& operator|=(T& lhs, MINMAX<1, U> rhs) {
  return lhs = (rhs.val > lhs ? (RELAXED = true, rhs.val)
                              : (RELAXED = false, lhs));
}
template <typename T, typename U>
inline T& operator|=(T& lhs, MINMAX<2, U> rhs) {
  return lhs = (rhs.val < lhs ? (RELAXED = true, rhs.val)
                              : (RELAXED = false, lhs));
}
template <typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
inline vector<T> READ(int n) {
  vector<T> vec(n);
  for (int i = 0; i < int(n); i++) cin >> vec[i];
  return vec;
}
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
struct node {
  int cnt, lb, rb, compId;
  bool operator<(const node& rhs) const { return false; }
};
vector<int> comp;
int compCount = 0;
map<int, vector<int> > adj;
const int MAXN = 3e5 + 5;
vector<pair<int, int> > bounds;
bool visited[MAXN];
bool taken[MAXN];
vector<node> nodes;
void dfs(int u) {
  if (visited[u]) return;
  visited[u] = true;
  comp.push_back(u);
  for (auto to : adj[u]) dfs(to);
}
void backtrack(int i, int cnt, int lb, int rb) {
  if (i == int(comp.size())) {
    if (lb <= rb) nodes.push_back({cnt, lb, rb, compCount});
    return;
  }
  backtrack(i + 1, cnt, lb, rb);
  int u = comp[i];
  for (auto to : adj[u])
    if (taken[to]) return;
  taken[u] = true;
  backtrack(i + 1, cnt + 1, max(lb, bounds[u].first),
            min(rb, bounds[u].second));
  taken[u] = false;
}
const int MOD = 998244353;
signed long long int fac[MAXN] = {1};
signed long long int invfac[MAXN];
signed long long int inverseModulo(signed long long int a,
                                   signed long long int b) {
  return 1 < a ? b - inverseModulo(b % a, a) * b / a : 1;
}
signed long long int binomial(int n, int k) {
  assert(k >= 0 && k <= n);
  if (k == 0 || n - k == 0) return 1;
  return fac[n] * invfac[k] % MOD * invfac[n - k] % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(12);
  int n, m;
  cin >> n >> m;
  bounds = READ<pair<int, int> >(n);
  for (int i = int(1); i <= int(MAXN - 1); i++) {
    fac[i] = 1LL * i * fac[i - 1] % MOD;
    invfac[i] = inverseModulo(fac[i], MOD);
  }
  for (int i = 0; i < int(m); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<int> compSize;
  for (int i = 0; i < int(n); i++) {
    comp.clear();
    dfs(i);
    if (comp.size() == 1) {
      nodes.push_back({1, bounds[i].first, bounds[i].second, -1});
    }
    if (comp.size() > 1) {
      backtrack(0, 0, 0, 1e9);
      compSize.push_back(comp.size());
      compCount++;
    }
    42;
  }
  signed long long int ans = 0;
  min_heap<pair<int, node> > add, remove;
  for (auto nd : nodes) {
    add.push({nd.lb, nd});
    remove.push({nd.rb, nd});
  }
  int cntSingle = 0;
  vector<vector<int> > cntComp(25, vector<int>(25, 0));
  for (int i = int(1); i <= int(n); i++) {
    while (add.size() && add.top().first <= i) {
      node nd = add.top().second;
      add.pop();
      if (nd.compId < 0)
        cntSingle += nd.cnt;
      else
        cntComp[nd.compId][nd.cnt]++;
    }
    while (remove.size() && remove.top().first < i) {
      node nd = remove.top().second;
      remove.pop();
      if (nd.compId < 0)
        cntSingle -= nd.cnt;
      else
        cntComp[nd.compId][nd.cnt]--;
    }
    signed long long int dp[25][25] = {{1}};
    for (int j = 0; j < int(compCount); j++) {
      for (int k = 0; k < int(compSize[j]); k++) {
        for (int l = 0; l < int(25 - k); l++) {
          dp[j + 1][l + k] += dp[j][l] * cntComp[j][k];
          dp[j + 1][l + k] %= MOD;
        }
      }
    }
    for (int l = 0; l < int(25); l++) {
      signed long long int cc = dp[compCount][l];
      if (cntSingle >= i - l && l <= i) {
        ans += cc * binomial(cntSingle, i - l);
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}

### Prompt

Please create a solution in CPP to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
bool RELAXED = false;
template <int, typename T>
struct MINMAX {
  T val;
  MINMAX(T val) : val(val) {}
};
template <typename T>
MINMAX<1, T> MAX(T val) {
  return MINMAX<1, T>(val);
};
template <typename T>
MINMAX<2, T> MIN(T val) {
  return MINMAX<2, T>(val);
};
template <typename T, typename U>
inline T& operator|=(T& lhs, MINMAX<1, U> rhs) {
  return lhs = (rhs.val > lhs ? (RELAXED = true, rhs.val)
                              : (RELAXED = false, lhs));
}
template <typename T, typename U>
inline T& operator|=(T& lhs, MINMAX<2, U> rhs) {
  return lhs = (rhs.val < lhs ? (RELAXED = true, rhs.val)
                              : (RELAXED = false, lhs));
}
template <typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
inline vector<T> READ(int n) {
  vector<T> vec(n);
  for (int i = 0; i < int(n); i++) cin >> vec[i];
  return vec;
}
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
struct node {
  int cnt, lb, rb, compId;
  bool operator<(const node& rhs) const { return false; }
};
vector<int> comp;
int compCount = 0;
map<int, vector<int> > adj;
const int MAXN = 3e5 + 5;
vector<pair<int, int> > bounds;
bool visited[MAXN];
bool taken[MAXN];
vector<node> nodes;
void dfs(int u) {
  if (visited[u]) return;
  visited[u] = true;
  comp.push_back(u);
  for (auto to : adj[u]) dfs(to);
}
void backtrack(int i, int cnt, int lb, int rb) {
  if (i == int(comp.size())) {
    if (lb <= rb) nodes.push_back({cnt, lb, rb, compCount});
    return;
  }
  backtrack(i + 1, cnt, lb, rb);
  int u = comp[i];
  for (auto to : adj[u])
    if (taken[to]) return;
  taken[u] = true;
  backtrack(i + 1, cnt + 1, max(lb, bounds[u].first),
            min(rb, bounds[u].second));
  taken[u] = false;
}
const int MOD = 998244353;
signed long long int fac[MAXN] = {1};
signed long long int invfac[MAXN];
signed long long int inverseModulo(signed long long int a,
                                   signed long long int b) {
  return 1 < a ? b - inverseModulo(b % a, a) * b / a : 1;
}
signed long long int binomial(int n, int k) {
  assert(k >= 0 && k <= n);
  if (k == 0 || n - k == 0) return 1;
  return fac[n] * invfac[k] % MOD * invfac[n - k] % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(12);
  int n, m;
  cin >> n >> m;
  bounds = READ<pair<int, int> >(n);
  for (int i = int(1); i <= int(MAXN - 1); i++) {
    fac[i] = 1LL * i * fac[i - 1] % MOD;
    invfac[i] = inverseModulo(fac[i], MOD);
  }
  for (int i = 0; i < int(m); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<int> compSize;
  for (int i = 0; i < int(n); i++) {
    comp.clear();
    dfs(i);
    if (comp.size() == 1) {
      nodes.push_back({1, bounds[i].first, bounds[i].second, -1});
    }
    if (comp.size() > 1) {
      backtrack(0, 0, 0, 1e9);
      compSize.push_back(comp.size());
      compCount++;
    }
    42;
  }
  signed long long int ans = 0;
  min_heap<pair<int, node> > add, remove;
  for (auto nd : nodes) {
    add.push({nd.lb, nd});
    remove.push({nd.rb, nd});
  }
  int cntSingle = 0;
  vector<vector<int> > cntComp(25, vector<int>(25, 0));
  for (int i = int(1); i <= int(n); i++) {
    while (add.size() && add.top().first <= i) {
      node nd = add.top().second;
      add.pop();
      if (nd.compId < 0)
        cntSingle += nd.cnt;
      else
        cntComp[nd.compId][nd.cnt]++;
    }
    while (remove.size() && remove.top().first < i) {
      node nd = remove.top().second;
      remove.pop();
      if (nd.compId < 0)
        cntSingle -= nd.cnt;
      else
        cntComp[nd.compId][nd.cnt]--;
    }
    signed long long int dp[25][25] = {{1}};
    for (int j = 0; j < int(compCount); j++) {
      for (int k = 0; k < int(compSize[j]); k++) {
        for (int l = 0; l < int(25 - k); l++) {
          dp[j + 1][l + k] += dp[j][l] * cntComp[j][k];
          dp[j + 1][l + k] %= MOD;
        }
      }
    }
    for (int l = 0; l < int(25); l++) {
      signed long long int cc = dp[compCount][l];
      if (cntSingle >= i - l && l <= i) {
        ans += cc * binomial(cntSingle, i - l);
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}

```