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>
#pragma GCC optimize("O3")
using namespace std;
const int N = 3e5 + 5;
const long long mod = 998244353;
int n, m, used[N], others;
vector<pair<int, int>> lr;
set<pair<int, int>> edges;
vector<int> g[N];
vector<vector<int>> comps;
set<int> in_comp;
vector<int> comp;
int paint(int v, int col) {
  used[v] = col;
  comp.push_back(v);
  int rt = 1;
  for (int u : g[v]) {
    if (!used[u]) {
      rt += paint(u, col);
    }
  }
  return rt;
}
int add(int a, int b) { return (a + b) % mod; }
int mult(int a, int b) { return ((long long)a * b) % mod; }
int pw(int a, int b) {
  if (!b) return 1;
  if (b & 1) return mult(pw(a, b - 1), a);
  int v = pw(a, b / 2);
  return mult(v, v);
}
int fact[N], invfact[N];
int cnk(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  return mult(fact[n], mult(invfact[k], invfact[n - k]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  fact[0] = 1;
  invfact[0] = pw(fact[0], mod - 2);
  for (int i = 1; i <= n; ++i) {
    fact[i] = mult(fact[i - 1], i);
    invfact[i] = pw(fact[i], mod - 2);
  }
  lr.resize(n);
  for (int i = 0; i < n; ++i) cin >> lr[i].first >> lr[i].second;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[v].push_back(u);
    g[u].push_back(v);
    edges.insert({min(v, u), max(v, u)});
  }
  int color = 1;
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      comp.clear();
      int x = paint(i, color++);
      if (x > 1) {
        comps.push_back(comp);
        for (int v : comp) in_comp.insert(v);
      } else
        others++;
    }
  }
  vector<vector<vector<int>>> dp(comps.size());
  color = comps.size();
  for (int i = 0; i < color; ++i) {
    auto &component = comps[i];
    int size = component.size();
    dp[i].resize(1 << size, vector<int>(size + 1));
    vector<vector<bool>> is(size, vector<bool>(size, false));
    for (int ii = 0; ii < size; ++ii) {
      for (int jj = 0; jj < size; ++jj) {
        int u = component[ii], v = component[jj];
        if (edges.find({u, v}) != edges.end()) {
          is[ii][jj] = is[jj][ii] = true;
        }
      }
    }
    for (int mask = 0; mask < (1 << size); ++mask) {
      bool ok = true;
      for (int bit1 = 0; bit1 < size; ++bit1) {
        if (!(mask >> bit1 & 1)) continue;
        for (int bit2 = bit1 + 1; bit2 < size; ++bit2) {
          if ((mask >> bit2 & 1) && is[bit1][bit2]) ok = false;
        }
      }
      if (ok) dp[i][mask][__builtin_popcount(mask)] = 1;
    }
    for (int bit = 0; bit < size; ++bit)
      for (int mask = 0; mask < (1 << size); ++mask)
        if (!(mask >> bit & 1))
          for (int ii = 0; ii < size; ++ii)
            dp[i][mask | 1 << bit][ii] += dp[i][mask][ii];
  }
  vector<int> lr_new;
  for (int i = 0; i < n; ++i)
    if (in_comp.find(i) == in_comp.end()) lr_new.push_back(i);
  vector<int> oth(n + 2, 0);
  for (int i = 0; i < lr_new.size(); ++i) {
    oth[lr[lr_new[i]].first]++;
    oth[lr[lr_new[i]].second + 1]--;
  }
  for (int i = 1; i <= n; ++i) oth[i] = oth[i - 1] + oth[i];
  int ans = 0;
  for (int num = 1; num <= n; ++num) {
    int inside = 0;
    vector<int> bag(2 * m + 2);
    bag[0] = 1;
    for (int c = 0; c < color; ++c) {
      auto &component = comps[c];
      int size = component.size(), mask = 0;
      for (int i = 0; i < size; ++i)
        if (lr[component[i]].first <= num && lr[component[i]].second >= num)
          mask |= 1 << i;
      for (int i = m; i >= 0; --i)
        for (int up = 1; up <= size; ++up)
          bag[i + up] = add(bag[i + up], mult(bag[i], dp[c][mask][up]));
    }
    for (int take = 0; take <= min(m, num); ++take) {
      ans = add(ans, mult(bag[take], cnk(oth[num], num - take)));
    }
  }
  cout << ans << '\n';
}